:root {
  --page-bg: #e8f4fd;
  --page-bg-end: #d0e8f8;
  --surface: rgba(250, 253, 255, 0.94);
  --surface-strong: #f4fbff;
  --ink: #0b2a43;
  --muted: #315f82;
  --line: rgba(34, 119, 170, 0.18);
  --brand: #16618f;
  --brand-strong: #0d4c72;
  --brand-hover: #1b668f;
  --brand-shadow: #124663;
  --warm: #ffaa00;
  --danger: #a24436;
  --input-bg: rgba(255, 255, 255, 0.88);
  --button-soft: rgba(34, 119, 170, 0.1);
  --button-soft-hover: rgba(34, 119, 170, 0.18);
  --button-soft-shadow: rgba(34, 119, 170, 0.28);
  --button-ghost: rgba(255, 255, 255, 0.82);
  --button-ghost-hover: rgba(208, 232, 248, 0.95);
  --button-ghost-shadow: rgba(34, 119, 170, 0.24);
  --focus-ring: rgba(34, 119, 170, 0.22);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --page-bg: #0f1b2d;
  --page-bg-end: #1a2d45;
  --surface: rgba(20, 38, 60, 0.94);
  --surface-strong: #102137;
  --ink: #f7fbff;
  --muted: #dbeaff;
  --line: rgba(170, 196, 221, 0.2);
  --brand: #eaf4ff;
  --brand-strong: #ffffff;
  --brand-hover: #cfe5ff;
  --brand-shadow: #5d7fa8;
  --warm: #ffe566;
  --danger: #ff9a88;
  --input-bg: rgba(15, 27, 45, 0.78);
  --button-soft: rgba(170, 196, 221, 0.12);
  --button-soft-hover: rgba(170, 196, 221, 0.2);
  --button-soft-shadow: rgba(10, 18, 30, 0.72);
  --button-ghost: rgba(170, 196, 221, 0.08);
  --button-ghost-hover: rgba(170, 196, 221, 0.16);
  --button-ghost-shadow: rgba(10, 18, 30, 0.7);
  --focus-ring: rgba(160, 185, 255, 0.38);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: linear-gradient(180deg, var(--page-bg) 0%, var(--page-bg-end) 100%);
  font-family: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] body {
  background: linear-gradient(180deg, var(--page-bg) 0%, var(--page-bg-end) 100%);
}

body {
  padding: 30px 32px 46px;
}

body.auth-modal-open {
  overflow: hidden;
}

