/* TicketBot website: account linking and the panel. Dark, Discord-like; no inline styles (CSP style-src 'self'). */
:root {
    --bg: #111214;
    --bg-soft: #17181b;
    --surface: #1e1f22;
    --surface-2: #2b2d31;
    --surface-3: #35373c;
    --border: #3a3c42;
    --text: #e3e5e8;
    --muted: #a3a6aa;
    --faint: #6d6f78;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --success: #23a55a;
    --warning: #f0b232;
    --danger: #da373c;
    --danger-hover: #a12d2f;
    --steam: #1b2838;
    --steam-hover: #2a475e;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --font: "gg sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
}
a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- header / footer ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(17, 18, 20, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--surface-2);
}
.site-header .inner, .container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}
.site-header .inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 60px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: var(--muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface-2); text-decoration: none; }
.header-right { display: flex; align-items: center; gap: 12px; }
.lang-switch { display: flex; gap: 2px; }
.lang-switch a {
    color: var(--faint);
    font-size: .8rem;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.lang-switch a.active, .lang-switch a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.user-chip form { margin: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); flex: none; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; }
.avatar.sm { width: 22px; height: 22px; }
main { flex: 1; padding: 36px 0 56px; }
.site-footer { border-top: 1px solid var(--surface-2); padding: 18px 0; color: var(--faint); font-size: .85rem; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.btn:hover { background: #404249; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary, .btn.discord { background: var(--accent); color: #fff; }
.btn.primary:hover, .btn.discord:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); }
.btn.success { background: var(--success); color: #fff; }
.btn.steam { background: var(--steam); color: #fff; border: 1px solid #2a475e; }
.btn.steam:hover { background: var(--steam-hover); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.lg { padding: 12px 22px; font-size: 1rem; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

/* ---------- cards, alerts, badges ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
    padding: 22px;
}
.card + .card { margin-top: 16px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.narrow { max-width: 620px; margin: 0 auto; }
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    border-left: 4px solid var(--accent);
    background: var(--surface-2);
}
.alert.ok { border-color: var(--success); }
.alert.error { border-color: var(--danger); }
.alert.warn { border-color: var(--warning); }
.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    background: var(--surface-3);
    color: var(--muted);
    white-space: nowrap;
}
.badge.open { background: rgba(35, 165, 90, .18); color: #4ade80; }
.badge.claimed { background: rgba(88, 101, 242, .2); color: #a5b4fc; }
.badge.closed { background: var(--surface-3); color: var(--muted); }
.badge.warn { background: rgba(240, 178, 50, .18); color: var(--warning); }
.badge.danger { background: rgba(218, 55, 60, .2); color: #f87171; }

/* ---------- landing ---------- */
.hero { text-align: center; padding: 30px 0 40px; }
.hero h1 { font-size: 2.4rem; }
.hero .lead { color: var(--muted); font-size: 1.15rem; max-width: 640px; margin: 0 auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.tile { display: block; color: var(--text); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.tile .icon { font-size: 1.8rem; margin-bottom: 8px; }
.tile p { color: var(--muted); margin: 0; }

/* ---------- linking ---------- */
.steps { display: grid; gap: 14px; }
.step { display: flex; gap: 16px; align-items: center; }
.step .num {
    width: 32px; height: 32px; flex: none;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface-3); font-weight: 700;
}
.step.done .num { background: var(--success); }
.step .body { flex: 1; min-width: 0; }
.step .title { font-weight: 700; }
.linked-pair { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 18px; flex-wrap: wrap; }
.linked-pair .side { text-align: center; }
.linked-pair .chain { font-size: 1.6rem; color: var(--success); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- panel layout ---------- */
.panel-layout { display: grid; grid-template-columns: 230px 1fr; gap: 26px; align-items: start; }
.panel-layout > *, .ticket-grid > *, .grid-2 > * { min-width: 0; }
.sidebar { position: sticky; top: 80px; }
.guild-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--text); }
.guild-head:hover { text-decoration: none; }
.guild-head .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-icon {
    width: 40px; height: 40px; border-radius: 12px; flex: none;
    background: var(--surface-3); display: grid; place-items: center; font-weight: 700; overflow: hidden;
}
.guild-icon img { width: 100%; height: 100%; object-fit: cover; }
/* A server in a table row ("my tickets"): a small icon and the name. */
.guild-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.guild-cell .guild-icon { width: 24px; height: 24px; border-radius: 7px; font-size: .75rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
    color: var(--muted);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--surface-3); color: var(--text); }
.side-nav .sep { height: 1px; background: var(--surface-2); margin: 8px 4px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
.guild-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.guild-card { display: flex; align-items: center; gap: 12px; color: var(--text); }
.guild-card:hover { border-color: var(--accent); text-decoration: none; }
.guild-card.disabled { opacity: .7; }
.guild-card.disabled:hover { opacity: 1; }
.section-title { margin-top: 32px; }

/* ---------- stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; }
.stat .hint { color: var(--faint); font-size: .8rem; }
.chart-box { position: relative; height: 280px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card + .card { margin-top: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
.table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.table tbody tr:hover { background: var(--bg-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table a.row-link { color: var(--text); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .label { font-weight: 600; font-size: .9rem; }
.field .help { color: var(--faint); font-size: .8rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
textarea.tall { min-height: 340px; font-family: var(--mono); font-size: .88rem; line-height: 1.45; }
select[multiple] { min-height: 120px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; flex: 1; }
.filters .field.grow { flex: 3; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); font-size: .85rem; }
.role-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; }
details.collapse { border: 1px solid var(--surface-2); border-radius: var(--radius); background: var(--surface); }
details.collapse + details.collapse { margin-top: 10px; }
details.collapse > summary { cursor: pointer; padding: 14px 18px; list-style: none; display: flex; align-items: center; gap: 10px; font-weight: 600; }
details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse > summary::before { content: "▸"; color: var(--faint); transition: transform .15s; }
details.collapse[open] > summary::before { transform: rotate(90deg); }
details.collapse > .content { padding: 0 18px 18px; }
.secret { padding: 12px; background: var(--bg); border: 1px dashed var(--warning); border-radius: var(--radius-sm); font-family: var(--mono); overflow-wrap: anywhere; user-select: all; }

/* ---------- ticket view ---------- */
.ticket-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--faint); font-size: .8rem; white-space: nowrap; min-width: 120px; }
.answers dt { font-weight: 700; margin-top: 10px; }
.answers dd { margin: 4px 0 0; white-space: pre-wrap; color: var(--muted); }
.transcript-frame { width: 100%; height: 75vh; border: 1px solid var(--surface-2); border-radius: var(--radius); background: #313338; }
.stars { color: var(--warning); letter-spacing: 1px; }

/* ---------- AI assistant ---------- */
.ai-test { margin-bottom: 18px; }
.ai-answer { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin: 6px 0 10px; }

@media (max-width: 900px) {
    .panel-layout, .ticket-grid, .grid-2 { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .sidebar > p { display: none; }
    /* The section menu becomes a horizontal strip instead of a screen-tall list. */
    .side-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
    .side-nav a { white-space: nowrap; }
    .side-nav .sep { display: none; }
    .nav { display: none; }
    .card { padding: 16px; }
}
@media (max-width: 560px) {
    .site-header .inner { gap: 10px; padding: 0 16px; }
    .container { padding: 0 16px; }
    .header-right { margin-left: auto; }
    .brand span { display: none; }
    .hero h1 { font-size: 1.8rem; }
    .user-chip .name { display: none; }
}
