/* MC Dashboard: styled after Apple's Human Interface Guidelines.
   System font, clear hierarchy, translucent materials, 44pt hit targets,
   automatic light/dark appearance, respect for reduced motion/transparency. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --label: #1d1d1f;
  --secondary-label: rgba(60, 60, 67, 0.62);
  --tertiary-label: rgba(60, 60, 67, 0.36);
  --separator: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: #ffffff;
  --input: rgba(255, 255, 255, 0.72);
  --material: rgba(255, 255, 255, 0.64);
  --sidebar: rgba(246, 246, 248, 0.78);
  --material-border: rgba(255, 255, 255, 0.7);
  --accent: #007aff;
  --accent-pressed: #0062cc;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.12);
  --orange: #ff9500;
  --green: #34c759;
  --gray: #8e8e93;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 40px rgba(0, 0, 0, 0.10);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 12px rgba(0, 0, 0, 0.04);
  --focus: 0 0 0 4px rgba(0, 122, 255, 0.28);

  --terminal-bg: #1c1c1e;
  --terminal-text: #e5e5ea;

  --orb-a: #8fd3a5;
  --orb-b: #9cc7ff;
  --orb-c: #e9c9a0;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --label: #f5f5f7;
    --secondary-label: rgba(235, 235, 245, 0.6);
    --tertiary-label: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.6);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: #1c1c1e;
    --input: rgba(118, 118, 128, 0.24);
    --material: rgba(30, 30, 32, 0.62);
    --sidebar: rgba(28, 28, 30, 0.78);
    --material-border: rgba(255, 255, 255, 0.08);
    --accent: #0a84ff;
    --accent-pressed: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.2);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, 0.18);
    --orange: #ff9f0a;
    --green: #30d158;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 60px rgba(0, 0, 0, 0.55);
    --card-shadow: none;
    --focus: 0 0 0 4px rgba(10, 132, 255, 0.4);

    --terminal-bg: #0d0d0f;

    --orb-a: #1f6b3c;
    --orb-b: #1c4f9c;
    --orb-c: #6b4a24;
  }
}

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

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  letter-spacing: -0.022em;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select { font: inherit; letter-spacing: inherit; color: inherit; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

svg { fill: currentColor; }

/* ================= Login ================= */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px 72px;
  overflow: hidden;
}

.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: drift 28s ease-in-out infinite alternate;
}
.orb-a { background: var(--orb-a); top: -25vmax; left: -15vmax; }
.orb-b { background: var(--orb-b); bottom: -30vmax; right: -20vmax; animation-delay: -9s; }
.orb-c { background: var(--orb-c); top: 35%; left: 45%; width: 35vmax; height: 35vmax; opacity: 0.35; animation-delay: -17s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 40px 32px 32px;
  text-align: center;
  background: var(--material);
  border: 0.5px solid var(--material-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  animation: appear 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes appear {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.app-icon {
  display: block;
  margin: 0 auto 18px;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.15;
}

.subtitle {
  margin: 6px 0 28px;
  color: var(--secondary-label);
  font-size: 15px;
}

/* iOS-style inset grouped fields */
.field-group {
  background: var(--input);
  border: 0.5px solid var(--separator);
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
  transition: box-shadow 0.2s ease;
}
.field-group:focus-within { box-shadow: var(--focus); }

.field { position: relative; display: flex; align-items: center; }
.field + .field::before {
  content: "";
  position: absolute; top: 0; left: 16px; right: 0;
  height: 0.5px; background: var(--separator);
}

.field input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 17px;
}
.field input::placeholder { color: var(--tertiary-label); }
.field input:-webkit-autofill {
  -webkit-text-fill-color: var(--label);
  transition: background-color 9999s ease-out 0s;
}

.code-input {
  text-align: center;
  font-family: var(--mono);
  font-size: 26px !important;
  letter-spacing: 0.4em;
  height: 60px !important;
  font-variant-numeric: tabular-nums;
}

.reveal {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  margin-right: 4px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--secondary-label);
  cursor: pointer;
}
.reveal:hover { color: var(--label); }
.reveal:focus-visible { outline: none; box-shadow: var(--focus); }
.reveal svg { width: 20px; height: 20px; }
.reveal .eye-closed { display: none; }
.reveal[aria-pressed="true"] .eye-open { display: none; }
.reveal[aria-pressed="true"] .eye-closed { display: block; }

.hint {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--orange);
}
.hint svg { width: 14px; height: 14px; }

.error {
  min-height: 20px;
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--red);
}
.error:empty { visibility: hidden; }

