:root {
  color-scheme: dark;
  --bg: #050713;
  --panel: rgba(12, 17, 38, 0.72);
  --panel-strong: rgba(17, 25, 55, 0.92);
  --line: rgba(130, 163, 255, 0.28);
  --text: #eef4ff;
  --muted: #aab7d4;
  --cyan: #35d6ff;
  --violet: #9c6cff;
  --green: #54ffb6;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(53, 214, 255, .24), transparent 25%),
    radial-gradient(circle at 85% 10%, rgba(156, 108, 255, .26), transparent 28%),
    radial-gradient(circle at 50% 90%, rgba(84, 255, 182, .10), transparent 35%),
    linear-gradient(135deg, #050713 0%, #0b1024 52%, #080916 100%);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.auth-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 28px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.06);
  overflow: hidden;
}
.auth-brand { margin: 0 0 18px; }
.back-link { color: var(--cyan); text-decoration: none; font-weight: 800; }
.auth-form { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 20px; width: 100%; }
.auth-form label { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.auth-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline: none;
}
.auth-form button {
  width: 100%;
  min-height: 46px;
  border-radius: 16px;
  font-weight: 800;
}
.auth-form #signupButton {
  border: 0;
  color: #04111a;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}
.auth-status { min-height: 22px; }

.desktop {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 56px 1fr;
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 19, .52);
}
.brand, .status { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.orb {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 24px var(--cyan);
}
.pill {
  border: 1px solid rgba(84,255,182,.45);
  color: var(--green);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.auth-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(53,214,255,.30);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,.055);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}
.auth-link:hover { color: var(--cyan); border-color: rgba(53,214,255,.58); }

