:root {
  color-scheme: light;
  --bg: #eef1f6;
  --card: #ffffff;
  --panel: #f7f9fc;
  --panel-2: #f1f5f9;
  --text: #14213d;
  --muted: #5f6f8a;
  --line: #dce5f1;
  --accent: #2f6df6;
  --accent-hover: #1f57d8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 28px 72px rgba(30, 41, 59, .16);
  --soft-shadow: 0 18px 42px rgba(30, 41, 59, .08);
  --radius-xl: 34px;
  --radius-lg: 26px;
  --radius-md: 18px;
}

body.dark {
  color-scheme: dark;
  --bg: #101521;
  --card: #191f2d;
  --panel: #202838;
  --panel-2: #182131;
  --text: #edf2ff;
  --muted: #a8b3c7;
  --line: #313c52;
  --accent: #5b8cff;
  --accent-hover: #79a3ff;
  --danger: #fb7185;
  --success: #22c55e;
  --shadow: 0 22px 54px rgba(0, 0, 0, .35);
  --soft-shadow: 0 10px 28px rgba(0, 0, 0, .20);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { white-space: nowrap; }
.hidden { display: none !important; }

.shell {
  width: min(1660px, calc(100vw - 40px));
  margin: 22px auto;
}

.app-card {
  background: var(--card);
  border: 1px solid rgba(220, 229, 241, .92);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: clamp(24px, 3vw, 38px);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: transparent;
  font-size: 32px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 2.5vw, 38px); line-height: 1.1; }
h2 { font-size: clamp(23px, 2vw, 30px); line-height: 1.18; }
h3 { font-size: 18px; line-height: 1.25; }
p, .hint { color: var(--muted); line-height: 1.65; }

.brand-badge, .badge, .user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(47, 109, 246, .06);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}

.app > .app-header .top-actions {
  flex-basis: auto;
  width: auto;
  justify-content: flex-start;
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
}

.top-actions, .inline-actions, .checks, .status-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-card {
  min-height: min(760px, calc(100vh - 44px));
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 24px;
  align-items: stretch;
}

.auth-intro {
  min-height: 420px;
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 52px);
  background:
    linear-gradient(180deg, rgba(47, 109, 246, .08), rgba(20, 184, 166, .06)),
    var(--panel);
  border: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 18px;
}

.auth-intro h2 { font-size: clamp(32px, 4vw, 54px); }
.auth-stack { display: grid; gap: 16px; align-content: start; }
.auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.auth-actions .btn { width: 100%; }
.status-strip span {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-weight: 750;
}

.theme-chip, .btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
}

.btn:hover, .theme-chip:hover { border-color: rgba(47, 109, 246, .45); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn-soft { background: var(--panel-2); }
.btn-danger {
  color: var(--danger);
  border-color: rgba(220, 38, 38, .28);
  background: rgba(220, 38, 38, .06);
}

.panel, .mini-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--soft-shadow);
}
.panel { margin-bottom: 18px; }
.mini-panel { display: grid; gap: 13px; }

.panel-head, .room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.compact-head { margin-bottom: 0; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(190px, 1fr)); }
.lobby-grid { grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr); }
.lobby-grid-single { grid-template-columns: minmax(320px, 560px); }
.room-grid { grid-template-columns: minmax(0, 1.8fr) minmax(360px, .8fr); align-items: stretch; }
.form-stack { display: grid; gap: 14px; align-content: start; }

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 760;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, .14);
}

.compact-input { min-width: 240px; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.room-list { display: grid; gap: 10px; }
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
}
.room-item strong { display: block; font-size: 17px; }
.room-item small { color: var(--muted); }

.control-buttons { margin: 16px 0; }
.check-row { display: inline-flex; align-items: center; gap: 7px; }
.check-row input { width: auto; min-height: 0; }
.check-row label { display: inline; color: var(--text); font-weight: 760; }

.meter-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--muted);
  font-weight: 760;
}
.meter {
  height: 18px;
  background: #cfd6df;
  border-radius: 999px;
  overflow: hidden;
}
.meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #facc15, #ef4444);
  transition: width .08s linear;
}

.slider-line {
  grid-template-columns: 92px 1fr 64px;
  align-items: center;
  margin-top: 12px;
}

.chat-panel {
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.chat-messages {
  min-height: 340px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 0%, rgba(47, 109, 246, .08), transparent 34%),
    radial-gradient(circle at 86% 0%, rgba(124, 58, 237, .08), transparent 30%),
    var(--card);
  border-radius: var(--radius-lg);
  padding: 12px;
}
.chat-line { margin-bottom: 10px; }
.chat-line .meta { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.chat-line .bubble {
  display: inline-block;
  max-width: 92%;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  word-break: break-word;
}
.chat-line.self { text-align: right; }
.chat-line.self .bubble {
  background: rgba(47, 109, 246, .12);
  border-color: rgba(47, 109, 246, .25);
}
.chat-line.system { text-align: center; }
.chat-line.system .bubble { color: var(--muted); }
.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 9px;
}
.member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
}
.member-list li.speaking {
  border-color: rgba(47, 109, 246, .85);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, .13);
}
.member-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.mini-btn {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 760;
}
.mini-btn.warn { color: #d97706; }
.mini-btn.danger { color: var(--danger); }
.status-bar, .form-status { min-height: 22px; color: var(--muted); margin-top: 10px; }
footer { text-align: center; color: var(--muted); margin: 20px 0 4px; }

@media (max-width: 1180px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-grid, .lobby-grid, .auth-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { width: min(100vw - 18px, 1536px); margin: 9px auto; }
  .app-card { padding: 16px; }
  .grid.two, .grid.four { grid-template-columns: 1fr; }
  .slider-line { grid-template-columns: 1fr; }
  .chat-input { grid-template-columns: 1fr; }
  .top-actions .btn, .theme-chip { width: 100%; }
}
