:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #172235;
  --border: #263246;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --teal: #00b1ae;
  --teal-light: #34d1ce;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 20px 55px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.drawer-open { overflow: hidden; }
body.locked { overflow: hidden; }
body.locked > .app-header,
body.locked > .app-shell { visibility: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.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; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, .94);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand span { display: grid; line-height: 1.05; }
.brand strong { font-size: 19px; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.button-label-short { display: none; }
.storage-status { color: var(--muted); font-size: 12px; }
.storage-status.saving { color: var(--warning); }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
  color: var(--text);
  text-decoration: none;
}
.button.primary { background: var(--teal); color: #041817; }
.button.primary:hover { background: var(--teal-light); }
.button.secondary { background: var(--surface); border-color: var(--border); }
.button.secondary:hover { border-color: var(--teal); color: var(--teal-light); }
.lock-button { width: 42px; padding: 0; font-size: 16px; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 28px; }
.text-button { border: 0; background: transparent; color: var(--teal-light); font-weight: 800; white-space: nowrap; }

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.stage-sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: #0e1727;
}
.project-label { padding: 5px 10px 18px; display: grid; }
.project-label span { color: var(--teal-light); font-size: 10px; font-weight: 850; letter-spacing: .12em; }
.project-label strong { margin-top: 7px; font-size: 20px; }
.project-label small { margin-top: 3px; color: var(--muted); }
.stage-navigation { display: grid; gap: 5px; }
.stage-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.stage-button:hover, .stage-button.active { background: rgba(0, 177, 174, .11); color: var(--text); }
.stage-number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--teal-light); font-size: 11px; font-weight: 850; }
.stage-copy { min-width: 0; display: grid; }
.stage-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.stage-copy small, .stage-percent { font-size: 10px; color: var(--muted); }

.workspace { width: min(1050px, 100%); padding: 34px 36px 70px; margin: 0 auto; }
.project-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.project-header h1 { margin: 7px 0 5px; font-size: clamp(30px, 4vw, 44px); line-height: 1.08; }
.project-header p { max-width: 720px; margin: 0; color: var(--muted); }
.eyebrow { color: var(--teal-light) !important; font-size: 10px; font-weight: 850; letter-spacing: .13em; }
.project-progress { flex: 0 0 auto; display: grid; text-align: right; }
.project-progress strong { font-size: 32px; line-height: 1; }
.project-progress span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.progress-track { height: 8px; margin: 22px 0 18px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--teal); transition: width .2s ease; }

.reminder-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 13px 16px; border: 1px solid rgba(245, 158, 11, .35); border-radius: 12px; background: rgba(245, 158, 11, .08); }
.reminder-banner div { display: grid; }
.reminder-banner span { color: var(--muted); font-size: 12px; }

.stage-summary { margin-bottom: 14px; padding: 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); }
.stage-summary header { display: flex; justify-content: space-between; gap: 16px; }
.stage-summary h2 { margin: 3px 0 7px; font-size: 24px; }
.stage-summary p { margin: 0; color: var(--muted); }
.stage-summary .stage-result { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); color: var(--text); font-size: 13px; }
.stage-summary .stage-result strong { color: var(--teal-light); }

