:root {
  --ink: #ececec;
  --muted: #a3a3a3;
  --line: #333333;
  --paper: #141414;
  --card: #1c1c1c;
  --field: #262626;
  --blue: #7cb3ff;
  --green: #22c55e;
  --green-2: #4ade80;
  --danger: #f87171;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  color-scheme: dark;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.gate {
  min-height: 100svh;
  display: flex;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(700px 380px at 110% 0%, rgba(34, 197, 94, 0.12), transparent 55%),
    var(--paper);
}

.gate .card { margin: auto; flex: none; }
.card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}

.mark { display: flex; gap: 8px; margin-bottom: 18px; }
.mark i {
  width: 14px; height: 14px; border-radius: 50%; display: block;
}
.mark i:first-child { background: var(--blue); }
.mark i:last-child { background: var(--green-2); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}
h1 { margin: 0; font-size: 34px; letter-spacing: -0.04em; }
h2 { margin: 0; font-size: 16px; }
.lede { margin: 8px 0 18px; color: var(--muted); line-height: 1.45; }

label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 12px; }
input, textarea {
  width: 100%;
  font-size: 16px;
  margin-top: 6px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--blue); background: #2e2e2e; box-shadow: 0 0 0 4px rgba(124, 179, 255, 0.16); }
textarea { resize: none; min-height: 48px; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--field);
  color: var(--ink);
}
.btn.primary { background: var(--green); color: #fff; font-weight: 700; width: 100%; }
.btn.primary:hover { filter: brightness(0.96); }
.btn.quiet { background: transparent; color: var(--blue); font-weight: 650; width: 100%; margin-top: 8px; }
.btn.send { width: auto; padding-inline: 16px; }
.error { min-height: 1.2em; margin: 0 0 8px; color: var(--danger); font-size: 14px; }

.desk { min-height: 100dvh; height: 100dvh; display: flex; flex-direction: column; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: #101010;
  color: #fff;
}
.who { display: flex; gap: 10px; align-items: center; flex: none; }
.who strong { white-space: nowrap; }
.who small { display: block; color: #b7c3d6; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.2); }
.dot.on { background: var(--green-2); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25); }
.top { position: relative; }
.top-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.top .btn.quiet { color: #dbe7ff; width: auto; margin: 0; padding: 8px 10px; font-size: 14px; }
.top .btn.quiet.on { background: #2a2a2a; color: #fff; }
.log-pop {
  position: absolute; right: 16px; top: calc(100% - 8px); z-index: 6;
  width: min(420px, calc(100vw - 24px)); max-height: 280px; overflow: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  box-shadow: var(--shadow);
}
.talk { position: relative; }
.transcript-card { width: min(520px, 100%); }
.transcript { max-height: 50dvh; overflow: auto; }
.transcript p { margin: 0 0 8px; font-size: 14px; line-height: 1.4; }
.transcript .you strong { color: var(--blue); }
.transcript .pc strong { color: var(--green-2); }
.transcript .empty { color: var(--muted); }
.mem-item { margin: 0 0 10px; font-size: 13px; line-height: 1.4; }
.mem-item small { color: var(--muted); font-weight: 650; }
.call-start {
  width: 48px; height: 48px; border: 0; border-radius: 50%; flex: none;
  background: var(--green); color: #fff; display: grid; place-items: center;
}
.call-start.on { outline: 4px solid rgba(34, 197, 94, 0.35); }
.call-start svg { width: 20px; height: 20px; fill: currentColor; }
.call-live {
  position: absolute; right: 8px; bottom: calc(100% + 8px); z-index: 4;
  display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap;
  width: max-content; max-width: calc(100vw - 24px);
  background: #2a2a2a; color: #fff; border: 1px solid #3a3a3a; padding: 6px; border-radius: 16px;
  box-shadow: 0 8px 24px rgba(11, 27, 52, 0.28);
}
.call-live[hidden], .transcript-pop[hidden] { display: none !important; }
.call-live.hearing { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.45); }
.call-graph { display: flex; align-items: flex-end; gap: 2px; width: 44px; height: 16px; flex: none; }
.call-graph i { flex: 1; display: block; height: 8%; background: #22c55e; border-radius: 2px; }
.call-timer { margin: 0; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.call-live button { border: 0; border-radius: 999px; background: rgba(255,255,255,0.12); color: #fff; font-weight: 650; font-size: 12px; padding: 6px 8px; width: auto; }
.call-live button.on { background: #f59e0b; color: var(--ink); }
#hang-up { background: #dc2626; }

.layout { flex: 1; min-height: 0; display: flex; padding: 12px; }
.talk, .panel, .card {
  border: 1px solid var(--line);
}
.talk, .panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.talk { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
.log {
  flex: 1;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: min(560px, 88%);
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.you { margin-left: auto; background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.bubble.pc { background: #2a2a2a; border-bottom-left-radius: 6px; }
.step-card { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #222; max-width: 100%; }
.step-think { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.step-tool { font-size: 13px; font-weight: 650; padding: 3px 0; }
.step-tool.live::before { content: "● "; color: var(--green); }
.step-tool.done::before { content: "✓ "; color: var(--green); }
.step-result { margin: 6px 0 0; font-size: 14px; }
.bubble a { color: inherit; }

.composer { position: relative; border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.modes { display: flex; gap: 6px; margin-bottom: 8px; }
.mode {
  border: 0; background: var(--field); border-radius: 999px; padding: 6px 12px; color: var(--muted);
}
.mode.on { background: #3a3a3a; color: #fff; }
.row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
  width: 100%;
}
.composer .row > * {
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 8px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.composer .mic,
.composer .call-start { width: 100%; height: 44px; border-radius: 14px; }
.composer .btn.send { width: 100%; height: 44px; padding: 0 8px; }
#box {
  display: block;
  width: 100%;
  min-height: 88px;
  max-height: 160px;
  overflow-x: hidden;
  overflow-y: auto;
  line-height: 1.45;
  color: var(--ink);
  caret-color: #fff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.attach {
  flex: none;
  margin: 0;
  border: 0;
  background: var(--field);
  color: var(--blue);
  font-weight: 650;
  border-radius: 12px;
  padding: 14px 12px;
  cursor: pointer;
}
.mic {
  width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: var(--green-2); color: #fff; flex: none;
  display: grid; place-items: center;
}
.mic svg { width: 24px; height: 24px; fill: currentColor; }
.mic.live { outline: 6px solid rgba(34, 197, 94, 0.35); }

.panel { padding: 14px; }
.panel-head, .keys, .actions, .typer, .modal-actions {
  display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.stage {
  position: relative;
  background: #101010;
  border-radius: 14px;
  min-height: 180px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.stage.off::after {
  content: "Screen is off";
  color: #9fb0c9;
}
.stage img { width: 100%; display: block; }
.stage.off img { display: none; }
.touch { position: absolute; inset: 0; touch-action: none; }
.keys { margin-top: 10px; }
.keys button, .actions button, .files button, .saved button {
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
}
.actions { margin-top: 10px; }
.danger { color: var(--danger) !important; }
.typer { margin-top: 10px; }
.typer input { margin: 0; }
.file-btn { width: auto; margin: 0; }
.files, .saved { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.files button, .saved button { text-align: left; }
.fold summary { cursor: pointer; font-weight: 700; }
.logs { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.logs li { margin: 4px 0; }

.modal, .banner {
  position: fixed; z-index: 5;
}
.modal {
  inset: 0; background: rgba(0, 0, 0, 0.62);
  display: grid; place-items: center; padding: 16px;
}
.modal[hidden], .banner[hidden], #app[hidden], #login[hidden] { display: none; }
.modal-card { width: min(420px, 100%); }
.screen-card { width: min(980px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.screen-card .btn.quiet { width: auto; margin: 0; }
.screen-card .stage { min-height: 320px; }
.modal-actions .btn { width: auto; }
.banner {
  left: 16px; right: 16px; top: 12px;
  background: #2a2118;
  border: 1px solid #9a6416;
  color: #fdba74;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}
.banner p { margin: 4px 0 0; }
.banner .btn.quiet { width: auto; margin: 0; color: #fdba74; }

@media (max-width: 700px) {
  .top { align-items: center; flex-wrap: nowrap; gap: 8px; padding: 10px 12px; }
  .who strong { font-size: 15px; }
  .top-actions { width: auto; flex: 1; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-end; gap: 2px; }
  .top .btn.quiet { font-size: 13px; padding: 6px 8px; }
  .layout { padding: 8px; }
  .talk { border-radius: 14px; }
  .log { padding: 12px; }
  .composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .composer .row { gap: 6px; }
  .attach { font-size: 13px; }
  .log-pop { left: 8px; right: 8px; width: auto; }
  .call-live { right: 0; left: 0; width: auto; max-width: none; justify-content: flex-start; }
  h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
