/* NG Rooms — Design System v2: Material 3 + Command Center */
:root {
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --shadow-1: 0 2px 6px rgba(5, 15, 30, .08);
  --shadow-2: 0 12px 32px rgba(5, 15, 30, .16);
  --shadow-3: 0 24px 60px rgba(3, 10, 20, .24);
  --brand-900: #061421;
  --brand-800: #0a2036;
  --brand-700: #0d2f4f;
  --brand-600: #12456f;
  --accent: #0ea5b7;
  --accent-strong: #0b8fa0;
  --success: #16a36a;
  --warning: #d97706;
  --danger: #dc3d4b;
  --info: #2563eb;
  --transition: 160ms cubic-bezier(.2, 0, 0, 1);
}

:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-soft: #eaf0f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #eef3f9;
  --surface-inverse: #0a2036;
  --text: #10243a;
  --text-strong: #061421;
  --text-muted: #5c7089;
  --text-inverse: #edf6ff;
  --border: #d7e2ee;
  --border-strong: #b9c9db;
  --primary: #0b4f86;
  --primary-hover: #083e6b;
  --on-primary: #ffffff;
  --accent-soft: #d7f5f8;
  --success-soft: #dcf7ea;
  --warning-soft: #fdf0d8;
  --danger-soft: #fde3e6;
  --info-soft: #e3edff;
  --state-hover: rgba(11, 79, 134, .07);
  --state-focus: rgba(11, 79, 134, .18);
  --map-bg: #e9eff6;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060d19;
  --bg-soft: #081426;
  --surface: #0d1a2b;
  --surface-raised: #12243a;
  --surface-sunken: #091422;
  --surface-inverse: #f4f8ff;
  --text: #dce6f7;
  --text-strong: #f5f9ff;
  --text-muted: #8fa2c2;
  --text-inverse: #0a2036;
  --border: #22314a;
  --border-strong: #34507a;
  --primary: #5b8cff;
  --primary-hover: #7ba3ff;
  --on-primary: #04101f;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: rgba(45, 212, 191, .12);
  --success: #36d6b1;
  --success-soft: rgba(54, 214, 177, .12);
  --warning: #ffcf70;
  --warning-soft: rgba(255, 207, 112, .12);
  --danger: #ff8a97;
  --danger-soft: rgba(255, 138, 151, .12);
  --info: #7ba3ff;
  --info-soft: rgba(91, 140, 255, .14);
  --state-hover: rgba(255, 255, 255, .06);
  --state-focus: rgba(91, 140, 255, .35);
  --map-bg: #0a1424;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--state-focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: #03151c; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-pill);
  border: 1px solid transparent; background: transparent; color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.btn:hover { background: var(--state-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent { background: var(--accent); color: #03151c; }
.btn.tonal { background: var(--accent-soft); color: var(--text-strong); border-color: transparent; }
.btn.outline { border-color: var(--border-strong); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius-pill);
  display: inline-grid; place-items: center; border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--state-hover); }
.icon-btn svg { width: 21px; height: 21px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
}
.card.pad { padding: var(--space-5); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: var(--space-4); }
.card-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-strong); letter-spacing: -.01em; }
.card-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 12.5px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; letter-spacing: .01em; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--text);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--state-focus);
}
textarea { min-height: 96px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 13px; color: var(--text); }
.check input { width: 20px; height: 20px; min-height: 20px; margin: 1px 0 0; accent-color: var(--primary); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 26px; padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--surface-sunken); color: var(--text-muted);
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.msg { margin-top: 12px; color: var(--text-muted); font-size: 13px; min-height: 18px; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--success); }
.hint { color: var(--text-muted); font-size: 12.5px; margin: 4px 0 0; }
.warn {
  border-left: 3px solid var(--warning); padding: 8px 12px;
  color: var(--warning); background: var(--warning-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px; line-height: 1.45;
}
.secret {
  font: 12px/1.5 var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  background: var(--surface-sunken); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; word-break: break-all;
}

/* ---------- site shell ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text-strong); font-weight: 800; letter-spacing: .06em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 10px;
  background:
    radial-gradient(circle at 30% 30%, #5eead4 0 22%, transparent 23%),
    linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 16px rgba(14, 165, 183, .25);
}
.brand small { display: block; font-size: 9px; letter-spacing: .18em; color: var(--text-muted); font-weight: 700; }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: 18px; }
.site-nav a { padding: 8px 12px; border-radius: var(--radius-pill); color: var(--text-muted); font-size: 13px; font-weight: 600; }
.site-nav a:hover { background: var(--state-hover); color: var(--text); text-decoration: none; }
.site-header .spacer { flex: 1; }

/* ---------- landing ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 500px at 80% -10%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
    linear-gradient(160deg, var(--brand-900), var(--bg) 68%);
  color: #edf6ff;
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .hero { background: linear-gradient(160deg, #071c30, #0d3554 55%, #eef6fb 100%); }
.hero-inner { max-width: 1180px; margin: 0 auto; padding: 68px 20px 54px; display: grid; grid-template-columns: 1.15fr .85fr; gap: 36px; align-items: center; }
.hero h1 { margin: 14px 0 12px; font-size: clamp(30px, 4.2vw, 50px); line-height: 1.08; letter-spacing: -.03em; color: #fff; }
.hero .lead { margin: 0 0 22px; max-width: 620px; color: #c7d8ea; font-size: 16px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn.primary { background: #2dd4bf; color: #03151c; }
.hero .btn.outline { border-color: rgba(255,255,255,.35); color: #fff; }
.hero .btn.outline:hover { background: rgba(255,255,255,.1); }
.hero-note { margin-top: 18px; font-size: 12px; color: #9fb5cb; }
.hero-panel {
  background: rgba(8, 22, 38, .72); border: 1px solid rgba(120, 180, 220, .25);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-3);
  backdrop-filter: blur(10px);
}
.hero-panel .row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(120,180,220,.16); font-size: 13px; color: #c7d8ea; }
.hero-panel .row:last-child { border-bottom: 0; }
.hero-panel b { color: #fff; }

.section { max-width: 1180px; margin: 0 auto; padding: 54px 20px; }
.section-head { max-width: 720px; margin-bottom: 24px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; color: var(--accent-strong); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.section h2 { margin: 8px 0 8px; font-size: clamp(22px, 2.6vw, 32px); letter-spacing: -.02em; color: var(--text-strong); }
.section p.lead { color: var(--text-muted); margin: 0; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.feature { padding: 18px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); }
.feature .icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 12px; }
.feature h3 { margin: 0 0 6px; font-size: 14.5px; color: var(--text-strong); }
.feature p { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.profile-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.security-band {
  margin-top: 28px; padding: 20px; border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--brand-800), var(--brand-700));
  color: #dce9f6; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
}
.security-band h3 { margin: 0 0 6px; color: #fff; font-size: 16px; }
.security-band p { margin: 0; font-size: 12.5px; color: #a9c0d6; }

/* ---------- workspace ---------- */
.workspace { max-width: 1180px; margin: 0 auto; padding: 34px 20px 64px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-sunken); border-radius: var(--radius-pill); margin-bottom: 14px; }
.tab { border: 0; background: transparent; color: var(--text-muted); padding: 8px 14px; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-1); }
.result { display: grid; gap: 10px; }
.secret-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.footer { border-top: 1px solid var(--border); padding: 22px 20px; color: var(--text-muted); font-size: 11.5px; }
.footer-inner { max-width: 1180px; margin: 0 auto; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- room command center ---------- */
.app-shell {
  min-height: 100vh; display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 300px;
  grid-template-rows: 60px minmax(0, 1fr);
  grid-template-areas: "top top top" "side main aside";
  background: var(--bg);
}
.app-topbar { grid-area: top; }
.sidebar { grid-area: side; }
.room-main { grid-area: main; }
.aside { grid-area: aside; }
.mobile-nav { grid-area: mobile; }
.app-topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 30;
}
.app-topbar .room-title { display: flex; flex-direction: column; min-width: 0; }
.app-topbar .room-title b { color: var(--text-strong); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar .room-title span { color: var(--text-muted); font-size: 10.5px; }
.app-topbar .spacer { flex: 1; }
.sidebar {
  padding: 16px 12px; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto;
}
.sidebar .brand { padding: 4px 8px 14px; }
.nav-label { margin: 14px 10px 6px; font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--text-muted); text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--state-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.sidebar .security-card { margin-top: auto; padding: 12px; border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); }
.sidebar .security-card b { color: var(--text-strong); display: block; margin-bottom: 4px; font-size: 12px; }