.task-toolbar { display: grid; grid-template-columns: 1fr 200px; gap: 10px; margin-bottom: 12px; }
.search-field input, .task-toolbar select, .task-controls input, .task-controls select, .note-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-field input, .task-toolbar select, .task-controls input, .task-controls select { min-height: 44px; padding: 9px 12px; }
.search-field input:focus, .task-toolbar select:focus, .task-controls input:focus, .task-controls select:focus, .note-field textarea:focus { border-color: var(--teal); }
.task-list { display: grid; gap: 9px; }
.task-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}
.task-row:hover { border-color: #3b4a61; }
.task-row.completed .task-title { color: var(--muted); text-decoration: line-through; }
.task-checkbox { appearance: none; width: 42px; height: 42px; margin: 0; border: 1px solid #3b4a61; border-radius: 11px; background: var(--surface-2); display: grid; place-items: center; }
.task-checkbox::after { content: "✓"; color: transparent; font-size: 20px; font-weight: 900; }
.task-checkbox:checked { border-color: var(--teal); background: var(--teal); }
.task-checkbox:checked::after { color: #041817; }
.task-open { min-width: 0; padding: 3px 0; border: 0; background: transparent; color: inherit; text-align: left; }
.task-title { display: block; font-weight: 780; }
.task-description { display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.tag { padding: 4px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 10px; }
.tag.in_progress { color: #bae6fd; background: rgba(56, 189, 248, .1); }
.tag.completed { color: #86efac; background: rgba(34, 197, 94, .1); }
.tag.overdue { color: #fca5a5; background: rgba(239, 68, 68, .1); }
.empty-tasks { padding: 35px; border: 1px dashed var(--border); border-radius: 13px; color: var(--muted); text-align: center; }
.local-note { margin-top: 18px; color: var(--muted); font-size: 11px; text-align: center; }
.storage-status.offline { color: var(--warning); }
.storage-status.synced { color: var(--success); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 12, .72); backdrop-filter: blur(3px); }
.task-drawer { position: fixed; z-index: 70; inset: 0 0 0 auto; width: min(620px, 100%); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #0f1828; border-left: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(102%); transition: transform .2s ease; }
.task-drawer.open { transform: translateX(0); }
.drawer-header, .drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-header span { color: var(--teal-light); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.drawer-header h2 { margin: 3px 0 0; font-size: 21px; line-height: 1.2; }
.drawer-body { min-height: 0; overflow: auto; padding: 22px; }
.task-intro { margin-top: 0; color: var(--muted); }
.task-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 20px 0; }
.task-controls label, .note-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.detail-block { padding: 15px 0; border-top: 1px solid var(--border); }
.detail-block h3 { margin: 0 0 7px; font-size: 14px; }
.detail-block p, .detail-block li { color: #c4cad3; font-size: 13px; }
.detail-block p { margin: 0; }
.detail-block ul, .detail-block ol { margin: 0; padding-left: 21px; }
.detail-block li + li { margin-top: 5px; }
.detail-block.example { margin: 5px 0; padding: 14px; border: 1px solid rgba(0, 177, 174, .25); border-radius: 11px; background: rgba(0, 177, 174, .06); }
.note-field { margin-top: 18px; font-size: 13px; color: var(--text); }
.note-field textarea { min-height: 160px; padding: 12px; resize: vertical; }
.note-field small { color: var(--muted); font-size: 10px; font-weight: 500; }
.drawer-footer { border-top: 1px solid var(--border); border-bottom: 0; }
.drawer-footer .primary { flex: 1; }
.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: 380px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 15%, rgba(0, 177, 174, .12), transparent 34%), var(--bg);
}
.access-gate[hidden] { display: none; }
.access-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.access-card > img { width: 70px; height: 70px; border-radius: 15px; }
.access-card h1 { margin: 8px 0 4px; font-size: 34px; }
.access-card > p:not(.eyebrow, .access-error) { margin: 0 0 22px; color: var(--muted); }
.access-card label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.access-card input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); outline: none; }
.access-card input:focus { border-color: var(--teal); }
.access-card .button { width: 100%; margin-top: 12px; }
.access-card small { display: block; margin-top: 14px; color: var(--muted); text-align: center; }
.access-error { margin: 8px 0 0; color: #fca5a5; font-size: 12px; }

@media (max-width: 900px) {
  .app-shell { display: block; }
  .stage-sidebar { position: sticky; top: 72px; z-index: 20; width: 100%; height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .project-label { display: none; }
  .stage-navigation { display: flex; overflow-x: auto; gap: 7px; scrollbar-width: thin; }
  .stage-button { flex: 0 0 205px; min-height: 52px; }
  .workspace { padding: 25px 18px 60px; }
}

@media (max-width: 620px) {
  .app-header { height: 64px; padding: 0 13px; }
  .brand img { width: 36px; height: 36px; }
  .brand strong { font-size: 17px; }
  .storage-status { display: none; }
  .header-actions .button { min-height: 38px; padding: 7px 10px; font-size: 12px; }
  .button-label-full { display: none; }
  .button-label-short { display: inline; }
  .stage-sidebar { top: 64px; }
  .project-header { align-items: flex-start; }
  .project-header h1 { font-size: 30px; }
  .project-header p { font-size: 13px; }
  .project-progress { display: none; }
  .task-toolbar { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: 42px minmax(0, 1fr); }
  .task-meta { grid-column: 2; justify-content: flex-start; }
  .reminder-banner { align-items: flex-start; }
  .task-controls { grid-template-columns: 1fr; }
  .task-drawer { inset: 0; width: 100%; }
  .drawer-footer { padding: 10px; }
  .drawer-footer .secondary { padding-inline: 8px; font-size: 11px; }
  .access-card { padding: 26px 22px; }
}
