:root {
  color: #17191b;
  background: #f4f5f4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  --ink: #17191b;
  --muted: #6d7374;
  --line: #dfe2e0;
  --paper: #ffffff;
  --soft: #f1f2f1;
  --coral: #ef4a37;
  --mint: #1aa18a;
  --yellow: #f0bd3c;
  --danger: #c92c2c;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; }

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  color: #fff;
  background: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 30px;
  font-size: 19px;
  font-weight: 760;
}

.brand-mark { position: relative; width: 26px; height: 21px; display: inline-block; }
.brand-mark i, .brand-mark b { position: absolute; display: block; height: 8px; border-radius: 2px; }
.brand-mark i { width: 22px; top: 1px; left: 0; background: var(--coral); }
.brand-mark b { width: 18px; right: 0; bottom: 1px; background: var(--mint); }

.primary-nav { display: grid; gap: 5px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: #b9bebc;
  background: transparent;
  text-align: left;
}
.nav-item:hover:not(:disabled), .nav-item.is-active { color: #fff; background: #2a2d2e; }
.nav-symbol { width: 20px; font-size: 23px; line-height: 1; text-align: center; }
.pulse-symbol { height: 9px; border-left: 2px solid; border-right: 2px solid; position: relative; }
.pulse-symbol::after { content: ""; position: absolute; left: 4px; right: 4px; top: 3px; border-top: 2px solid; }

.sidebar-footer { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #383c3d; }
.connection-state { display: flex; align-items: center; gap: 8px; color: #adb3b0; font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #777; }
.connection-state.is-connected .status-dot { background: var(--mint); }
.text-command { margin-top: 14px; padding: 0; border: 0; color: #adb3b0; background: none; font-size: 12px; }
.text-command:hover { color: #fff; }

.main-content { min-width: 0; background: var(--paper); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 108px;
  padding: 24px clamp(28px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 3px 0 0; font-size: 23px; line-height: 1.2; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 750; }
.api-state { padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 12px; }
.api-state.is-online { color: #087360; border-color: #9bd4ca; background: #eef9f7; }

.pairing-view, .new-analysis, .session-view { padding: clamp(32px, 6vw, 78px) clamp(28px, 7vw, 96px); }
.pairing-panel, .analysis-form, .session-view > * { max-width: 900px; }
.pairing-panel { max-width: 560px; }

.section-heading { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 34px; }
.section-index { padding-top: 5px; color: var(--coral); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 750; }
.section-heading h2 { margin: 0; font-size: 31px; line-height: 1.15; }
.section-heading p { margin: 7px 0 0; color: var(--muted); }
.compact-heading { margin-bottom: 0; }

form { display: grid; gap: 11px; }
label, legend { color: #44494a; font-size: 13px; font-weight: 680; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #cfd3d1;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus, select:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(239, 74, 55, 0.12); }
#pairing-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 23px; letter-spacing: 0; }
#device-name { margin-bottom: 12px; }

.primary-command, .danger-command {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  background: var(--ink);
  font-weight: 720;
  white-space: nowrap;
}
.primary-command:hover { background: #343839; }
.danger-command { color: var(--danger); border-color: #e3b5b5; background: #fff; }
.danger-command:hover { background: #fff4f4; }
.pairing-panel .primary-command { justify-self: start; min-width: 150px; margin-top: 8px; }

.analysis-form { gap: 14px; }
.url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.options-band {
  display: grid;
  grid-template-columns: minmax(190px, 0.65fr) minmax(280px, 1fr);
  gap: 32px;
  margin-top: 22px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.select-field { display: grid; gap: 9px; }
.mode-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.mode-field legend { margin-bottom: 9px; }
.segmented-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3px; border-radius: 6px; background: #eaedeb; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control label, .segmented-control button {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  color: #606666;
  background: transparent;
  text-align: center;
  font-size: 13px;
  font-weight: 650;
}
.segmented-control input:checked + label, .segmented-control button.is-selected { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(20, 25, 24, 0.12); }

.form-error { margin: 8px 0 0; padding: 12px 14px; border-left: 3px solid var(--danger); color: #9c2020; background: #fff4f4; font-size: 14px; }
.session-view { padding-top: clamp(32px, 5vw, 62px); }
.session-header { display: flex; align-items: flex-start; justify-content: space-between; max-width: 900px; margin-bottom: 42px; }
.icon-command { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 24px; line-height: 1; }
.icon-command:hover { background: var(--soft); }

.progress-track { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.progress-step { position: relative; min-width: 0; padding-right: 12px; }
.progress-step::before { content: ""; position: absolute; top: 15px; left: 31px; right: 0; height: 2px; background: var(--line); }
.progress-step:last-child::before { display: none; }
.step-mark { position: relative; display: grid; place-items: center; width: 31px; height: 31px; border: 2px solid var(--line); border-radius: 50%; color: var(--muted); background: #fff; font-size: 11px; font-weight: 800; z-index: 1; }
.step-label { display: block; margin-top: 11px; color: var(--muted); font-size: 13px; }
.progress-step.is-complete::before { background: var(--mint); }
.progress-step.is-complete .step-mark { color: #fff; border-color: var(--mint); background: var(--mint); }
.progress-step.is-active .step-mark { color: #fff; border-color: var(--coral); background: var(--coral); }
.progress-step.is-active .step-label { color: var(--ink); font-weight: 720; }

.session-actions { margin-top: 42px; padding-top: 20px; border-top: 1px solid var(--line); }
.result-intro h3 { max-width: 760px; margin: 0; font-size: 26px; line-height: 1.3; }
.result-intro p { max-width: 780px; margin: 14px 0 0; color: var(--muted); line-height: 1.7; }
.key-points { margin-top: 32px; }
.key-points h3 { margin: 0 0 12px; font-size: 15px; }
.key-points ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.key-points li { position: relative; padding-left: 21px; line-height: 1.5; }
.key-points li::before { content: ""; position: absolute; left: 0; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 36px 0 18px; }
.result-modes { width: min(440px, 100%); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.language-pair { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.timeline { display: grid; gap: 10px; }
.timeline-entry { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.timeline-meta { color: var(--coral); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 720; }
.timeline-meta span { display: block; margin-top: 6px; color: var(--muted); font-family: inherit; font-weight: 600; }
.timeline-copy { display: grid; gap: 8px; min-width: 0; line-height: 1.55; }
.timeline-copy p { margin: 0; overflow-wrap: anywhere; }
.timeline-copy .translation { color: #555b5a; font-weight: 620; }
.visual-note { padding: 10px 12px; border-left: 3px solid var(--mint); color: #35615a; background: #eef8f6; font-size: 13px; }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 5; height: auto; padding: 12px 16px; flex-direction: row; align-items: center; border-bottom: 1px solid #323637; }
  .brand { padding: 0; margin-right: auto; font-size: 17px; }
  .primary-nav { display: flex; margin-left: 16px; }
  .nav-item { width: 42px; min-height: 40px; justify-content: center; padding: 0; font-size: 0; }
  .nav-symbol { font-size: 22px; }
  .sidebar-footer { display: none; }
  .topbar { min-height: 88px; padding: 18px 20px; }
  .topbar h1 { font-size: 20px; }
  .api-state { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pairing-view, .new-analysis, .session-view { padding: 32px 20px 46px; }
  .section-heading { margin-bottom: 26px; }
  .section-heading h2 { font-size: 25px; }
  .url-row { grid-template-columns: 1fr; }
  .options-band { grid-template-columns: 1fr; gap: 20px; }
  .progress-track { grid-template-columns: 1fr; gap: 0; }
  .progress-step { display: grid; grid-template-columns: 40px 1fr; min-height: 55px; padding: 0; }
  .progress-step::before { top: 31px; bottom: 0; left: 15px; width: 2px; height: auto; }
  .step-label { margin: 7px 0 0 7px; }
  .result-toolbar { align-items: stretch; flex-direction: column; }
  .timeline-entry { grid-template-columns: 1fr; gap: 10px; }
  .timeline-meta span { display: inline; margin: 0 0 0 8px; }
}
