/* ============================================================================
   LiveSpace — LiveKit / Soundcheck design system (dark-first)
   Brand anchors (livekit.com/brand): dark accent #1FD5F9 on #070707,
   light accent #002CF2 on #FDFDFC. Hand-authored (no build step).
   ========================================================================= */

/* Self-hosted faces from /public/fonts (offline-safe, no external CDN). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/inter-700.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/plex-mono-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/plex-mono-600.woff2") format("woff2"); }

:root {
  /* Brand accent — cyan (dark mode default) */
  --color-accent: #1FD5F9;
  --color-accent-hover: #5FE2FB;
  --color-accent-press: #00B9E0;
  --color-accent-contrast: #04121A;

  /* Neutrals — dark scale anchored on #070707 */
  --color-bg: #070707;
  --color-surface-1: #0E0F11;
  --color-surface-2: #16181B;
  --color-surface-3: #1E2125;
  --color-border: #26292E;
  --color-border-strong: #343941;

  /* Text — AA on dark */
  --color-text: #F4F5F6;
  --color-text-muted: #AEB4BC;
  --color-text-subtle: #7C828B;

  /* Semantic */
  --color-success: #34D399;
  --color-success-bg: #052E22;
  --color-warning: #FBBF24;
  --color-warning-bg: #2A1E03;
  --color-danger: #F87171;
  --color-danger-bg: #2A0F0F;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { background-color: var(--color-bg); color-scheme: dark; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--color-bg);
  /* Subtle realtime-nod: a faint brand-cyan glow anchored top-right, fixed. */
  background-image: radial-gradient(55% 40% at 100% -8%, color-mix(in oklab, var(--color-accent) 7%, transparent), transparent 60%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.tabular, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

:where(a, button, [role="button"], input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ layout */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-1);
  position: sticky; top: 0; z-index: 20;
}
.site-header .bar {
  max-width: 72rem; margin: 0 auto; padding: 0 1.5rem;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .name { display: flex; flex-direction: column; line-height: 1; }
.brand .name b { font-weight: 600; color: var(--color-text); font-size: 15px; }
.brand .name span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-subtle); margin-top: 3px; }
.header-actions { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.container { max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem; }
.container-narrow { max-width: 42rem; margin: 0 auto; padding: 2rem 1.5rem; }

/* page header */
.page-header { margin-bottom: 1.5rem; }
.page-header .back { display: inline-flex; gap: 4px; font-size: 12px; color: var(--color-text-subtle); margin-bottom: 4px; }
.page-header .back:hover { color: var(--color-text-muted); }
.page-header .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; margin: 0; color: var(--color-text); }
.page-header .subtitle { font-size: .875rem; color: var(--color-text-muted); margin: .25rem 0 0; }
.page-header .actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ------------------------------------------------------------------ cards */
.card {
  border: 1px solid var(--color-border);
  background: var(--color-surface-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-head {
  padding: .75rem 1rem; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  font-weight: 500; font-size: .875rem;
}
.card-body { padding: 1rem; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.cat-card {
  display: block; border: 1px solid var(--color-border); background: var(--color-surface-1);
  border-radius: var(--radius-lg); padding: 1rem; transition: border-color .15s, background .15s;
}
.cat-card:hover { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.cat-card .title { font-weight: 500; color: var(--color-text); }
.cat-card:hover .title { color: var(--color-accent); }
.cat-card .desc { font-size: .8rem; color: var(--color-text-subtle); margin: .35rem 0 0; }
.cat-card .meta {
  margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--color-border);
  display: flex; justify-content: space-between; font-size: .75rem; color: var(--color-text-subtle);
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-md); padding: .5rem .75rem; font-size: .875rem; font-weight: 500;
  font-family: inherit; cursor: pointer; border: 1px solid transparent; transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn-primary { background: var(--color-accent); color: var(--color-accent-contrast); }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { background: var(--color-accent-press); }
.btn-secondary { border-color: var(--color-border); background: var(--color-surface-1); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-ghost { color: var(--color-text-muted); padding: .35rem .5rem; }
.btn-ghost:hover { color: var(--color-text); background: var(--color-surface-2); }
.btn-danger { color: var(--color-danger); border-color: var(--color-border); background: var(--color-surface-1); }
.btn-danger:hover { background: var(--color-danger-bg); }
.btn-sm { padding: .3rem .55rem; font-size: .78rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 9999px;
  padding: .1rem .5rem; font-size: .72rem; font-weight: 500;
}
.badge-html { background: color-mix(in oklab, var(--color-accent) 15%, transparent); color: var(--color-accent); }
.badge-csv { background: var(--color-success-bg); color: var(--color-success); }
.badge-neutral { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ------------------------------------------------------------------ forms */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .8rem; font-weight: 500; color: var(--color-text-muted); margin-bottom: .35rem; }
.field .hint { font-size: .75rem; color: var(--color-text-subtle); margin-top: .35rem; }
input[type="text"], input[type="password"], textarea, input[type="file"] {
  width: 100%; padding: .55rem .65rem; font-family: inherit; font-size: .9rem;
  background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); color: var(--color-text);
}
input::placeholder, textarea::placeholder { color: var(--color-text-subtle); }
textarea { resize: vertical; min-height: 4.5rem; }
input[type="file"] { padding: .45rem; cursor: pointer; }
input[type="file"]::file-selector-button {
  margin-right: .75rem; border: 1px solid var(--color-border); background: var(--color-surface-1);
  color: var(--color-text); border-radius: var(--radius-sm); padding: .35rem .6rem; cursor: pointer; font-family: inherit;
}

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data th, table.data td {
  text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
table.data thead th { color: var(--color-text-subtle); font-weight: 500; background: var(--color-surface-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tbody tr:hover { background: var(--color-surface-2); }
table.data td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* url / copy row */
.url-row { display: flex; align-items: center; gap: .5rem; }
.url-pill {
  flex: 1; min-width: 0; font-family: var(--font-mono); font-size: .78rem; color: var(--color-text-muted);
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: .35rem .55rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------------------------ misc */
.empty { padding: 2.5rem 1rem; text-align: center; }
.empty .icon { width: 40px; height: 40px; margin: 0 auto .75rem; border-radius: 9999px; background: var(--color-surface-2); color: var(--color-text-subtle); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.empty p { font-size: .875rem; color: var(--color-text-muted); margin: 0 0 .25rem; }

.flash { max-width: 72rem; margin: 1rem auto 0; padding: 0 1.5rem; }
.flash .msg { border-radius: var(--radius-md); padding: .6rem .8rem; font-size: .85rem; border: 1px solid var(--color-border); }
.flash .notice { background: var(--color-success-bg); color: var(--color-success); border-color: color-mix(in oklab, var(--color-success) 30%, transparent); }
.flash .alert { background: var(--color-danger-bg); color: var(--color-danger); border-color: color-mix(in oklab, var(--color-danger) 30%, transparent); }

.muted { color: var(--color-text-subtle); }
.text-muted { color: var(--color-text-muted); }
.stack > * + * { margin-top: 1rem; }
.flex { display: flex; align-items: center; gap: .5rem; }
.between { justify-content: space-between; }
.section-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-subtle); }

/* live pulse */
.live-dot { position: relative; display: inline-flex; height: .5rem; width: .5rem; }
.live-dot::before { content: ""; position: absolute; inset: 0; border-radius: 9999px; background: var(--color-accent); opacity: .75; animation: sc-ping 1.2s cubic-bezier(0,0,.2,1) infinite; }
.live-dot::after { content: ""; position: relative; display: inline-flex; border-radius: 9999px; height: .5rem; width: .5rem; background: var(--color-accent); }
@keyframes sc-ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }

/* auth screen */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 22rem; }
.auth-card .brand { justify-content: center; margin-bottom: 1.5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
