:root {
  --accent: #7c6bff;
  /* Logo gradient: purple -> blue -> cyan */
  --g1: #a63cff;
  --g2: #4f7dff;
  --g3: #0bd3f2;
  --grad: linear-gradient(120deg, var(--g1) 0%, var(--g2) 55%, var(--g3) 100%);
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --bg: #07080c;
  --panel: #0e1017;
  --panel-2: #141722;
  --panel-3: #1b1f2c;
  --line: #232838;
  --line-2: #2e3447;
  --text: #e8ebf3;
  --muted: #8b93a7;
  --dim: #5d6477;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --note: #eab308;
  --radius: 14px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(700px 380px at 30% -140px, color-mix(in srgb, var(--g1) 16%, transparent), transparent 70%),
    radial-gradient(700px 380px at 72% -140px, color-mix(in srgb, var(--g3) 12%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--panel); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 10px clamp(14px, 4vw, 48px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img, .brand .mark { width: 34px; height: 34px; border-radius: 9px; }
.brand img { border-radius: 0; object-fit: contain; width: 38px; height: 38px; }
.brand .mark { display: grid; place-items: center; background: var(--grad); box-shadow: 0 0 22px var(--accent-soft); }
.brand strong { display: block; font-size: 17px; letter-spacing: -0.02em; line-height: 1.1; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; }
.pills { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.pills a { padding: 6px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.pills a:hover { color: var(--text); text-decoration: none; }
.pills a.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-line); }
.top-right { justify-self: end; display: flex; align-items: center; gap: 8px; }
.announce { margin: 14px auto 0; max-width: 760px; padding: 10px 14px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 10px; font-size: 13.5px; }

/* ---------- buttons + inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--panel-3); border-color: #3a4157; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 24px -8px var(--g2); text-shadow: 0 1px 2px #0004; }
.btn.primary:hover { background: var(--grad); filter: brightness(1.12); }
.btn.danger { color: #fca5a5; border-color: #4b1d1d; background: #1d0f12; }
.btn.danger:hover { background: #2a1216; }
.btn.good { color: #86efac; border-color: #14532d; background: #0c1a12; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.discord { background: #5865f2; border-color: transparent; color: #fff; }
.btn.discord:hover { background: #4752c4; }
.btn svg { flex: none; }

label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
label.field > small, .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.req { color: var(--accent); }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #0a0c12; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 110px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--line-2); background: #0a0c12; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.check b { display: block; font-weight: 600; font-size: 13px; }
.check small { color: var(--muted); font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2);
  cursor: pointer; font-weight: 500; font-size: 13px; color: var(--muted); transition: all .15s;
}
.chip:hover { color: var(--text); border-color: #3a4157; }
.chip[aria-checked=true] { color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
.chip .tag { font-size: 10.5px; margin-left: 6px; padding: 1px 6px; border-radius: 99px; background: var(--panel-3); color: var(--muted); }
.chip-group-label { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 4px 0 -2px; }

/* ---------- layout ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 28px clamp(14px, 4vw, 40px) 60px; }
.page.narrow { max-width: 680px; }
.card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 24px; }
.card-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
h1 { font-size: 30px; letter-spacing: -0.03em; margin: 0 0 18px; line-height: 1.15; }
h2 { font-size: 18px; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line-2); font-size: 13.5px; margin-bottom: 14px; }
.notice.error { background: #1d0f12; border-color: #4b1d1d; color: #fecaca; }
.notice.info { background: var(--accent-soft); border-color: var(--accent-line); }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; border: 1px solid var(--line-2); color: var(--muted); background: var(--panel); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.open { color: #a5b4fc; }
.badge.open::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.badge.closed { color: var(--dim); }
.badge.ai { color: #67e8f9; }
.badge.accepted { color: #86efac; }
.badge.denied { color: #fca5a5; }
.badge.nodot::before { display: none; }

/* ---------- ticket list ---------- */
.tlist { display: grid; gap: 10px; }
.titem { display: block; padding: 16px 18px; color: var(--text); transition: border-color .15s, transform .15s; }
.titem:hover { border-color: var(--line-2); text-decoration: none; transform: translateY(-1px); }
.titem .spread b { font-size: 15px; }
.titem p { margin: 6px 0 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ticket view / chat ---------- */
.back { color: var(--muted); font-size: 13px; display: inline-flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.thead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.thead h1 { margin-bottom: 6px; }
.ident { display: grid; grid-template-columns: auto auto; gap: 2px 12px; font-size: 12px; color: var(--muted); align-items: center; }
.ident b { color: var(--text); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.ident img { width: 18px; height: 18px; border-radius: 50%; }
.copy { background: none; border: 0; padding: 2px; color: var(--dim); cursor: pointer; display: inline-grid; }
.copy:hover { color: var(--text); }

.chat { display: flex; flex-direction: column; height: min(72vh, 760px); min-height: 420px; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.chat-head b { font-size: 15px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--good); font-size: 12.5px; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); animation: pulse 2s infinite; }
.live.off { color: var(--dim); }
.live.off::before { background: var(--dim); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: .35; } }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: min(78%, 620px); display: flex; flex-direction: column; gap: 5px; }
.msg .meta { font-size: 12px; color: var(--dim); display: flex; gap: 8px; align-items: center; }
.msg .meta b { font-weight: 600; color: var(--accent); }
.msg .bubble { padding: 11px 15px; border-radius: 14px; background: var(--panel-3); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.mine .meta b { color: var(--text); }
.msg.mine .bubble { background: linear-gradient(120deg, color-mix(in srgb, var(--g1) 30%, var(--panel-2)), color-mix(in srgb, var(--g3) 22%, var(--panel-2))); border-color: var(--accent-line); }
.msg.ai .meta b { color: #67e8f9; }
.msg.note { max-width: 100%; align-self: stretch; }
.msg.note .bubble { background: #1c1806; border-color: #4a3d0a; color: #fde68a; }
.msg.note .meta b { color: var(--note); }
.msg.sys { align-self: center; max-width: 90%; }
.msg.sys .bubble { background: transparent; border: 0; padding: 2px 8px; color: var(--muted); font-size: 12.5px; text-align: center; }
.msg .att { display: block; margin-top: 4px; }
.msg .att img { max-width: 280px; max-height: 220px; border-radius: 10px; border: 1px solid var(--line-2); display: block; }
.msg .file { display: inline-flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); color: var(--text); }
.typing { display: inline-flex; gap: 4px; padding: 12px 15px; border-radius: 14px; background: var(--panel-3); border: 1px solid var(--line); width: fit-content; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.intake-card { align-self: stretch; padding: 12px 16px; border: 1px dashed var(--line-2); border-radius: 12px; background: var(--panel); font-size: 13px; }
.intake-card dl { margin: 6px 0 0; display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 4px 14px; }
.intake-card dt { color: var(--muted); }
.intake-card dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { min-height: 44px; max-height: 180px; resize: none; padding: 11px 14px; border-radius: 12px; }
.composer .btn { height: 44px; }
.icon-btn { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.closed-bar { padding: 16px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }
.file-pill { display: flex; gap: 8px; align-items: center; padding: 6px 12px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }

/* ---------- toast + dialog ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: 0 10px 30px #0008; animation: rise .2s; }
.toast.error { border-color: #7f1d1d; color: #fecaca; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 0; width: min(560px, 94vw); max-height: 88vh; }
dialog.wide { width: min(820px, 96vw); }
dialog::backdrop { background: #000a; backdrop-filter: blur(3px); }
dialog .card-pad { overflow-y: auto; max-height: calc(88vh - 70px); }

/* ---------- main page ---------- */
.home { display: grid; gap: 18px; }
.hero { text-align: center; padding: 48px 0 26px; }
.hero-mark { display: inline-block; margin-bottom: 18px; }
.hero-mark .mark, .hero-mark img { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; }
.hero-mark img { width: 120px; height: 120px; border-radius: 0; object-fit: contain; filter: drop-shadow(0 10px 40px color-mix(in srgb, var(--g2) 40%, transparent)); }
.hero-mark .mark { background: var(--grad); box-shadow: 0 0 40px var(--accent-soft); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-mark .mark svg { width: 32px; height: 32px; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); margin-bottom: 10px; }
.lead { font-size: 16.5px; max-width: 520px; margin: 0 auto 24px; }
.hero-actions { justify-content: center; }
.btn.lg { padding: 11px 20px; font-size: 15px; border-radius: 12px; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.home-grid h2 { margin-bottom: 4px; }
.home-grid > .card > p { margin: 0 0 14px; font-size: 13.5px; }
.link-list { display: grid; gap: 8px; }
.link-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); transition: border-color .15s, background .15s; }
.link-row:hover { text-decoration: none; border-color: var(--accent-line); background: var(--accent-soft); }
.link-row b { display: block; font-size: 14px; }
.link-row small { display: block; color: var(--muted); font-size: 12.5px; }
.link-row .arrow { color: var(--dim); }
.link-row:hover .arrow { color: var(--accent); }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.guide-card { display: grid; gap: 6px; align-content: start; padding: 16px; color: var(--text); transition: border-color .15s, transform .15s; }
.guide-card:hover { text-decoration: none; border-color: var(--accent-line); transform: translateY(-1px); }
.guide-card .tagc { justify-self: start; }
.guide-card p { margin: 0; color: var(--muted); font-size: 13px; }
.tagc { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--panel-3); color: var(--muted); border: 1px solid var(--line); }
@media (max-width: 720px) { .home-grid { grid-template-columns: 1fr; } .hero { padding-top: 24px; } }

/* ---------- guide article ---------- */
.guide { font-size: 15px; line-height: 1.7; }
.guide > :first-child { margin-top: 0; }
.guide h2 { font-size: 20px; margin: 28px 0 8px; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; }
.guide h4 { font-size: 14px; margin: 18px 0 6px; }
.guide p, .guide ul, .guide ol { margin: 0 0 14px; }
.guide li { margin-bottom: 4px; }
.guide code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; padding: 2px 6px; border-radius: 6px; background: var(--panel-3); border: 1px solid var(--line); }
.guide pre { padding: 14px; border-radius: 10px; background: #0a0c12; border: 1px solid var(--line); overflow-x: auto; }
.guide pre code { padding: 0; border: 0; background: none; }
.guide blockquote { margin: 0 0 14px; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.guide img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.guide hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

.footer { text-align: center; color: var(--dim); font-size: 12px; padding: 24px; }
.footer a { color: var(--muted); }

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar .pills { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .brand small { display: none; }
  .msg { max-width: 92%; }
  h1 { font-size: 24px; }
  .intake-card dl { grid-template-columns: 1fr; gap: 2px; }
  .intake-card dd { margin-bottom: 8px; }
  .thead > .row { width: 100%; justify-content: space-between; }
}
