:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: #0b0f17;
  --panel-2: #101722;
  --ink: #f4f7fb;
  --muted: #8e99aa;
  --line: #202a38;
  --blue: #84a9ff;
  --blue-2: #243a66;
  --green: #6fd6a5;
  --red: #f47c8a;
  --amber: #d9b36c;
  --white-soft: #d8e2f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(circle at top left, rgba(34, 53, 87, 0.35), transparent 34rem), var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Inter", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--line);
  background: #10141d;
  color: var(--white-soft);
  min-height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #44536a;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 58px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(300px, 0.85fr) minmax(190px, 0.5fr);
  gap: 16px;
  align-items: center;
  padding: 0 20px;
  background: rgba(4, 6, 10, 0.92);
  border-bottom: 1px solid #18202d;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: 1.4px;
}

.brand small,
.clock-grid,
.panel-head span,
.session-head span {
  color: var(--muted);
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #243044;
  background: #f4f4f2;
}

nav {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.nav-button {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  background: transparent;
}

.nav-button.active {
  color: var(--ink);
  border-color: var(--blue-2);
  background: #0c1423;
}

.settings-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.settings-cluster button {
  white-space: nowrap;
}

.account-status {
  color: var(--muted);
  font-size: 11px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clock-grid {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  font-family: "Consolas", monospace;
  font-size: 12px;
}

main {
  padding: 20px;
}

.auth-gate {
  position: fixed;
  inset: 58px 0 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: rgba(5, 7, 11, 0.9);
  backdrop-filter: blur(14px);
}

body:has(#auth-gate:not([hidden])) main {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.auth-gate[hidden] {
  display: none;
}

.auth-panel {
  width: min(100%, 640px);
  background: linear-gradient(180deg, rgba(16, 22, 34, 0.98), rgba(8, 12, 20, 0.98));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.38);
}

.auth-hero {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.auth-logo {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #263449;
  background: #f4f4f2;
}

.auth-hero span {
  display: block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.auth-hero h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.auth-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 44rem;
}

.auth-message {
  color: var(--white-soft);
  margin-bottom: 14px;
  border: 1px solid rgba(132, 169, 255, 0.22);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(132, 169, 255, 0.08);
}

.auth-message.warning {
  color: var(--amber);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.auth-form[hidden] {
  display: none;
}

.auth-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b12;
  padding: 14px;
}

.auth-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.auth-section strong,
.auth-section-head strong {
  color: var(--white-soft);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  font-size: 12px;
}

.name-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-panel button {
  background: linear-gradient(180deg, #99b8ff, #6f94ee);
  color: #061020;
  border-color: #91aef1;
  font-weight: 800;
}

.auth-panel .text-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.auth-panel button:hover {
  border-color: #b6c9ff;
}

.config-input {
  min-height: 230px;
  font-family: "Consolas", monospace;
  text-transform: none;
  letter-spacing: 0;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.provider-grid button {
  min-height: 40px;
}

.account-promises {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.account-promises span {
  border: 1px solid rgba(132, 169, 255, 0.16);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
  text-align: center;
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

select,
input,
textarea {
  width: 100%;
  color: var(--ink);
  background: #0a0e15;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 82px;
  resize: vertical;
  text-transform: none;
  letter-spacing: 0;
}

.primary-action,
.accent {
  background: linear-gradient(180deg, #99b8ff, #6f94ee);
  color: #061020;
  border-color: #91aef1;
  font-weight: 700;
}

.workspace {
  display: none;
}

.workspace.active {
  display: block;
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.session-card,
.panel {
  background: linear-gradient(180deg, rgba(16, 22, 34, 0.98), rgba(8, 12, 20, 0.98));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.24);
}

.session-card {
  padding: 16px;
  min-width: 0;
}

.session-card.featured {
  border-color: rgba(111, 148, 238, 0.58);
}

.asia {
  box-shadow: inset 0 3px 0 rgba(101, 169, 255, 0.95);
}

.london {
  box-shadow: inset 0 3px 0 rgba(244, 124, 138, 0.95);
}

.newyork {
  box-shadow: inset 0 3px 0 rgba(142, 153, 170, 0.95);
}

.session-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

h3 {
  font-size: 13px;
  color: var(--blue);
}

.metric-table {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.metric-row {
  display: grid;
  grid-template-columns: 1.15fr 0.8fr 0.8fr 0.55fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-name {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--white-soft);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.metric-row input {
  min-height: 30px;
  padding: 5px 7px;
  font-family: "Consolas", monospace;
}

.delta {
  font-family: "Consolas", monospace;
  text-align: right;
}

.delta.up {
  color: var(--green);
}

.delta.down {
  color: var(--red);
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.lower-grid {
  display: block;
  margin-top: 16px;
}

.panel {
  padding: 16px;
}

.dropzone {
  min-height: 118px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed #3c4657;
  border-radius: 8px;
  color: var(--white-soft);
  background: #070b12;
  cursor: pointer;
  margin-top: 10px;
}

.dropzone input {
  display: none;
}

.dropzone small {
  display: block;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 6px;
}

.session-capture {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b12;
  padding: 10px;
  margin: 12px 0;
  cursor: text;
}

.session-capture:focus-within,
.session-capture:focus,
.session-capture.armed {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 2px rgba(132, 169, 255, 0.08);
  outline: none;
}

.capture-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.capture-head strong {
  color: var(--white-soft);
}

.mini-dropzone {
  min-height: 118px;
  place-items: center;
  text-align: center;
  border: 1px dashed #3c4657;
  border-radius: 6px;
  color: var(--white-soft);
  background: #05080d;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  padding: 14px;
  align-content: center;
}

.mini-dropzone input {
  display: none;
}

.mini-dropzone span {
  font-weight: 800;
}

.mini-dropzone small {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.session-preview {
  display: none;
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  background: #030508;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 8px 0;
}

.reader-message {
  display: block;
  min-height: 16px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}

.reader-message.success {
  color: var(--green);
  font-weight: 800;
}

.reader-message.warning {
  color: var(--amber);
}

#screenshot-preview {
  display: none;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #030508;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
}

#ocr-text {
  min-height: 96px;
  margin-bottom: 10px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions button {
  flex: 1 1 150px;
}

.run-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #070b12;
  padding: 7px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
}

.step.active {
  color: #061020;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 800;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.score-row div {
  border: 1px solid var(--line);
  background: #080d15;
  border-radius: 8px;
  padding: 12px;
}

.score-row small {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.score-row strong {
  display: block;
  font-size: 15px;
}

.settings-panel {
  max-width: 980px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080d15;
  padding: 14px;
}

.settings-card small {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.settings-card strong {
  display: block;
  color: var(--white-soft);
  font-size: 15px;
  margin-bottom: 10px;
}

.settings-card p {
  color: var(--muted);
}

.danger-action {
  border-color: rgba(244, 124, 138, 0.55);
  color: #ffd6db;
}

#regime-pill {
  padding: 4px 9px;
  border: 1px solid #405073;
  border-radius: 999px;
  color: var(--blue);
  background: #0b1322;
  font-size: 12px;
}

.analysis-list {
  margin: 0;
  padding-left: 18px;
  color: var(--white-soft);
}

.analysis-list li {
  margin-bottom: 10px;
}

.journal-form {
  display: grid;
  grid-template-columns: 150px 150px 150px 1fr;
  gap: 10px;
}

.journal-form textarea,
.attachment-label,
.journal-form button {
  grid-column: 1 / -1;
}

.attachment-label {
  text-transform: none;
  letter-spacing: 0;
  color: var(--white-soft);
}

.export-actions {
  margin-top: 12px;
}

.journal-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.journal-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #080d15;
}

.journal-entry strong {
  display: block;
  margin-bottom: 6px;
}

.journal-entry img {
  width: min(100%, 340px);
  max-height: 210px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  background: #030508;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rule-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #080d15;
}

.reference-panel {
  padding: 18px;
}

.reference-section-label {
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  margin: 12px 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid #151d2a;
  border-radius: 8px;
  overflow: hidden;
}

.definition-card,
.regime-card {
  min-height: 148px;
  background: #080d15;
  border-right: 1px solid #151d2a;
  border-bottom: 1px solid #151d2a;
  padding: 16px;
}

.definition-card h3,
.regime-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.definition-card h3 span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.definition-card strong,
.regime-card strong {
  display: block;
  color: var(--white-soft);
  margin-bottom: 8px;
  font-size: 13px;
}

.definition-card p,
.regime-card p {
  color: #b8c3d2;
  margin-bottom: 10px;
}

.definition-card small,
.regime-card small {
  color: #697589;
}

.blue-line h3 {
  color: #65a9ff;
}

.blue-line h3 span {
  background: #65a9ff;
}

.down-line h3 {
  color: #d86138;
}

.down-line h3 span {
  background: #d86138;
}

.up-line h3 {
  color: #54c89a;
}

.up-line h3 span {
  background: #54c89a;
}

.skew-line h3 {
  color: #b982ff;
}

.skew-line h3 span {
  background: #b982ff;
}

.skew-ratio-line h3 {
  color: #e1737d;
}

.skew-ratio-line h3 span {
  background: #e1737d;
}

.atm-line h3 {
  color: #9aa7b1;
}

.atm-line h3 span {
  background: #9aa7b1;
}

.convexity-line h3 {
  color: #67d0e0;
}

.convexity-line h3 span {
  background: #67d0e0;
}

.underlying-line h3 {
  color: #ffcc6f;
}

.underlying-line h3 span {
  background: #ffcc6f;
}

.regime-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid #151d2a;
  border-radius: 8px;
  overflow: hidden;
}

.regime-card {
  min-height: 170px;
  border-top: 3px solid transparent;
}

.healthy {
  border-top-color: #54c89a;
}

.healthy h3 {
  color: #6fd6a5;
}

.risk-on {
  border-top-color: #e1737d;
}

.risk-on h3 {
  color: #f47c8a;
}

.panic {
  border-top-color: #d9b36c;
}

.panic h3 {
  color: #d9b36c;
}

.exhaustion {
  border-top-color: #b982ff;
}

.exhaustion h3 {
  color: #c69cff;
}

body.light-theme {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --ink: #0b1018;
  --muted: #5d6878;
  --line: #cbd5e1;
  --blue-2: #9bb8f5;
  --white-soft: #111827;
  background: #f4f6f9;
  color: var(--ink);
}

body.light-theme .topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: #d8dee8;
}

body.light-theme .auth-gate {
  background: rgba(244, 246, 249, 0.82);
}

body.light-theme .auth-panel {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.16);
}

body.light-theme .auth-message {
  color: #111827;
  background: #eef4ff;
  border-color: #c7d7fb;
}

body.light-theme .auth-section {
  background: #ffffff;
}

body.light-theme .auth-hero p,
body.light-theme .account-promises span {
  color: #475569;
}

body.light-theme .auth-section strong,
body.light-theme .auth-section-head strong {
  color: #111827;
}

body.light-theme .account-promises span {
  background: #f8fafc;
  border-color: #d8dee8;
}

body.light-theme .auth-panel button {
  background: linear-gradient(180deg, #99b8ff, #6f94ee);
  color: #061020;
  border-color: #7d9fea;
}

body.light-theme .auth-panel .text-button {
  background: transparent;
  color: #315fb5;
  border-color: transparent;
}

body.light-theme button {
  background: #f8fafc;
  color: #111827;
  border-color: #cbd5e1;
}

body.light-theme button:hover {
  border-color: #94a3b8;
}

body.light-theme .auth-panel button {
  background: linear-gradient(180deg, #99b8ff, #6f94ee);
  color: #061020;
  border-color: #7d9fea;
}

body.light-theme .auth-panel .text-button {
  background: transparent;
  color: #315fb5;
  border-color: transparent;
}

body.light-theme .nav-button.active {
  background: #e9eef9;
  border-color: #9bb8f5;
}

body.light-theme select,
body.light-theme input,
body.light-theme textarea {
  background: #ffffff;
  color: #0b1018;
  border-color: #cbd5e1;
}

body.light-theme .session-card,
body.light-theme .panel {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
}

body.light-theme .asia {
  box-shadow: inset 0 3px 0 rgba(101, 169, 255, 0.95), 0 18px 50px rgba(15, 23, 42, 0.1);
}

body.light-theme .london {
  box-shadow: inset 0 3px 0 rgba(244, 124, 138, 0.95), 0 18px 50px rgba(15, 23, 42, 0.1);
}

body.light-theme .newyork {
  box-shadow: inset 0 3px 0 rgba(142, 153, 170, 0.95), 0 18px 50px rgba(15, 23, 42, 0.1);
}

body.light-theme .session-card.featured {
  border-color: rgba(91, 124, 196, 0.58);
}

body.light-theme .session-capture,
body.light-theme .mini-dropzone,
body.light-theme .dropzone,
body.light-theme .score-row div,
body.light-theme .settings-card,
body.light-theme .journal-entry,
body.light-theme .rule-grid div,
body.light-theme .definition-card,
body.light-theme .regime-card,
body.light-theme .step {
  background: #ffffff;
  color: #111827;
}

body.light-theme .mini-dropzone,
body.light-theme .dropzone {
  border-color: #aab6c7;
}

body.light-theme .session-preview,
body.light-theme #screenshot-preview,
body.light-theme .journal-entry img {
  background: #eef2f7;
}

body.light-theme #regime-pill {
  background: #edf3ff;
  border-color: #9bb8f5;
}

body.light-theme .analysis-list,
body.light-theme .attachment-label,
body.light-theme .metric-name,
body.light-theme .capture-head strong,
body.light-theme .settings-card strong,
body.light-theme .definition-card strong,
body.light-theme .regime-card strong {
  color: #111827;
}

body.light-theme .definition-grid,
body.light-theme .regime-grid,
body.light-theme .definition-card,
body.light-theme .regime-card {
  border-color: #d8dee8;
}

body.light-theme .definition-card p,
body.light-theme .regime-card p {
  color: #334155;
}

body.light-theme .definition-card small,
body.light-theme .regime-card small {
  color: #64748b;
}

body.light-theme .primary-action,
body.light-theme .accent {
  background: linear-gradient(180deg, #99b8ff, #6f94ee);
  color: #061020;
  border-color: #7d9fea;
}

body.light-theme .danger-action {
  color: #9f1239;
  border-color: rgba(190, 18, 60, 0.4);
}

@media (max-width: 980px) {
  .topbar,
  .control-strip,
  .session-grid,
  .journal-form,
  .definition-grid,
  .regime-grid,
  .settings-grid,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    height: auto;
    padding: 14px;
  }

  nav,
  .clock-grid,
  .settings-cluster {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .provider-grid {
    grid-template-columns: 1fr;
  }

  .auth-hero,
  .account-promises {
    grid-template-columns: 1fr;
  }

  .auth-logo {
    width: 58px;
    height: 58px;
  }

  .name-grid {
    grid-template-columns: 1fr;
  }
}
