/* Toybox LiveBot — chunky toy-block UI */
:root {
  --bg: #fff7ea;
  --bg-2: #ffefd6;
  --card: #ffffff;
  --ink: #2a1f3d;
  --ink-soft: #5c5072;
  --line: #2a1f3d;
  --muted-line: #e8dcc8;
  --red: #ff5d5d;
  --yellow: #ffc83d;
  --teal: #22b8a7;
  --grape: #7b5cff;
  --pink: #ff8fc7;
  --ok: #18a058;
  --warn: #c77c00;
  --bad: #d43d3d;
  --shadow: 4px 4px 0 var(--line);
  --shadow-sm: 2px 2px 0 var(--line);
  --radius: 14px;
  --font-display: "Fredoka", ui-rounded, "Segoe UI", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --discord-bg: #313338;
  --discord-embed: #2b2d31;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17131f; --bg-2: #1f1a2b; --card: #251f35; --ink: #f3edff; --ink-soft: #b9aed0;
    --line: #0b0810; --muted-line: #3a3150; --shadow: 4px 4px 0 #0b0810; --shadow-sm: 2px 2px 0 #0b0810;
    --ok: #3ccf82; --warn: #ffb547; --bad: #ff7272;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17131f; --bg-2: #1f1a2b; --card: #251f35; --ink: #f3edff; --ink-soft: #b9aed0;
  --line: #0b0810; --muted-line: #3a3150; --shadow: 4px 4px 0 #0b0810; --shadow-sm: 2px 2px 0 #0b0810;
  --ok: #3ccf82; --warn: #ffb547; --bad: #ff7272;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(var(--muted-line) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 16px/1.55 var(--font-body);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: var(--grape); font-weight: 700; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, kbd { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; background: var(--bg-2); border: 1.5px solid var(--muted-line); padding: .08em .4em; border-radius: 6px; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--ink-soft); }
.small { font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- nav ---------- */
.nav { padding: 18px 0; }
.nav .wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.logo-mark { width: 38px; height: 38px; }
.nav-links { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--ink); text-decoration: none; padding: 6px 12px; border-radius: 10px; font-weight: 700; }
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--bg-2); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); }
.user-chip form { margin: 0; }

