:root {
  color-scheme: dark;
  --bg: #07090c;
  --panel: rgba(14, 20, 26, 0.88);
  --panel-strong: rgba(21, 30, 38, 0.94);
  --line: rgba(126, 232, 255, 0.24);
  --text: #edf8fb;
  --muted: #8aa1a9;
  --aqua: #76e9ff;
  --amber: #ffca72;
  --red: #ff6b6b;
  --green: #7dffb2;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(118, 233, 255, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(118, 233, 255, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 50% 22%, rgba(118, 233, 255, 0.18), transparent 32rem),
    linear-gradient(135deg, #07090c 0%, #10151b 44%, #080b10 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
  color: var(--text);
}

body[data-ui-style="glass"] {
  --bg: #071013;
  --panel: rgba(12, 31, 36, 0.78);
  --panel-strong: rgba(19, 49, 55, 0.9);
  --line: rgba(136, 255, 229, 0.28);
  --text: #eefdf9;
  --muted: #91bbb4;
  --aqua: #88ffe5;
  --amber: #f6d782;
  --green: #9effc5;
  background:
    linear-gradient(90deg, rgba(136, 255, 229, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(136, 255, 229, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 78% 18%, rgba(246, 215, 130, 0.12), transparent 26rem),
    linear-gradient(135deg, #071013 0%, #102328 48%, #090d12 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

body[data-ui-style="stealth"] {
  --bg: #050607;
  --panel: rgba(13, 15, 17, 0.92);
  --panel-strong: rgba(22, 24, 27, 0.96);
  --line: rgba(190, 198, 204, 0.2);
  --text: #f0f2f2;
  --muted: #8f999f;
  --aqua: #c9d4d9;
  --amber: #e7b96c;
  --green: #a7f0b8;
  background:
    linear-gradient(90deg, rgba(240, 242, 242, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(240, 242, 242, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 42% 8%, rgba(231, 185, 108, 0.09), transparent 24rem),
    linear-gradient(135deg, #050607 0%, #151719 55%, #08090a 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

body[data-ui-style="daylight"] {
  color-scheme: light;
  --bg: #edf3f5;
  --panel: rgba(251, 253, 253, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(31, 95, 114, 0.22);
  --text: #17262c;
  --muted: #62747b;
  --aqua: #0c7e98;
  --amber: #a76616;
  --green: #177a49;
  --shadow: 0 24px 80px rgba(40, 68, 79, 0.16);
  background:
    linear-gradient(90deg, rgba(12, 126, 152, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(12, 126, 152, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 50% 12%, rgba(167, 102, 22, 0.14), transparent 28rem),
    linear-gradient(135deg, #edf3f5 0%, #f9fbfb 48%, #e4ecef 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.private-gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 18px;
}

.gate-panel {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  background: rgba(14, 20, 26, 0.92);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 44px);
  backdrop-filter: blur(18px);
}

.gate-panel h1 {
  margin: 2px 0 28px;
  font-size: clamp(2.4rem, 10vw, 5.2rem);
}

.gate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  margin-top: 8px;
}

.gate-row button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--aqua);
  color: #061014;
  font-weight: 800;
}

.gate-row button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.gate-message {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 18px;
}

.console,
.settings {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.console {
  display: grid;
  grid-template-rows: auto minmax(260px, 39vh) 1fr auto;
  min-height: calc(100vh - 36px);
  overflow: hidden;
}

.status-bar,
.composer,
.settings {
  padding: 18px;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
label,
.readouts span {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.readouts label {
  display: block;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 7vw, 5.8rem);
  line-height: 0.92;
  color: var(--aqua);
  text-shadow: 0 0 30px rgba(118, 233, 255, 0.34);
}

h2 {
  font-size: 1.45rem;
}

.system-state,
.readouts div,
.note {
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.system-state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 10px 12px;
  color: var(--green);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 18px currentColor;
}

.core-panel {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

#reactor {
  display: block;
  width: 100%;
  height: 100%;
}

.readouts {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  gap: 8px;
  width: min(420px, calc(100% - 32px));
}

.readouts div {
  padding: 10px;
}

.readouts strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 0.94rem;
}

.readouts select {
  height: 34px;
  margin-top: 6px;
  padding: 0 8px;
  font-size: 0.86rem;
}

.readouts #voiceState {
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 220px;
  overflow-y: auto;
  padding: 18px;
}

.message {
  max-width: min(820px, 92%);
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.06);
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.assistant {
  border-color: rgba(118, 233, 255, 0.26);
  background: rgba(36, 123, 145, 0.16);
}

.message.user {
  align-self: flex-end;
  border-color: rgba(255, 202, 114, 0.25);
  background: rgba(145, 103, 36, 0.16);
}

.composer {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px 88px;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: rgba(4, 8, 12, 0.42);
}

.icon-button,
.send-button,
.key-row button,
.button-row button,
.settings > button,
.attachment-pill {
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(118, 233, 255, 0.12);
  color: var(--text);
}

.icon-button {
  font-size: 1.5rem;
  color: var(--aqua);
}

.send-button,
.key-row button,
.settings > button {
  background: var(--aqua);
  color: #061014;
  font-weight: 800;
}

.settings > .danger-button {
  border-color: rgba(255, 107, 107, 0.46);
  background: rgba(255, 107, 107, 0.14);
  color: var(--text);
}

.settings > .danger-button:hover,
.settings > .danger-button:focus-visible {
  background: var(--red);
  color: #190606;
}

.settings > .danger-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.attachment-tray {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.attachment-pill {
  min-height: 34px;
  max-width: 100%;
  padding: 0 10px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#cameraPreview,
#screenPreview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  background: #000;
  object-fit: cover;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 48px;
  max-height: 150px;
  resize: none;
  padding: 13px 14px;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(118, 233, 255, 0.12);
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: calc(100vh - 36px);
}

.settings-head {
  margin-bottom: 10px;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  font-size: 0.95rem;
  color: var(--text);
}

.toggle input {
  width: 18px;
  height: 18px;
}

.note {
  margin-top: auto;
  padding: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .console,
  .settings {
    min-height: auto;
  }

  .console {
    grid-template-rows: auto 280px minmax(260px, 1fr) auto;
  }
}

@media (max-width: 620px) {
  body {
    background-size: 30px 30px, 30px 30px, auto, auto;
  }

  button,
  input,
  textarea,
  select {
    font-size: 16px;
  }

  button {
    min-height: 48px;
  }

  .private-gate {
    align-items: start;
    padding: 14px;
    padding-top: max(18px, env(safe-area-inset-top));
  }

  .gate-panel {
    margin-top: 8vh;
    padding: 22px;
  }

  .gate-panel h1 {
    margin-bottom: 22px;
    font-size: clamp(2.3rem, 16vw, 4.2rem);
    line-height: 0.98;
  }

  .shell {
    gap: 10px;
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .console {
    grid-template-rows: auto minmax(210px, 28svh) minmax(300px, 1fr) auto;
    min-height: calc(100dvh - 20px);
  }

  .status-bar,
  .composer,
  .settings {
    padding: 12px;
  }

  .status-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  h1 {
    font-size: clamp(2rem, 15vw, 3.7rem);
  }

  h2 {
    font-size: 1.25rem;
  }

  .system-state {
    width: 100%;
    min-width: 0;
  }

  .core-panel {
    min-height: 210px;
  }

  .readouts {
    right: 10px;
    bottom: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: calc(100% - 20px);
  }

  .readouts div {
    min-width: 0;
    padding: 8px;
  }

  .readouts strong,
  .readouts select {
    font-size: 0.78rem;
  }

  .chat-log {
    min-height: 260px;
    padding: 12px;
  }

  .message {
    max-width: 100%;
    padding: 12px;
  }

  .composer {
    grid-template-columns: 48px minmax(0, 1fr) 48px 72px;
    gap: 8px;
  }

  .send-button {
    grid-column: auto;
  }

  .gate-row {
    grid-template-columns: 1fr;
  }

  .settings {
    min-height: auto;
  }
}