.room-main { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.room-tabs {
  display: flex; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface); overflow-x: auto;
}
.room-tab {
  border: 0; background: transparent; color: var(--text-muted); padding: 8px 12px;
  border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.room-tab.active { background: var(--surface-sunken); color: var(--text-strong); }
.panel { display: none; min-height: 0; flex: 1; }
.panel.active { display: flex; flex-direction: column; }
.messages { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.message { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.message-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; min-width: 0; }
.message-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; }
.message-meta b { color: var(--text-strong); font-size: 12px; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.composer input { flex: 1; }
.aside {
  border-left: 1px solid var(--border); background: var(--surface);
  padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow: auto; min-height: 0;
}
.aside h3 { margin: 0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); }
.status-list { display: grid; gap: 8px; }
.status-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: 0; }
.status-row span { color: var(--text-muted); }
.status-row b { color: var(--text-strong); text-align: right; }
.info-item { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.info-item h4 { margin: 0 0 4px; font-size: 13px; color: var(--text-strong); }
.info-item p { margin: 0; font-size: 12.5px; color: var(--text-muted); white-space: pre-wrap; }
.info-list { display: grid; gap: 10px; padding: 18px; overflow: auto; }
.info-compose { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); display: grid; gap: 8px; }
.mobile-nav { display: none; }