/* ---------- buttons & form controls ---------- */
.btn {
  --b: var(--yellow);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem var(--font-display); letter-spacing: .01em;
  color: #2a1f3d; background: var(--b);
  border: 2.5px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
  padding: 9px 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.big { padding: 13px 22px; font-size: 1.12rem; box-shadow: var(--shadow); }
.btn.discord { --b: #5865f2; color: #fff; }
.btn.grape { --b: var(--grape); color: #fff; }
.btn.teal { --b: var(--teal); color: #fff; }
.btn.red { --b: var(--red); color: #fff; }
.btn.ghost { --b: var(--card); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: .9rem; border-width: 2px; border-radius: 10px; }
.btn svg { width: 1.1em; height: 1.1em; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-soft); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

label { font-weight: 800; font-size: .9rem; display: block; margin-bottom: 6px; }
.hint { font-size: .85rem; color: var(--ink-soft); margin-top: 6px; }
input[type=text], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
textarea { min-height: 84px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .92rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible, .switch input:focus-visible + span {
  outline: 3px solid var(--grape); outline-offset: 2px;
}
input[type=color] { width: 52px; height: 42px; border: 2px solid var(--line); border-radius: 10px; padding: 2px; background: var(--card); cursor: pointer; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; margin: 0; }
.switch input { position: absolute; opacity: 0; }
.switch span.track { width: 46px; height: 26px; border: 2px solid var(--line); border-radius: 999px; background: var(--bg-2); position: relative; flex: none; transition: background .15s; }
.switch span.track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); transition: transform .15s; }
.switch input:checked + span.track { background: var(--teal); }
.switch input:checked + span.track::after { transform: translateX(20px); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 22px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.step-num { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; border: 2px solid var(--line); font-size: 1rem; color: #2a1f3d; }

.notice { border: 2.5px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; display: flex; gap: 12px; align-items: flex-start; background: var(--card); box-shadow: var(--shadow-sm); }
.notice strong { font-family: var(--font-display); font-weight: 600; }
.notice.warn { background: color-mix(in srgb, var(--yellow) 28%, var(--card)); }
.notice.bad { background: color-mix(in srgb, var(--red) 22%, var(--card)); }
.notice.ok { background: color-mix(in srgb, var(--teal) 22%, var(--card)); }
.notice .grow { flex: 1; }
.notice p { margin: 0; }

/* ---------- home ---------- */
.hero { padding: 40px 0 56px; display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; }
.hero h1 .hl { background: linear-gradient(transparent 58%, var(--yellow) 58%); padding: 0 .1em; }
.hero p.lead { font-size: 1.2rem; color: var(--ink-soft); max-width: 34ch; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.blocks { display: flex; gap: 8px; margin-bottom: 18px; }
.blocks span { width: 18px; height: 18px; border: 2px solid var(--line); border-radius: 4px; }
.stats { display: flex; gap: 28px; margin-top: 30px; flex-wrap: wrap; }
.stats div { font-family: var(--font-display); }
.stats b { display: block; font-size: 1.8rem; font-weight: 600; }
.stats span { color: var(--ink-soft); font-size: .9rem; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 10px 0 60px; }
.feature { background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.feature .ico { width: 44px; height: 44px; border: 2.5px solid var(--line); border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; color: #2a1f3d; }
.feature .ico svg { width: 24px; height: 24px; }
.feature p { color: var(--ink-soft); margin: 0; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; counter-reset: s; margin-bottom: 70px; }
.steps li { list-style: none; position: relative; padding: 20px 20px 20px 72px; background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 18px; top: 18px; width: 40px; height: 40px; display: grid; place-items: center; font: 600 1.3rem var(--font-display); border: 2.5px solid var(--line); border-radius: 10px; background: var(--yellow); color: #2a1f3d; }
.steps li:nth-child(2)::before { background: var(--teal); }
.steps li:nth-child(3)::before { background: var(--pink); }
.steps { padding: 0; }
.section-title { text-align: center; margin: 0 0 26px; }

/* Discord message preview */
.dc { background: var(--discord-bg); color: #dbdee1; border-radius: 12px; padding: 16px 18px; font: 15px/1.4 "gg sans", "Noto Sans", "Segoe UI", system-ui, sans-serif; border: 2.5px solid var(--line); box-shadow: var(--shadow); }
.dc-row { display: flex; gap: 14px; }
.dc-av { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--yellow); display: grid; place-items: center; overflow: hidden; }
.dc-av svg { width: 30px; height: 30px; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-bot { background: #5865f2; color: #fff; font-size: .62rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: 2px; }
.dc-time { color: #949ba4; font-size: .75rem; margin-left: 6px; }
.dc-content { margin: 2px 0 6px; word-break: break-word; }
.dc-mention { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.dc-embed { background: var(--discord-embed); border-left: 4px solid #9146ff; border-radius: 4px; padding: 10px 14px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; max-width: min(440px, 100%); min-width: 0; }
.dc-row > div:not(.dc-av) { min-width: 0; flex: 1; }
.dc-embed .etitle, .dc-embed .author { overflow-wrap: anywhere; }
.dc-embed .author { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; color: #f2f3f5; grid-column: 1; }
.dc-embed .author .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--pink); flex: none; }
.dc-embed .author img { width: 22px; height: 22px; border-radius: 50%; }
.dc-embed .etitle { color: #00a8fc; font-weight: 600; grid-column: 1; }
.dc-embed .fields { display: flex; gap: 26px; font-size: .85rem; grid-column: 1; }
.dc-embed .fields b { display: block; color: #f2f3f5; font-weight: 600; }
.dc-embed .thumb { grid-column: 2; grid-row: 1 / span 3; width: 64px; height: 64px; border-radius: 6px; background: linear-gradient(135deg, var(--pink), var(--grape)); }
.dc-embed .thumb img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; }
.dc-embed .image { grid-column: 1 / -1; aspect-ratio: 16/9; border-radius: 6px; background: linear-gradient(135deg, #3a2d63, #7b5cff 55%, #ff8fc7); display: grid; place-items: center; color: rgba(255,255,255,.85); font-weight: 700; letter-spacing: .08em; font-size: .8rem; }
.dc-embed .foot { grid-column: 1 / -1; font-size: .72rem; color: #949ba4; }
.preview-label { font: 600 .8rem var(--font-display); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); margin: 0 0 8px; }

/* ---------- dashboard server grid ---------- */
.page-head { padding: 18px 0 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0; }
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; margin-bottom: 36px; }
.server { background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.server .name { font: 600 1.05rem var(--font-display); overflow-wrap: anywhere; }
.gicon { width: 64px; height: 64px; border-radius: 18px; border: 2.5px solid var(--line); background: var(--grape); color: #fff; display: grid; place-items: center; font: 600 1.3rem var(--font-display); overflow: hidden; flex: none; }
.gicon img { width: 100%; height: 100%; object-fit: cover; }
.gicon.sm { width: 44px; height: 44px; border-radius: 12px; font-size: 1rem; }
.server .btn { margin-top: auto; width: 100%; }
.tag { display: inline-block; font: 700 .72rem var(--font-body); text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--line); background: var(--bg-2); }
.tag.on { background: var(--teal); color: #fff; }
.empty { text-align: center; padding: 36px 20px; border: 2.5px dashed var(--muted-line); border-radius: var(--radius); color: var(--ink-soft); }

/* ---------- guild setup ---------- */
.guild-head { display: flex; gap: 16px; align-items: center; padding: 14px 0 24px; flex-wrap: wrap; }
.guild-head h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.3rem); overflow-wrap: anywhere; }
.guild-head .crumb { font-weight: 700; color: var(--ink-soft); text-decoration: none; font-size: .95rem; }
.guild-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 26px; align-items: start; margin-bottom: 60px; }
.sticky { position: sticky; top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.add-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; padding: 14px; border: 2px dashed var(--muted-line); border-radius: 12px; margin-bottom: 16px; background: var(--bg); }
.add-form label { font-size: .78rem; }
.add-form .btn { grid-column: 1 / -1; justify-self: end; min-width: 140px; }

.streamers { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.streamer { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--card); }
.streamer .av { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--pink); object-fit: cover; }
.streamer .who b { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.streamer .who a { font-weight: 600; font-size: .85rem; color: var(--ink-soft); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill { font-size: .8rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--bg-2); border: 1.5px solid var(--muted-line); color: var(--ink-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.role { color: var(--ink); }
.streamer .edit { grid-column: 1 / -1; display: none; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; padding-top: 10px; border-top: 2px dashed var(--muted-line); }
.streamer.editing .edit { display: grid; }
.streamer .edit label { font-size: .78rem; }
.list-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.list-tools input { max-width: 260px; }

.activity { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: .9rem; }
.activity li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; border-bottom: 1.5px dashed var(--muted-line); padding-bottom: 6px; }
.activity time { color: var(--ink-soft); font-size: .8rem; white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { font: 700 .88rem var(--font-body); padding: 4px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(140%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 700; border: 2.5px solid var(--line); box-shadow: var(--shadow); transition: transform .2s, visibility .2s; z-index: 50; max-width: calc(100% - 32px); visibility: hidden; }
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast.bad { background: var(--bad); color: #fff; }

.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tokens button { font: 600 .8rem ui-monospace, Consolas, monospace; padding: 2px 8px; border-radius: 8px; border: 1.5px solid var(--muted-line); background: var(--bg-2); color: var(--ink); cursor: pointer; }
.tokens button:hover { border-color: var(--line); }
.saving-bar { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.dirty-dot { font-size: .85rem; color: var(--warn); font-weight: 700; display: none; }
.dirty .dirty-dot { display: inline; }

/* ---------- docs ---------- */
.docs { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 34px; padding: 10px 0 70px; align-items: start; }
.toc { position: sticky; top: 16px; background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.toc h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); margin: 0 0 8px; }
.toc ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.toc a { display: block; padding: 4px 8px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: .93rem; }
.toc a:hover { background: var(--bg-2); }
.prose { background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(18px, 4vw, 38px); }
.prose section { scroll-margin-top: 16px; }
.prose section + section { margin-top: 38px; padding-top: 30px; border-top: 2px dashed var(--muted-line); }
.prose h2 { display: flex; align-items: center; gap: 10px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-size: .93rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1.5px solid var(--muted-line); vertical-align: top; }
.prose th { font-family: var(--font-display); font-weight: 600; }
.prose td code { white-space: nowrap; }
details.faq { border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; background: var(--bg); }
details.faq summary { cursor: pointer; font-weight: 800; }
details.faq p { margin: 8px 0 0; }

/* ---------- admin table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1.5px solid var(--muted-line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* ---------- footer ---------- */
footer { border-top: 2.5px solid var(--line); background: var(--card); padding: 22px 0; margin-top: 30px; font-size: .9rem; }
footer .wrap { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
footer a { color: var(--ink-soft); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .guild-layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 30px; padding-top: 16px; }
  .features, .steps { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr; }
  .toc { position: static; }
}
@media (max-width: 600px) {
  .add-form .btn { justify-self: stretch; }
  .streamer .who a { overflow-wrap: anywhere; }
  .grid2 { grid-template-columns: 1fr; }
  .add-form { grid-template-columns: 1fr; }
  .streamer { grid-template-columns: 40px minmax(0, 1fr); }
  .streamer .actions { grid-column: 1 / -1; }
  .streamer .edit { grid-template-columns: 1fr; }
  .nav-links { margin-left: 0; width: 100%; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
