:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #eaeae7;
  --border-strong: #ddddd9;
  --ink: #17181a;
  --ink-soft: #6b6b68;
  --ink-faint: #9c9c98;
  --accent: #3d3dff;
  --accent-soft: #eef0ff;
  --green: #17a34a;
  --green-soft: #eafaf0;
  --orange: #e07f13;
  --orange-soft: #fdf3e6;
  --red: #e0393f;
  --red-soft: #fdecec;
  --gray-soft: #f1f1ef;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 20, 20, 0.06);
  --shadow-lg: 0 20px 60px rgba(20, 20, 20, 0.10);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --surface: #17181a;
    --border: #232326;
    --border-strong: #2c2c30;
    --ink: #f2f2f0;
    --ink-soft: #a3a3a0;
    --ink-faint: #6f6f6c;
    --accent: #7b7bff;
    --accent-soft: #1c1c3a;
    --green: #33c26e;
    --green-soft: #0f2a1c;
    --orange: #f5a94e;
    --orange-soft: #2e230f;
    --red: #f2666b;
    --red-soft: #301315;
    --gray-soft: #1e1e21;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e10; --surface: #17181a; --border: #232326; --border-strong: #2c2c30;
  --ink: #f2f2f0; --ink-soft: #a3a3a0; --ink-faint: #6f6f6c;
  --accent: #7b7bff; --accent-soft: #1c1c3a;
  --green: #33c26e; --green-soft: #0f2a1c;
  --orange: #f5a94e; --orange-soft: #2e230f;
  --red: #f2666b; --red-soft: #301315; --gray-soft: #1e1e21;
}
:root[data-theme="light"] {
  --bg: #f7f7f5; --surface: #ffffff; --border: #eaeae7; --border-strong: #ddddd9;
  --ink: #17181a; --ink-soft: #6b6b68; --ink-faint: #9c9c98;
  --accent: #3d3dff; --accent-soft: #eef0ff;
  --green: #17a34a; --green-soft: #eafaf0;
  --orange: #e07f13; --orange-soft: #fdf3e6;
  --red: #e0393f; --red-soft: #fdecec; --gray-soft: #f1f1ef;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app { min-height: 100vh; }

.hidden { display: none !important; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.greeting h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.wave { display: inline-block; animation: wave 2.2s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
}
.date-label {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  text-transform: capitalize;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); }

/* ── Main layout ────────────────────────────────────────── */
.main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadein 0.5s var(--ease);
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Mission card ───────────────────────────────────────── */
.mission-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  display: flex;
  align-items: center;
  gap: 28px;
  box-shadow: var(--shadow-md);
}
.mission-icon {
  font-size: 52px;
  width: 92px;
  height: 92px;
  min-width: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
}
.mission-body { flex: 1; min-width: 0; }
.mission-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.mission-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.mission-progress-track, .focus-progress-track, .block-progress-track {
  height: 6px;
  background: var(--gray-soft);
  border-radius: 999px;
  overflow: hidden;
}
.mission-progress-fill, .focus-progress-fill, .block-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s var(--ease);
}
.mission-progress-label {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.automation-notes { display: flex; flex-direction: column; gap: 8px; }
.automation-note {
  background: var(--orange-soft);
  color: var(--orange);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Grid ───────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 780px) {
  .grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.panel-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 18px;
}

/* ── Timeline ───────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.block {
  display: grid;
  grid-template-columns: 56px 20px 1fr;
  gap: 4px;
  animation: fadein 0.35s var(--ease);
}
.block-time {
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.block-start { font-weight: 700; color: var(--ink-soft); }
.block-connector { display: flex; flex-direction: column; align-items: center; }
.block-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border-strong);
  margin-top: 16px;
  flex-shrink: 0;
}
.block.is-appointment .block-dot { background: var(--accent); }
.block.is-done .block-dot { background: var(--green); }
.block-line { flex: 1; width: 1px; background: var(--border); margin: 4px 0; }
.block:last-child .block-line { display: none; }

.block-card {
  background: var(--gray-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.block-card:hover { border-color: var(--border-strong); }
.block.is-appointment .block-card { background: var(--accent-soft); }
.block.is-done .block-card { background: var(--green-soft); opacity: 0.75; }
.block.is-skipped .block-card { opacity: 0.4; }

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.block-domain {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.block-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}
.block-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.block-progress-track { margin-bottom: 6px; }
.block-checklist { list-style: none; margin: 10px 0 0; padding: 0; display: none; flex-direction: column; gap: 8px; }
.block.is-expanded .block-checklist { display: flex; }
.block-checklist li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
}
.block-checklist li.checked { color: var(--ink-faint); text-decoration: line-through; }
.checkbox {
  width: 17px; height: 17px; min-width: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.checkbox.checked { background: var(--ink); border-color: var(--ink); color: var(--bg); font-size: 11px; }

/* ── Stock panel ────────────────────────────────────────── */
.stock-list { display: flex; flex-direction: column; gap: 4px; }
.stock-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.stock-item:last-child { border-bottom: none; }
.stock-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.stock-dot.green { background: var(--green); }
.stock-dot.orange { background: var(--orange); }
.stock-dot.red { background: var(--red); }
.stock-dot.gray { background: var(--ink-faint); }
.stock-info { flex: 1; min-width: 0; }
.stock-label { font-size: 13.5px; font-weight: 600; }
.stock-value { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.stock-edit input, .stock-edit select {
  width: 52px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 5px 7px;
  font-family: inherit;
  font-size: 12.5px;
  background: var(--surface);
  color: var(--ink);
}
.stock-edit button.toggle-pill {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.stock-edit button.toggle-pill.on { background: var(--green-soft); color: var(--green); border-color: transparent; }

/* ── Focus mode ─────────────────────────────────────────── */
.focus-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadein 0.3s var(--ease);
}
.focus-exit {
  position: absolute;
  top: 26px;
  right: 30px;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 999px;
}
.focus-exit:hover { background: var(--gray-soft); }
.focus-content {
  max-width: 560px;
  width: 90%;
  text-align: left;
}
.focus-domain {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 10px;
}
.focus-title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.15;
}
.focus-time { font-size: 14px; color: var(--ink-faint); margin-bottom: 30px; font-variant-numeric: tabular-nums; }
.focus-checklist { list-style: none; margin: 0 0 26px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.focus-checklist li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  cursor: pointer;
  color: var(--ink);
}
.focus-checklist li.checked { color: var(--ink-faint); text-decoration: line-through; }
.focus-checklist .checkbox { width: 22px; height: 22px; border-radius: 7px; }
.focus-progress-track { margin-bottom: 22px; height: 8px; }
.focus-next-btn { width: 100%; padding: 15px; font-size: 15px; }

.empty-state { color: var(--ink-faint); font-size: 13.5px; padding: 20px 4px; }