/* ---------- join / moderation ---------- */
.center-wrap { max-width: 620px; margin: 0 auto; padding: 48px 18px; }
.join-hero { text-align: center; margin-bottom: 20px; }
.join-hero h1 { margin: 8px 0; font-size: 26px; letter-spacing: -.02em; color: var(--text-strong); }
.join-hero p { color: var(--text-muted); margin: 0; }
.queue { display: grid; gap: 10px; margin-top: 14px; }
.queue-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; background: var(--surface); }
.queue-item h4 { margin: 0 0 4px; font-size: 14px; color: var(--text-strong); }
.queue-item p { margin: 0; color: var(--text-muted); font-size: 12.5px; }
.queue-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .aside { display: none; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-panel { display: none; }
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .site-nav { display: none; }
  .app-topbar { height: auto; min-height: 58px; padding: 8px 10px; gap: 8px; }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "top" "main" "mobile"; }
  .sidebar { display: none; }
  .app-topbar .room-title span { display: none; }
  .room-tabs { padding: 6px 8px; }
  .messages { padding: 12px; }
  .message { grid-template-columns: 30px minmax(0, 1fr); }
  .avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 10px; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border); background: var(--surface); position: sticky; bottom: 0; z-index: 25;
  }
  .mobile-nav button { border: 0; background: transparent; color: var(--text-muted); padding: 6px 2px; border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; font-weight: 650; }
  .mobile-nav button.active { color: var(--accent-strong); background: var(--accent-soft); }
  .mobile-nav svg { width: 20px; height: 20px; }
  .composer { padding: 8px; position: sticky; bottom: 64px; }
}
@media (max-width: 560px) {
  .feature-grid { grid-template-columns: 1fr; }
  .auth-grid { grid-template-columns: 1fr; }
  .hero-inner { padding: 44px 16px 36px; }
  .section { padding: 38px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .security-band { grid-template-columns: 1fr; }
  .site-header-inner { padding: 8px 12px; }
  .brand small { display: none; }
  .workspace { padding: 20px 12px 40px; }
  .card.pad { padding: 18px; }
  .center-wrap { padding: 28px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

[hidden] { display: none !important; }