.app-shell {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.topbar,
.status-band,
.beta-banner,
.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar,
.status-band,
.beta-banner,
.surface {
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 36px;
  align-items: center;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.brand-mark {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-top: 9px;
  border-radius: 6px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  font: 700 2rem/1.05 Georgia, "Times New Roman", serif;
}

h2 {
  font: 700 1.05rem/1.2 Georgia, "Times New Roman", serif;
}

.account-strip {
  display: grid;
  gap: 18px;
  justify-items: end;
}

.auth-status {
  margin: 0;
  text-align: right;
  color: var(--muted);
  line-height: 1.45;
}

.account-actions,
.toolbar-row,
.footer-actions,
.inline-row,
.status-topline,
.status-stats,
.section-heading {
  display: flex;
  align-items: center;
}

.account-actions,
.toolbar-row,
.footer-actions,
.inline-row {
  gap: 12px;
}

.account-actions,
.toolbar-row {
  flex-wrap: wrap;
}

.status-topline,
.status-stats,
.section-heading {
  justify-content: space-between;
}

.status-topline,
.status-stats {
  gap: 12px;
}

.status-message {
  min-height: 42px;
  margin: 16px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.beta-banner {
  border-color: rgba(255, 229, 102, 0.46);
  background: rgba(255, 229, 102, 0.16);
  color: var(--brand-strong);
  font-weight: 900;
  line-height: 1.45;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(27, 25, 22, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand) 0%, var(--warm) 100%);
  transition: width 150ms ease;
}

.status-stats {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.idle {
  background: rgba(100, 93, 83, 0.12);
  color: var(--muted);
}

.badge.ready,
.badge.starting,
.badge.running {
  background: rgba(21, 109, 93, 0.14);
  color: var(--brand-strong);
}

.badge.countdown {
  background: rgba(198, 125, 56, 0.16);
  color: #8a521a;
}

.badge.complete {
  background: rgba(68, 141, 79, 0.16);
  color: #2f7040;
}

.badge.error {
  background: rgba(162, 68, 54, 0.14);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr);
  gap: 24px;
}

.surface {
  display: grid;
  gap: 22px;
}

.surface-compact {
  align-content: start;
}

.section-heading {
  gap: 24px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  text-align: right;
  max-width: 36ch;
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 10px;
}

.field-note,
label,
.check-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.field-note {
  margin: 0;
  line-height: 1.5;
}

.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

textarea,
input,
button {
  font: 600 0.95rem/1.2 "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(66, 52, 33, 0.18);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 300px;
  padding: 18px;
  resize: vertical;
  font: 500 0.92rem/1.55 Consolas, "Courier New", monospace;
}

input:focus,
textarea:focus,
button:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.inline-row input {
  flex: 1 1 auto;
}

.toolbar-row {
  flex-wrap: wrap;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 46px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(66, 52, 33, 0.18);
  background: var(--input-bg);
}

.segment {
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment.active {
  background: rgba(21, 109, 93, 0.12);
  color: var(--brand-strong);
}

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

.estimate-band {
  min-height: 112px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(198, 125, 56, 0.2);
  background: var(--surface-strong);
}

.estimate-band p {
  margin: 0;
  line-height: 1.5;
  color: var(--muted);
}

.estimate-note {
  margin-top: 10px !important;
  font-size: 0.84rem;
}

button {
  position: relative;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.primary-button {
  background: var(--brand);
  color: #f8fff9;
}

:root[data-theme="dark"] .primary-button {
  color: #0f1b2d;
}

.primary-button:not(:disabled):hover {
  background: var(--brand-hover);
  box-shadow: 0 4px 0 var(--brand-shadow);
  transform: translateY(-2px);
}

.secondary-button {
  background: var(--button-soft);
  border-color: var(--button-soft);
  color: var(--ink);
}

.secondary-button:not(:disabled):hover {
  background: var(--button-soft-hover);
  border-color: var(--button-soft-hover);
  box-shadow: 0 4px 0 var(--button-soft-shadow);
  transform: translateY(-2px);
}

.ghost-button {
  background: var(--button-ghost);
  border-color: rgba(66, 52, 33, 0.14);
  color: var(--ink);
}

.ghost-button:not(:disabled):hover {
  background: var(--button-ghost-hover);
  border-color: var(--button-ghost-hover);
  box-shadow: 0 4px 0 var(--button-ghost-shadow);
  transform: translateY(-2px);
}

.segment:not(:disabled):hover {
  background: var(--button-soft-hover);
  color: var(--brand-strong);
  box-shadow: inset 0 -3px 0 var(--button-soft-shadow);
}

.segment.active:not(:disabled):hover {
  box-shadow: inset 0 -3px 0 var(--brand);
}

button:not(:disabled):active {
  box-shadow: none;
  transform: translateY(1px);
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 12, 22, 0.62);
  backdrop-filter: blur(10px);
}

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

.auth-modal-card {
  position: relative;
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(4, 10, 18, 0.36);
}

.auth-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  background: var(--button-soft);
  color: var(--ink);
}

.google-mark {
  width: 50px;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ffffff;
  color: #1a73e8;
  font: 800 1.45rem/1 "Segoe UI", Arial, sans-serif;
  box-shadow: 0 8px 28px rgba(10, 18, 30, 0.16);
}

.auth-modal-card h2 {
  font-size: 1.55rem;
}

.auth-modal-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-modal-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.theme-switch {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px 0 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
}

.theme-switch:not(:disabled):hover {
  background: var(--button-ghost);
  box-shadow: 0 4px 0 var(--button-ghost-shadow);
  transform: translateY(-2px);
}

.theme-switch:not(:disabled):hover .switch-visual {
  background: #bddcf2;
  border-color: #83b8dd;
}

:root[data-theme="dark"] .theme-switch:not(:disabled):hover .switch-visual {
  background: #203856;
  border-color: #416181;
}

.theme-switch:not(:disabled):active {
  box-shadow: none;
  transform: translateY(1px);
}

.switch-label {
  min-width: 76px;
  color: var(--brand-strong);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: left;
}

.switch-visual {
  position: relative;
  flex: 0 0 auto;
  width: 100px;
  height: 54px;
  border-radius: 999px;
  background: #d0e8f8;
  border: 1px solid #a0c8e8;
  overflow: hidden;
  transition: background 300ms ease, border-color 300ms ease;
}

:root[data-theme="dark"] .switch-visual {
  background: #1a2d45;
  border-color: #2a4060;
}

.theme-track-canvas {
  position: absolute;
  inset: 0;
  width: 100px;
  height: 54px;
  border-radius: 999px;
  pointer-events: none;
}

.switch-thumb {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: radial-gradient(circle at 38% 38%, #fffde0, #ffe566, #ffaa00);
  box-shadow: 0 0 20px 10px rgba(255, 210, 60, 0.6), 0 0 50px 20px rgba(255, 180, 0, 0.22);
  transition: transform 450ms cubic-bezier(.4, 0, .2, 1), box-shadow 450ms ease, background 450ms ease;
}

:root[data-theme="dark"] .switch-thumb {
  background: radial-gradient(circle at 38% 38%, #e8f0ff, #c8d8ff, #8899cc);
  box-shadow: 0 0 20px 10px rgba(160, 180, 255, 0.6), 0 0 50px 20px rgba(120, 150, 255, 0.22);
}

:root:not([data-theme="dark"]) .switch-thumb {
  transform: translateX(46px);
}

.theme-thumb-canvas {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: block;
  pointer-events: none;
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: var(--brand-strong);
  font-weight: 700;
}

.feedback-link {
  width: min(100%, 460px);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--brand);
  color: #f8fff9;
  font-weight: 900;
  text-decoration: none;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

:root[data-theme="dark"] .feedback-link {
  color: #0f1b2d;
}

.feedback-link:hover {
  background: var(--brand-hover);
  box-shadow: 0 4px 0 var(--brand-shadow);
  transform: translateY(-2px);
}

.feedback-note {
  color: var(--muted) !important;
  font-size: 0.86rem;
}

.footer-arrow {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--button-soft);
  color: var(--brand-strong);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.extension-link-slot {
  width: min(100%, 420px);
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.footer-actions button {
  flex: 1 1 auto;
}

@media (max-width: 1080px) {
  .topbar,
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-strip {
    justify-items: start;
  }

  .auth-status,
  .section-heading p {
    text-align: left;
  }

  .section-heading {
    display: grid;
    gap: 6px;
  }
}

@media (max-width: 720px) {
  body {
    padding: 16px;
  }

  .topbar,
  .status-band,
  .beta-banner,
  .surface {
    padding: 18px;
  }

  .input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-row,
  .footer-actions,
  .auth-modal-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .inline-row,
  .footer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  h1 {
    font-size: 1.72rem;
  }
}