.primary {
  position: relative;
  width: 100%;
  height: 50px;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.2s ease;
}
.primary:hover { background: var(--accent-pressed); }
.primary:active { transform: scale(0.98); }
.primary:focus-visible { outline: none; box-shadow: var(--focus); }
.primary:disabled { opacity: 0.45; cursor: default; transform: none; background: var(--accent); }
.primary.busy { opacity: 1; }
.primary.busy .label { visibility: hidden; }
.primary.compact { width: auto; height: 40px; padding: 0 22px; margin: 0; font-size: 15px; border-radius: 10px; }

.link {
  display: block;
  margin: 14px auto 0;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  border-radius: 8px;
}
.link:hover { text-decoration: underline; }
.link:focus-visible { outline: none; box-shadow: var(--focus); }

.spinner {
  position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  display: none;
  animation: spin 0.8s linear infinite;
}
.primary.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-card.shake { animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.login-card.success { transition: opacity 0.3s ease, transform 0.3s ease; opacity: 0; transform: scale(1.02); }

.login-footer {
  position: fixed; left: 0; right: 0; bottom: 24px; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px;
  color: var(--secondary-label);
}
.login-footer svg { width: 12px; height: 12px; }

/* ================= Dashboard shell ================= */

.dashboard-page { min-height: 100vh; }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px;
  background: var(--sidebar);
  border-right: 0.5px solid var(--separator);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand img { border-radius: 8px; flex: none; }
.brand-name { font-size: 15px; font-weight: 600; }

.state-pill { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--secondary-label); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: none; }
[data-state="running"] .dot { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
[data-state="starting"] .dot, [data-state="stopping"] .dot { background: var(--orange); animation: pulse 1.2s ease-in-out infinite; }
[data-state="crashed"] .dot { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--label);
  text-decoration: none;
  font-size: 15px;
}
.nav-item svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.nav-item:hover { background: var(--fill); }
.nav-item[aria-current="page"] { background: var(--accent); color: #fff; }
.nav-item[aria-current="page"] svg { color: #fff; }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus); }

.sidebar-footer {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 8px 0;
  border-top: 0.5px solid var(--separator);
}
.account { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.demo-badge {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--orange) 18%, transparent);
  color: var(--orange);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.secondary {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.secondary:hover { background: var(--separator); }
.secondary:focus-visible { outline: none; box-shadow: var(--focus); }

.main { min-width: 0; padding: 28px 32px 64px; }
.view { max-width: 1100px; margin: 0 auto; animation: fade 0.25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
.view-header h1 { font-size: 32px; letter-spacing: -0.03em; }

.search {
  width: 220px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  font-size: 15px;
  outline: none;
}
.search:focus { box-shadow: var(--focus); }

.card {
  background: var(--bg-elevated);
  border: 0.5px solid var(--separator);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}

.eyebrow, .tile h2 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--secondary-label);
}

/* ---------- Overview ---------- */

.server-card { padding: 22px 24px; margin-bottom: 16px; }
.server-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.server-state { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.server-state[data-state="running"] { color: var(--green); }
.server-state[data-state="crashed"] { color: var(--red); }
.server-state[data-state="starting"], .server-state[data-state="stopping"] { color: var(--orange); }
.server-meta { margin-top: 2px; font-size: 14px; color: var(--secondary-label); }

.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
.pill-button svg { width: 15px; height: 15px; }
.pill-button:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.pill-button:active { transform: scale(0.97); }
.pill-button:focus-visible { outline: none; box-shadow: var(--focus); }
.pill-button:disabled { opacity: 0.35; cursor: default; transform: none; }
.pill-button.destructive { background: var(--red-soft); color: var(--red); }
.pill-button.destructive:hover { background: color-mix(in srgb, var(--red) 24%, transparent); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.tile { padding: 18px 20px; position: relative; }
.tile-value { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile-note { margin: 6px 0 0; font-size: 13px; color: var(--secondary-label); }

.meter {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}
.meter span {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.meter span.warn { background: var(--orange); }
.meter span.crit { background: var(--red); }

.spark { position: relative; margin-top: 10px; height: 44px; }
.spark svg { display: block; width: 100%; height: 44px; overflow: visible; cursor: crosshair; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--accent); opacity: 0.12; }
.spark-base { stroke: var(--separator); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-cursor { stroke: var(--secondary-label); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-tip {
  position: absolute; bottom: 100%; transform: translate(-50%, -6px);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--label); color: var(--bg);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  pointer-events: none;
}

/* ---------- Console ---------- */

.terminal {
  position: relative;
  display: flex; flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 360px;
  background: var(--terminal-bg);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  border: 0.5px solid var(--separator);
}
.terminal-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--terminal-text);
  white-space: pre-wrap;
  word-break: break-word;
}
.ln.warn { color: #ffd60a; }
.ln.error, .ln.fatal { color: #ff6961; }
.ln.cmd { color: #64d2ff; margin-top: 6px; }
.ln.out { color: #a1e3a1; }
.terminal-input {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}
.prompt { color: #64d2ff; font-family: var(--mono); font-size: 16px; }
.terminal-input input {
  flex: 1; min-width: 0;
  height: 36px;
  border: 0; background: transparent; outline: none;
  color: var(--terminal-text);
  font-family: var(--mono); font-size: 13.5px; letter-spacing: 0;
}
.terminal-input input::placeholder { color: rgba(235, 235, 245, 0.35); }

.send {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--accent); color: #fff;
  cursor: pointer;
}
.send svg { width: 18px; height: 18px; }
.send:focus-visible { outline: none; box-shadow: var(--focus); }

.jump {
  position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%);
  padding: 6px 14px;
  border: 0; border-radius: 999px;
  background: rgba(60, 60, 67, 0.85); color: #fff;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ---------- Players ---------- */

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
}
.segmented button {
  height: 30px;
  padding: 0 14px;
  border: 0; border-radius: 7px;
  background: transparent;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.segmented button[aria-selected="true"] {
  background: var(--fill-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  .segmented button[aria-selected="true"] { background: #636366; }
}
.segmented button:focus-visible { outline: none; box-shadow: var(--focus); }

.inline-form { display: flex; gap: 8px; }
.inline-form input {
  width: 170px; height: 36px;
  padding: 0 12px;
  border: 0; border-radius: 10px;
  background: var(--fill);
  outline: none; font-size: 15px;
}
.inline-form input:focus { box-shadow: var(--focus); }

.list {
  background: var(--bg-elevated);
  border: 0.5px solid var(--separator);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.list-row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px;
  padding: 10px 12px 10px 16px;
}
.list-row + .list-row::before {
  content: ""; position: absolute; top: 0; left: 68px; right: 0;
  height: 0.5px; background: var(--separator);
}
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; font-size: 16px; }
.row-sub { font-size: 13px; color: var(--secondary-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  --hue: 210;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  background: linear-gradient(160deg, hsl(var(--hue) 70% 62%), hsl(var(--hue) 62% 46%));
  color: #fff;
  font-weight: 600; font-size: 17px;
}
.avatar.small { width: 26px; height: 26px; font-size: 12px; }
.avatar.server { background: linear-gradient(160deg, #8e8e93, #636366); }
.avatar-wrap { position: relative; }
.presence {
  position: absolute; right: -1px; bottom: -1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--green);
  border: 2.5px solid var(--bg-elevated);
}

.badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary-label);
  font-size: 11px; font-weight: 600;
}
.badge.op { background: var(--accent-soft); color: var(--accent); }
.badge.banned { background: var(--red-soft); color: var(--red); }

.more {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--fill); color: var(--accent);
  cursor: pointer;
}
.more svg { width: 18px; height: 18px; }
.more:hover { background: var(--separator); }
.more:focus-visible { outline: none; box-shadow: var(--focus); }

.empty { margin: 0; padding: 40px 16px; text-align: center; color: var(--secondary-label); font-size: 15px; }

/* ---------- Chat ---------- */

.chat { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 360px; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-msg .avatar { width: 32px; height: 32px; font-size: 14px; }
.chat-body { min-width: 0; }
.chat-head { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.chat-head time, .chat-event time { color: var(--tertiary-label); font-size: 12px; font-variant-numeric: tabular-nums; }
.chat-body p {
  display: inline-block;
  margin: 3px 0 0;
  padding: 7px 12px;
  border-radius: 4px 16px 16px 16px;
  background: var(--fill);
  font-size: 15px;
  word-break: break-word;
}
.chat-msg.from-server .chat-body p { background: var(--accent-soft); }
.chat-event { display: flex; justify-content: center; gap: 8px; align-items: baseline; font-size: 13px; color: var(--secondary-label); }
.chat-event.join span::before { content: "→ "; color: var(--green); }
.chat-event.leave span::before { content: "← "; color: var(--gray); }
.chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 10px 14px;
  border-top: 0.5px solid var(--separator);
}
.chat-input input {
  flex: 1; min-width: 0;
  height: 36px;
  padding: 0 14px;
  border: 0.5px solid var(--separator);
  border-radius: 999px;
  background: var(--bg);
  outline: none; font-size: 15px;
}
.chat-input input:focus { box-shadow: var(--focus); }

/* ---------- Settings ---------- */

.settings { max-width: 720px; }
.group-title {
  margin: 24px 0 8px 16px;
  font-size: 13px; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--secondary-label);
}
.group-title:first-child { margin-top: 0; }
.group {
  background: var(--bg-elevated);
  border: 0.5px solid var(--separator);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
.row {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 52px;
  padding: 8px 16px;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0;
  height: 0.5px; background: var(--separator);
}
.row > label { font-size: 15px; }
.row > label small { display: block; font-size: 12px; color: var(--secondary-label); }
.row-control { display: flex; align-items: center; gap: 10px; }
.row-footnote { margin: 0; padding: 0 16px 12px; font-size: 12px; color: var(--secondary-label); }

.slider-control { display: flex; align-items: center; gap: 12px; }
.slider-control output { min-width: 82px; text-align: right; font-size: 14px; color: var(--secondary-label); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 200px; accent-color: var(--accent); }

.row select, .row input[type="text"], .number-control input {
  height: 32px;
  padding: 0 10px;
  border: 0; border-radius: 8px;
  background: var(--fill);
  font-size: 15px;
  outline: none;
}
.row input[type="text"] { width: 280px; }
.number-control { display: flex; align-items: center; gap: 8px; }
.number-control input { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.unit { font-size: 13px; color: var(--secondary-label); }
.row select:focus, .row input:focus { box-shadow: var(--focus); }

/* iOS-style switch */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: var(--fill);
  transition: background-color 0.2s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.25s cubic-bezier(0.3, 1.2, 0.5, 1);
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }

.settings-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 720px;
  margin-bottom: 16px;
  padding: 12px 12px 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 15px;
}

/* ---------- Alerts & toasts ---------- */

.alert {
  width: min(300px, calc(100vw - 40px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--material);
  color: var(--label);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  text-align: center;
  overflow: hidden;
}
.alert[open] { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes pop { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: none; } }
.alert::backdrop { background: rgba(0, 0, 0, 0.3); }
.alert h2 { margin: 20px 16px 4px; font-size: 17px; font-weight: 600; }
.alert p { margin: 0 16px 16px; font-size: 13px; color: var(--label); opacity: 0.85; }
.alert input {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  height: 32px;
  padding: 0 8px;
  border: 0.5px solid var(--separator);
  border-radius: 7px;
  background: var(--bg-elevated);
  font-size: 14px;
  outline: none;
}
.alert-buttons { display: flex; border-top: 0.5px solid var(--separator); }
.alert-buttons.stacked { flex-direction: column; }
.alert-button {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 17px; font-weight: 600;
  cursor: pointer;
}
.alert-buttons:not(.stacked) .alert-button + .alert-button { border-left: 0.5px solid var(--separator); }
.alert-buttons.stacked .alert-button + .alert-button { border-top: 0.5px solid var(--separator); }
.alert-buttons:not(.stacked) .alert-button.cancel { order: -1; }
.alert-button.cancel { font-weight: 400; }
.alert-button.destructive { color: var(--red); }
.alert-button:hover { background: var(--fill); }
.alert-button:focus-visible { outline: none; background: var(--fill); }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--material);
  color: var(--label);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: var(--red); }

/* ---------- Small screens: sidebar becomes an iOS tab bar ---------- */

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20;
    height: auto;
    flex-direction: row; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 0.5px solid var(--separator);
  }
  .brand, .sidebar-footer { display: none; }
  .nav-item { flex-direction: column; gap: 2px; min-height: 44px; padding: 4px 6px; font-size: 10px; color: var(--secondary-label); }
  .nav-item svg { width: 22px; height: 22px; color: inherit; }
  .nav-item[aria-current="page"] { background: none; color: var(--accent); }
  .nav-item[aria-current="page"] svg { color: var(--accent); }
  .main { padding: 20px 16px 96px; }
  .view-header h1 { font-size: 28px; }
  .search { width: 140px; }
  .terminal, .chat { height: calc(100vh - 200px); }
  .row { flex-wrap: wrap; }
  .row input[type="text"] { width: 100%; }
  input[type="range"] { width: 140px; }
  .segmented { overflow-x: auto; max-width: 100%; }
}

/* ---------- Accessibility preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .spinner { animation: spin 1.6s linear infinite !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .login-card, .sidebar, .alert, .toast {
    background: var(--fill-strong);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .orb { display: none; }
}

@media (prefers-contrast: more) {
  :root { --separator: rgba(60, 60, 67, 0.5); }
  .field-group, .login-card, .card, .list, .group { border-width: 1px; }
}

@media (max-width: 420px) {
  .login-card { padding: 32px 20px 24px; border-radius: 24px; }
}
