/* PlaySync — shared styles (landing, dashboard, docs).
   Neutral dark theme, one accent colour, system fonts, no external assets. */

:root {
  color-scheme: dark;

  /* palette: neutral greys + one blue accent */
  --bg: #0e1014;
  --bg-elev: #111419;
  --surface: #15181e;
  --surface-2: #1b1f27;
  --surface-3: #232833;
  --border: #262b35;
  --border-strong: #353c49;
  --text: #e6e8ec;
  --text-muted: #9aa3b2;
  --text-dim: #8a93a3;

  --accent: #2563eb;          /* primary buttons, active states */
  --accent-hover: #1d55d6;
  --accent-text: #6ea8ff;     /* links / accent text on dark surfaces */
  --accent-soft: rgba(59, 130, 246, .12);
  --accent-border: rgba(96, 155, 255, .45);
  --focus: #7cb0ff;

  --success: #3fb97a;
  --success-text: #6fd19c;
  --success-bg: rgba(63, 185, 122, .10);
  --warning: #d9a52b;
  --warning-text: #e8bd55;
  --warning-bg: rgba(217, 165, 43, .10);
  --danger: #e5534b;
  --danger-text: #f08a84;
  --danger-strong: #c93c35;
  --danger-bg: rgba(229, 83, 75, .10);
  --info: #6ea8ff;
  --info-bg: rgba(59, 130, 246, .08);

  /* type */
  --font: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: .75rem;      /* 12 */
  --fs-sm: .875rem;     /* 14 */
  --fs-base: 1rem;      /* 16 */
  --fs-lg: 1.125rem;    /* 18 */
  --fs-xl: 1.25rem;     /* 20 */
  --fs-2xl: 1.5rem;     /* 24 */
  --fs-3xl: clamp(1.625rem, 3vw, 2rem);      /* 26-32 */
  --fs-hero: clamp(2rem, 4.4vw, 3rem);       /* 32-48 */

  /* spacing (8px grid; s1/s3/s5 are half steps for tight UI) */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.25rem;
  --s6: 1.5rem; --s8: 2rem; --s10: 2.5rem; --s12: 3rem; --s16: 4rem; --s20: 5rem; --s24: 6rem;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-xl: 8px;
  --shadow: none;
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
  --maxw: 1200px;
  --header-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--s3); letter-spacing: -.01em; font-weight: 600; color: var(--text); }
p { margin: 0 0 var(--s4); }
code, kbd, pre { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s8) 0; }
::selection { background: rgba(59, 130, 246, .4); color: #fff; }

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

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--s4); top: -100px; z-index: 1000; background: var(--surface-3); color: var(--text); padding: var(--s2) var(--s4); border-radius: var(--radius); border: 1px solid var(--border-strong); }
.skip-link:focus { top: var(--s3); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s4); }
@media (min-width: 640px) { .container { padding: 0 var(--s6); } }
@media (min-width: 1024px) { .container { padding: 0 var(--s8); } }

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.hidden, [hidden] { display: none !important; }