.workspace {
  display: grid;
  grid-template-columns: 86px minmax(420px, 1fr) 360px;
  gap: 22px;
  padding: 22px;
  min-height: 0;
  height: calc(100dvh - 56px);
  overflow: hidden;
}
.dock {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  align-self: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.dock-icon {
  width: 48px; height: 48px; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(255,255,255,.05); color: var(--text); font-size: 20px;
  cursor: pointer;
}
.dock-icon.active { background: linear-gradient(135deg, rgba(53,214,255,.35), rgba(156,108,255,.35)); box-shadow: 0 0 28px rgba(53,214,255,.25); }

.window, .glass-card {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.06);
}
.chat-window { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; overflow: hidden; }
.window-titlebar {
  display: flex; gap: 18px; align-items: center;
  padding: 22px 24px; border-bottom: 1px solid var(--line);
  background: rgba(17, 25, 55, .54);
}
.traffic { display: flex; gap: 8px; }
.traffic span { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.traffic span:nth-child(2) { background: #ffbd2e; }
.traffic span:nth-child(3) { background: #28c840; }
h1 { margin: 0; font-size: 22px; }
p { margin: 6px 0 0; color: var(--muted); }

.messages { padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.message { display: flex; gap: 12px; align-items: flex-start; }
.message.user { flex-direction: row-reverse; }
.avatar {
  width: 38px; height: 38px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
}
.bubble {
  max-width: min(680px, 80%);
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 20px;
  background: rgba(255,255,255,.06);
}
.user .bubble { background: rgba(53,214,255,.14); }
.bubble p { white-space: pre-wrap; }

.composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  grid-template-areas:
    "voice input bridge send"
    "status status status status";
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(5,7,19,.34);
  align-items: center;
}
textarea {
  grid-area: input;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 11px 14px;
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline: none;
  min-height: 44px;
  max-height: 110px;
}
.composer button[type="submit"] {
  grid-area: send;
  border: 0; border-radius: 16px; padding: 0 18px; font-weight: 800;
  min-height: 44px;
  color: #04111a; cursor: pointer;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}
button:disabled, textarea:disabled { opacity: .55; cursor: wait; }
.round-action, .ghost-button, .mini-form button, .compact-list button {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.07);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}
.round-action { grid-area: voice; width: 44px; height: 44px; padding: 0; font-size: 17px; display: inline-grid; place-items: center; flex: 0 0 44px; align-self: center; }
.round-action.listening { color: #04111a; background: linear-gradient(135deg, #ff6bd6, var(--cyan)); box-shadow: 0 0 30px rgba(255,107,214,.35); }
.round-action.disabled { opacity: .45; }
.bridge-control {
  grid-area: bridge;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255,255,255,.045);
  font-size: 12px;
  font-weight: 800;
}
.bridge-control input { accent-color: var(--green); }
.bridge-control.disabled { opacity: .55; cursor: not-allowed; }
.voice-status {
  grid-area: status;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}
.voice-status.live { color: var(--green); }
.voice-status.warn { color: #ffbd2e; }

.widget-stack { display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto; padding-right: 4px; }
.glass-card { padding: 22px; }
.glass-card h2 { margin: 0 0 10px; font-size: 16px; }
ul { color: var(--muted); padding-left: 20px; line-height: 1.7; }
.meter { height: 10px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin-top: 16px; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan), var(--green)); }
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-heading h2 { margin: 0; }
.mini-pill, .module-status {
  border: 1px solid rgba(53,214,255,.32);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(53,214,255,.08);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 5px 8px;
  text-transform: uppercase;
}
.module-grid { display: grid; gap: 12px; }
.module-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  position: relative;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,.075), rgba(255,255,255,.025));
  overflow: hidden;
}
.module-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(156,108,255,.18), transparent 70%);
}
.module-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
}
.module-card h3 { margin: 0; font-size: 14px; }
.module-card p { margin: 4px 0 0; font-size: 12px; line-height: 1.4; }
.module-status {
  grid-column: 2;
  justify-self: start;
  margin-top: 4px;
  color: var(--green);
  border-color: rgba(84,255,182,.35);
  background: rgba(84,255,182,.08);
}
.mini-form { display: grid; gap: 10px; margin: 10px 0 14px; }
.mode-select-label { display: block; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 8px; }
.mode-select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 12px;
  background: rgba(255,255,255,.07);
  color: var(--text);
  font-weight: 800;
  outline: none;
}
.mode-select option { background: #0b1024; color: var(--text); }
.admin-card[hidden] { display: none; }
.mini-form input[type="text"], .mini-form input:not([type]), .mini-form input[type="file"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 10px 12px;
  background: rgba(255,255,255,.06);
  color: var(--text);
}
.file-form { grid-template-columns: 1fr auto; align-items: center; }
.ghost-button { padding: 9px 12px; width: 100%; color: var(--muted); }
.session-status { color: var(--muted); font-size: 12px; font-weight: 800; }
.compact-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 14px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.compact-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  font-size: 12px;
}
.compact-list a { color: var(--cyan); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-list button { width: 28px; height: 28px; flex: 0 0 auto; }
.compact-list li.done span { text-decoration: line-through; opacity: .62; }
.muted-item { justify-content: center !important; color: rgba(170,183,212,.7); }

@media (max-width: 900px) {
  .desktop {
    min-height: 100dvh;
    grid-template-rows: auto 1fr;
  }
  .topbar {
    min-height: 56px;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand, .status { gap: 8px; flex-wrap: wrap; }
  .pill { display: none; }
  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
    height: auto;
    min-height: calc(100dvh - 72px);
    overflow: visible;
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .dock { flex-direction: row; justify-self: center; align-self: auto; padding: 8px; }
  .dock-icon { width: 42px; height: 42px; }
  .widget-stack { display: none; }
  .chat-window {
    height: calc(100dvh - 172px);
    min-height: 420px;
    max-height: none;
  }
  .window-titlebar { padding: 14px 16px; }
  .messages { min-height: 0; padding: 16px; }
  .composer {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "voice input"
      "bridge send"
      "status status";
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .bridge-control, .composer button[type="submit"] { min-height: 44px; }
}

@media (max-width: 520px) {
  h1 { font-size: 18px; }
  .auth-link, .session-status, #clock { font-size: 11px; }
  .window-titlebar p { display: none; }
  .bubble { max-width: 86%; }
}
