/* Castivy: the site and the dashboard. One set of tokens, light and dark. */

:root {
  --bg: #f5f5f1;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --ink: #15171a;
  --ink-2: #474c53;
  --muted: #7d828a;
  --line: #e6e5df;
  --line-strong: #d3d2ca;
  --accent: #1d9a60;
  --accent-hover: #178553;
  --accent-ink: #0d5435;
  --accent-soft: #e3f3ea;
  --on-accent: #ffffff;
  --danger: #c23b33;
  --danger-soft: #fbe9e7;
  --warn: #a8660b;
  --warn-soft: #fbf0dc;
  --twitch: #9146ff;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(20 22 26 / 5%), 0 4px 16px rgb(20 22 26 / 4%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1011;
    --surface: #16191b;
    --surface-2: #1b1e21;
    --ink: #eceeec;
    --ink-2: #b9bdbb;
    --muted: #868b8f;
    --line: #25292c;
    --line-strong: #353a3e;
    --accent: #34c47f;
    --accent-hover: #4bd292;
    --accent-ink: #9fe6c3;
    --accent-soft: #12281d;
    --on-accent: #06140d;
    --danger: #ef6b62;
    --danger-soft: #2c1513;
    --warn: #e2a443;
    --warn-soft: #2a1f0e;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden, [hidden] { display: none !important; }
.stack.tight { --gap: 10px; }
.stack.tighter { --gap: 6px; }
.center { text-align: center; }
.row.centered { justify-content: center; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.legend { margin-bottom: 6px; padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* --- Brand ------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; text-decoration: none; }
.brand svg { width: 24px; height: 24px; color: var(--accent); }

/* --- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.large { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.twitch { background: var(--twitch); border-color: var(--twitch); color: #fff; }
.btn.twitch:hover { background: #7f30f5; }

/* --- Forms ------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--danger); }
input[type=text], input[type=email], input[type=number], input[type=search], textarea, select {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prefix-input { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); overflow: hidden; }
.prefix-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prefix-input span { display: flex; align-items: center; padding: 0 2px 0 12px; color: var(--muted); white-space: nowrap; }
.prefix-input input { border: 0; box-shadow: none !important; padding-left: 2px; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / 20%); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Surfaces ---------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head.inset { padding: 22px 22px 0; }
.mt { margin-top: 12px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.card-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 14px; background: var(--accent-soft); color: var(--accent-ink); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.badge.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.empty { padding: 36px 22px; text-align: center; color: var(--muted); font-size: 14px; }

.copy { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.copy code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; }
.copy code.secret { filter: blur(5px); user-select: none; transition: filter .15s; }
.copy code.secret.shown { filter: none; user-select: text; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.stat .value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12px; font-weight: 500; color: var(--muted); }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex: none; }
.avatar.large { width: 72px; height: 72px; }
.avatar.fallback { display: grid; place-items: center; color: var(--accent-ink); font-weight: 700; }

/* --- Public pages ------------------------------------------------------ */
.site-header { display: flex; align-items: center; justify-content: space-between; max-width: 1080px; margin: 0 auto; padding: 22px 24px; }
.site-footer { max-width: 1080px; margin: 0 auto; padding: 40px 24px 48px; display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

.hero { max-width: 1080px; margin: 0 auto; padding: 72px 24px 56px; display: grid; gap: 48px; grid-template-columns: 1.1fr 1fr; align-items: center; }
.hero h1 { font-size: clamp(36px, 5vw, 56px); letter-spacing: -0.035em; line-height: 1.05; font-weight: 700; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { margin-top: 18px; font-size: 18px; color: var(--ink-2); max-width: 30em; }
.hero .actions { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero-visual { position: relative; aspect-ratio: 4 / 3; border-radius: 22px; background: radial-gradient(120% 90% at 20% 10%, #1f2a24, #0c0f0e 65%); overflow: hidden; box-shadow: 0 30px 60px -20px rgb(13 40 27 / 35%); }
.hero-visual .scene { position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 22px, rgb(255 255 255 / 2%) 22px 23px); }
.hero-visual .demo-alert { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: 78%; }
.features { max-width: 1080px; margin: 0 auto; padding: 24px 24px 40px; display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.feature h3 { margin: 12px 0 6px; font-size: 16px; }
.feature p { color: var(--ink-2); font-size: 14px; }
.feature .icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.feature .icon svg { width: 20px; height: 20px; }

.narrow { max-width: 460px; margin: 0 auto; padding: 32px 20px 64px; }
.prose { max-width: 720px; margin: 0 auto; padding: 24px 24px 64px; }
.prose h1 { margin-bottom: 18px; }
.prose .notice { margin-bottom: 20px; }
.prose h2 { margin: 28px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose p + p { margin-top: 10px; }

/* Donation page */
.donate { max-width: 480px; margin: 0 auto; padding: 28px 20px 56px; }
.donate-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 22px; }
.donate-head h1 { font-size: 24px; }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.amounts label { position: relative; }
.amounts input { position: absolute; opacity: 0; }
.amounts span { display: grid; place-items: center; height: 46px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums; transition: border-color .15s, background .15s; }
.amounts input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 1px var(--accent) inset; }
.amounts input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.tips { display: flex; gap: 6px; flex-wrap: wrap; }
.tips label { position: relative; }
.tips input { position: absolute; opacity: 0; }
.tips span { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); font-size: 13px; font-weight: 600; cursor: pointer; }
.tips input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.tips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.summary-line { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); }
.summary-line.total { font-size: 16px; font-weight: 650; color: var(--ink); padding-top: 8px; border-top: 1px solid var(--line); }
.counter { text-align: right; font-size: 12px; color: var(--muted); }

/* --- Dashboard --------------------------------------------------------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.app > * { min-width: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar .brand { padding: 0 10px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: 14px; }
.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent-ink); }
.nav a[aria-current=page] svg { opacity: 1; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); }
.sidebar .me .who { min-width: 0; }
.sidebar .me .who .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .me .name { font-weight: 600; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 32px clamp(20px, 4vw, 48px) 64px; max-width: 980px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.checklist li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist .tick { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed var(--line-strong); color: transparent; flex: none; }
.checklist .done .tick { border: 0; background: var(--accent); color: var(--on-accent); }
.checklist .tick svg { width: 15px; height: 15px; }
.checklist .text { flex: 1; min-width: 0; }
.checklist .text strong { display: block; font-weight: 600; font-size: 14px; }
.checklist .text span { font-size: 13px; color: var(--muted); }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.theme { position: relative; cursor: pointer; }
.theme input { position: absolute; opacity: 0; }
.theme .frame { display: block; border-radius: 12px; border: 1px solid var(--line-strong); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.theme input:checked + .frame { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme input:focus-visible + .frame { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme .preview { height: 108px; display: grid; place-items: center; background: repeating-conic-gradient(#20242a 0 25%, #1a1d22 0 50%) 0 0 / 16px 16px; padding: 12px; }
.theme .name { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; font-size: 13px; font-weight: 600; background: var(--surface); }

/* Miniature alerts in the theme picker and on the landing page */
.mini.wide { max-width: none; }
.mini { width: 100%; max-width: 220px; font-family: var(--font); text-align: center; }
.mini b { display: block; font-size: 13px; }
.mini i { display: block; font-style: normal; font-size: 11px; opacity: .8; margin-top: 2px; }
.mini-clean { background: #fff; color: #15171a; border-radius: 10px; padding: 10px 12px; border-bottom: 3px solid #1d9a60; box-shadow: 0 6px 18px rgb(0 0 0 / 35%); }
.mini-clean b span { color: #1d9a60; }
.mini-neon { background: rgb(10 12 20 / 85%); color: #fff; border-radius: 12px; padding: 10px 12px; border: 1px solid #5ef0ff; box-shadow: 0 0 14px #5ef0ff99, inset 0 0 12px #5ef0ff33; }
.mini-neon b span { color: #5ef0ff; text-shadow: 0 0 8px #5ef0ff; }
.mini-pop { background: #ffd23f; color: #15171a; border-radius: 14px; padding: 10px 12px; border: 3px solid #15171a; box-shadow: 4px 4px 0 #15171a; transform: rotate(-2deg); }
.mini-pop b { font-weight: 800; }
.mini-pop b span { color: #e5384b; }

.alert-rows .list > li { flex-wrap: wrap; }
.alert-rows .type { flex: 1; min-width: 160px; }
.alert-rows .type strong { display: block; font-size: 14px; }
select.compact { width: auto; min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.alert-rows select { width: auto; min-width: 150px; min-height: 34px; padding: 5px 10px; font-size: 13px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.media-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.media-item .thumb { height: 90px; display: grid; place-items: center; background: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 14px 14px; }
.media-item .thumb img { max-height: 90px; object-fit: contain; }
.media-item .thumb svg { width: 28px; height: 28px; color: var(--muted); }
.media-item .meta { padding: 8px 10px; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.media-item .meta span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone { display: grid; justify-items: center; gap: 6px; }
.dropzone svg { width: 24px; height: 24px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.connection { display: flex; align-items: center; gap: 16px; }
.connection .logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.connection .logo svg { width: 22px; height: 22px; }
.connection .logo.twitch { background: #9146ff1f; color: var(--twitch); }
.connection .logo.google { background: var(--surface-2); border: 1px solid var(--line); }
.connection .logo.stripe { background: #635bff1f; color: #635bff; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 22px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 22px; border-top: 1px solid var(--line); vertical-align: top; }
.table tr:first-child td { border-top: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 550; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; }
  .features { grid-template-columns: 1fr; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-auto-flow: column; overflow-x: auto; width: 100%; order: 3; }
  .nav a span { white-space: nowrap; }
  .sidebar .me { margin: 0 0 0 auto; border: 0; padding: 0; }
  .sidebar .me .who { display: none; }
  .grid-2, .themes { grid-template-columns: 1fr; }
  .main { padding-top: 22px; }
}
@media (max-width: 420px) {
  .amounts { grid-template-columns: repeat(2, 1fr); }
}