/* ------------------------------------------------------------------ icons */
.icon { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-lg { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ logo */
.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 650; font-size: 1.0625rem; letter-spacing: -.01em; color: var(--text); white-space: nowrap; }
.logo:hover { color: var(--text); text-decoration: none; }
.logo-mark { width: 26px; height: 26px; }
.logo-sub { color: var(--text-muted); font-weight: 500; padding-left: .55rem; margin-left: .1rem; border-left: 1px solid var(--border-strong); }

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 38px; padding: .45rem .95rem;
  border-radius: var(--radius); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
  user-select: none;
}
.btn:hover { text-decoration: none; color: var(--btn-fg); background: var(--surface-3); border-color: #444c5b; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--btn-bg); border-color: var(--btn-border); }
.btn-primary { --btn-bg: var(--accent); --btn-fg: #fff; --btn-border: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-outline { --btn-bg: transparent; }
.btn-danger { --btn-bg: var(--danger-strong); --btn-fg: #fff; --btn-border: var(--danger-strong); }
.btn-danger:hover { background: #b0322c; border-color: #b0322c; color: #fff; }
.btn-danger-ghost { --btn-bg: transparent; --btn-fg: var(--danger-text); --btn-border: rgba(229, 83, 75, .4); }
.btn-danger-ghost:hover { background: var(--danger-bg); color: var(--danger-text); border-color: rgba(229, 83, 75, .65); }
.btn-sm { min-height: 30px; padding: .25rem .65rem; font-size: var(--fs-xs); border-radius: var(--radius-sm); gap: .35rem; }
.btn-lg { min-height: 44px; padding: .6rem 1.25rem; font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; }
.btn .spinner { width: 14px; height: 14px; }

.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: currentColor; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ labels (badges) */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .05rem .45rem; border-radius: var(--radius-sm); font-size: var(--fs-xs); font-weight: 600; border: 1px solid var(--border-strong); color: var(--text-muted); background: transparent; white-space: nowrap; line-height: 1.5; }
.badge-accent { color: var(--accent-text); border-color: var(--accent-border); background: var(--accent-soft); }
.badge-cyan { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.badge-success { color: var(--success-text); border-color: rgba(63,185,122,.4); background: var(--success-bg); }
.badge-warning { color: var(--warning-text); border-color: rgba(217,165,43,.4); background: var(--warning-bg); }
.badge-danger { color: var(--danger-text); border-color: rgba(229,83,75,.45); background: var(--danger-bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex-shrink: 0; }
.dot-live { color: var(--success); }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: .375rem; margin-bottom: var(--s4); }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.hint { font-size: var(--fs-xs); color: var(--text-dim); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: .5rem .75rem;
  border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text);
  font: inherit; font-size: var(--fs-sm);
  transition: border-color .12s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: #737d8c; }
.input:hover, .select:hover, .textarea:hover { border-color: #4a5262; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent-text); outline: 2px solid rgba(110, 168, 255, .35); outline-offset: 0; border-radius: var(--radius); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-group { display: flex; gap: var(--s2); align-items: stretch; }
.input-group .input { flex: 1 1 auto; min-width: 0; }
.checkbox { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--fs-sm); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-error { color: var(--danger-text); font-size: var(--fs-sm); background: var(--danger-bg); border: 1px solid rgba(229,83,75,.35); padding: .6rem .8rem; border-radius: var(--radius); margin-bottom: var(--s4); }
.form-success { color: var(--success-text); font-size: var(--fs-sm); background: var(--success-bg); border: 1px solid rgba(63,185,122,.35); padding: .6rem .8rem; border-radius: var(--radius); margin-bottom: var(--s4); }

/* segmented toggle (monthly / yearly, time range) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.segmented button { font: inherit; font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); background: transparent; border: 1px solid transparent; padding: .3rem .85rem; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; min-height: 30px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); font-weight: 600; }
.segmented .save { font-size: var(--fs-xs); color: var(--success-text); font-weight: 600; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s6); }
.card-tight { padding: var(--s4); }
.card h3 { font-size: var(--fs-lg); }

/* ------------------------------------------------------------------ code (shared by landing, dashboard, docs) */
.code-window { background: #0a0c10; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.code-window-bar { display: flex; align-items: stretch; justify-content: space-between; gap: var(--s2); border-bottom: 1px solid var(--border); background: var(--surface); font-size: var(--fs-xs); color: var(--text-muted); min-height: 36px; }
.code-window-bar .file { display: inline-flex; align-items: center; gap: .4rem; padding: 0 .9rem; color: var(--text); border-right: 1px solid var(--border); background: #0a0c10; margin-bottom: -1px; font-family: var(--mono); }
.code-window-bar .lang { display: inline-flex; align-items: center; padding: 0 .9rem; color: var(--text-dim); }
.code-window pre { margin: 0; padding: var(--s4) var(--s5); overflow-x: auto; font-size: .8125rem; line-height: 1.65; color: #d4d7dd; tab-size: 4; }
.code-window pre code { font-size: inherit; }

.tok-kw { color: #6cb0ff; }
.tok-type { color: #5fc9b4; }
.tok-str { color: #d9a07b; }
.tok-num { color: #b7d3a0; }
.tok-com { color: #7a8494; }
.tok-attr { color: #d7c98a; }
.tok-fn { color: #e0d49a; }

/* ------------------------------------------------------------------ site header (landing + docs) */
.site-header { position: sticky; top: 0; z-index: 50; height: var(--header-h); background: var(--bg); border-bottom: 1px solid var(--border); }
.site-header .container { height: 100%; display: flex; align-items: center; gap: var(--s8); }
.site-nav { display: flex; align-items: center; gap: var(--s1); height: 100%; }
.site-nav a { position: relative; display: inline-flex; align-items: center; height: 100%; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; padding: 0 .75rem; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); }
.site-nav a[aria-current="page"]::after { content: ""; position: absolute; left: .75rem; right: .75rem; bottom: -1px; height: 2px; background: var(--accent-text); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .site-header .container { gap: var(--s4); }
  .site-nav { display: none; }
  .menu-toggle { display: inline-flex; }
  .site-header.menu-open .site-nav { display: flex; flex-direction: column; align-items: stretch; position: absolute; top: var(--header-h); left: 0; right: 0; height: auto; padding: var(--s2) var(--s4) var(--s4); background: var(--bg); border-bottom: 1px solid var(--border); gap: 0; }
  .site-header.menu-open .site-nav a { height: auto; padding: .75rem .5rem; font-size: var(--fs-base); border-bottom: 1px solid var(--border); }
  .site-header.menu-open .site-nav a:last-child { border-bottom: 0; }
  .site-header.menu-open .site-nav a[aria-current="page"]::after { display: none; }
  .header-actions .hide-sm { display: none; }
}
@media (max-width: 400px) { .header-actions .btn { padding-left: .7rem; padding-right: .7rem; } }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; z-index: 1000; right: var(--s4); bottom: var(--s4); display: flex; flex-direction: column; gap: var(--s2); max-width: min(420px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s3); padding: .75rem 1rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border-strong); border-left-width: 3px; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toast-in .2s var(--ease); }
.toast .icon { margin-top: 2px; }
.toast-success { border-left-color: var(--success); } .toast-success .icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error .icon { color: var(--danger); }
.toast-info { border-left-color: var(--accent-text); } .toast-info .icon { color: var(--accent-text); }
.toast .toast-close { margin-left: auto; background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 0 0 0 var(--s2); font-size: 1.1rem; line-height: 1; }
.toast .toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast.leaving { opacity: 0; transition: opacity .2s; }

/* ------------------------------------------------------------------ dialogs */
dialog.modal { padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(5, 6, 9, .7); }
.modal-head { padding: var(--s5) var(--s6) 0; }
.modal-head h2 { font-size: var(--fs-xl); margin: 0 0 var(--s1); }
.modal-body { padding: var(--s4) var(--s6); }
.modal-foot { padding: var(--s4) var(--s6); display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; border-top: 1px solid var(--border); background: var(--bg-elev); }

/* ------------------------------------------------------------------ tables */
.table-wrap { position: relative; width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; background: var(--bg-elev); white-space: nowrap; }
.table tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255,255,255,.018); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ footer */
.site-footer { border-top: 1px solid var(--border); padding: var(--s12) 0 var(--s8); margin-top: var(--s16); background: var(--bg-elev); }
.footer-grid { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: var(--s8); }
.footer-grid h2, .footer-grid h4 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: var(--s3); letter-spacing: 0; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.footer-grid a { color: var(--text-muted); font-size: var(--fs-sm); }
.footer-grid a:hover { color: var(--text); }
.footer-about p { color: var(--text-muted); font-size: var(--fs-sm); max-width: 22rem; margin: var(--s3) 0 var(--s4); }
.footer-bottom { margin-top: var(--s10); padding-top: var(--s6); border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: var(--s2) var(--s6); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-dim); }
.status-pill { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--fs-xs); color: var(--text-muted); }
@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } .footer-grid > .footer-about { grid-column: 1 / -1; } }

/* ------------------------------------------------------------------ motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* programmatic focus targets (headings, panels, main) don't need a ring */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
