:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface: #131823;
  --surface-2: #1a2130;
  --border: #252e40;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --accent: #6d8cff;

  --todo: #ef4444;
  --todo-bg: rgba(239, 68, 68, 0.14);
  --progress: #f59e0b;
  --progress-bg: rgba(245, 158, 11, 0.14);
  --done: #22c55e;
  --done-bg: rgba(34, 197, 94, 0.14);

  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.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;
}

.banner {
  background: var(--progress-bg);
  color: #fcd34d;
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
}
.banner-error { background: var(--todo-bg); color: #fca5a5; border-bottom-color: rgba(239, 68, 68, 0.35); }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { margin: 4px 0 12px; color: var(--muted); font-size: 14px; }
.header-main { flex: 1 1 360px; min-width: 0; }

.date-panel {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.today { cursor: pointer; }

.btn-calendar {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-calendar:hover, .btn-calendar[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.btn-step:disabled { opacity: 0.35; cursor: default; }
.btn-step:disabled:hover { border-color: var(--border); }

.calendar {
  position: absolute; top: 100%; right: 0; z-index: 20;
  margin-top: 8px; width: 300px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head strong { font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding-bottom: 4px; }
.cal-day {
  position: relative;
  aspect-ratio: 1; max-width: 100%;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--text); font: inherit; font-size: 14px; font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day:disabled { color: var(--border); cursor: default; background: none; }
.cal-day.is-today { border-color: var(--accent); }
.cal-day.is-selected { background: var(--accent); color: #0b0e14; font-weight: 700; }
.cal-day.has-work::after {
  content: ""; position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--done);
}
.cal-day.is-selected.has-work::after { background: #0b0e14; }
.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.cal-legend { font-size: 12px; color: var(--muted); }
.date-note {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.date-note.is-other-day { color: var(--progress); }
.date-controls { display: flex; align-items: center; gap: 6px; }
.btn-step {
  width: 32px; height: 32px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.btn-step:hover { border-color: var(--accent); }

.btn-step:focus-visible, .btn-calendar:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.done-counter {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--done-bg); color: var(--done);
  padding: 6px 12px; border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.done-counter strong { font-size: 26px; line-height: 1; }
.done-counter { flex-wrap: wrap; justify-content: flex-end; max-width: 260px; }
.done-label { font-size: 14px; font-weight: 600; }
.done-sub { flex-basis: 100%; text-align: right; font-size: 12px; color: var(--muted); }

.today {
  display: flex; align-items: center; gap: 12px;
  font-variant-numeric: tabular-nums;
}
.today-day {
  font-size: 64px; font-weight: 700; line-height: 1;
  letter-spacing: -0.03em; color: var(--text);
}
.today-rest { display: flex; flex-direction: column; line-height: 1.25; }
.today-weekday { font-size: 20px; font-weight: 600; color: var(--accent); }
.today-month { font-size: 15px; color: var(--muted); }

.legend {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 16px; flex-wrap: wrap;
  color: var(--muted); font-size: 12px;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.status-todo { background: var(--todo); }
.dot.status-in_progress { background: var(--progress); }
.dot.status-done { background: var(--done); }

/* Tabs */
.tabs {
  display: flex; gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none;
  color: var(--muted);
  font: inherit; font-weight: 600;
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-count {
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
  padding: 1px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .tab-count { background: rgba(109, 140, 255, 0.18); color: var(--accent); }

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-chip {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 14px; border-radius: 10px;
  font-size: 13px;
}
.summary-chip strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.summary-total { color: var(--text); background: var(--surface-2); margin-left: auto; }

.qty-wrap { display: flex; align-items: center; gap: 4px; }
.btn-qty { width: 28px; height: 28px; font-size: 16px; }
.btn-qty:disabled { opacity: 0.4; cursor: default; }
.btn-qty:disabled:hover { border-color: var(--border); }
input[type="number"] {
  width: 52px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 6px; font: inherit; font-size: 14px; font-weight: 600;
  text-align: center; font-variant-numeric: tabular-nums;
  color-scheme: dark; -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.taken-cell { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.taken-running { color: var(--progress); font-weight: 500; }
.taken-none { color: var(--muted); font-weight: 400; }

.status-todo { color: var(--todo); background: var(--todo-bg); }
.status-in_progress { color: var(--progress); background: var(--progress-bg); }
.status-done { color: var(--done); background: var(--done-bg); }

/* Table */
.tasks { width: 100%; border-collapse: collapse; }
.tasks th {
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.tasks td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tasks tbody tr:hover { background: var(--surface-2); }
.tasks .num { width: 36px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tasks .title { font-weight: 500; }
.tasks .actions { width: 132px; text-align: right; }

.time-wrap { display: flex; align-items: center; gap: 6px; }

#add-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.time-value {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.time-value::after {
  content: ""; width: 10px; height: 10px; opacity: 0.45;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a5 5 0 0 1 5 5v3h1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1h1V7a5 5 0 0 1 5-5zm0 2a3 3 0 0 0-3 3v3h6V7a3 3 0 0 0-3-3z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a5 5 0 0 1 5 5v3h1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1h1V7a5 5 0 0 1 5-5zm0 2a3 3 0 0 0-3 3v3h6V7a3 3 0 0 0-3-3z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.time-none { color: var(--muted); }
.btn-stamp {
  min-width: 72px; height: 32px; padding: 0 14px;
  border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-stamp-start { background: var(--progress-bg); color: var(--progress); border-color: rgba(245, 158, 11, 0.4); }
.btn-stamp-start:hover { background: var(--progress); color: #0b0e14; }
.btn-stamp-end { background: var(--done-bg); color: var(--done); border-color: rgba(34, 197, 94, 0.4); }
.btn-stamp-end:hover { background: var(--done); color: #0b0e14; }
.btn-stamp:disabled { background: none; color: var(--muted); border-color: var(--border); opacity: 0.5; cursor: not-allowed; }
.btn-stamp:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.qty-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Notepad */
.notes-panel { margin-top: 20px; }
.notes-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.notes-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.notes-status { font-size: 12px; color: var(--muted); }
#notes-input {
  display: block; width: 100%; min-height: 120px; resize: vertical;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font: inherit; line-height: 1.6;
}
#notes-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-now {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 8px; cursor: pointer;
}
.btn-now:hover { color: var(--text); border-color: var(--accent); }

.row-tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.btn-tool {
  width: 30px; height: 30px;
  background: none; border: none; color: var(--muted);
  border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-tool:hover { color: var(--text); background: var(--surface-2); }
.btn-tool:disabled { opacity: 0.25; cursor: default; }
.btn-tool:disabled:hover { background: none; color: var(--muted); }
.btn-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.spotlight { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.spotlight-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 20px;
  background: var(--progress-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
}
.spotlight-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--progress);
}
.spotlight-eyebrow::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--progress);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .spotlight-eyebrow::before { animation: none; } }
.spotlight-title { font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
.spotlight-meta { color: var(--progress); font-size: 15px; font-variant-numeric: tabular-nums; }

.btn-icon, .btn-delete {
  background: none; border: none; color: var(--muted);
  cursor: pointer; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon { font-size: 18px; width: 26px; height: 26px; line-height: 1; }
.btn-delete { width: 30px; height: 30px; }
.btn-icon:hover { color: var(--text); background: var(--surface-2); }
.btn-delete:hover { color: var(--todo); background: var(--todo-bg); }
.btn-delete.armed {
  width: auto; padding: 0 10px;
  color: var(--todo); background: var(--todo-bg);
  font: inherit; font-size: 12px; font-weight: 600; white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}

.empty { color: var(--muted); text-align: center; padding: 24px 0; margin: 0; }

.add-form { display: flex; gap: 10px; margin-top: 16px; }
#add-input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font: inherit;
}
.btn-primary {
  background: var(--accent); color: #0b0e14;
  border: none; border-radius: 8px;
  padding: 10px 18px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.1); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--todo);
  padding: 10px 16px; border-radius: 10px;
  font-size: 14px; max-width: calc(100% - 32px);
}

/* Phone layout: each task becomes a card. */
@media (max-width: 720px) {
  .container { padding-top: 20px; }
  .panel { padding: 14px; }
  .tasks thead { display: none; }
  .tasks, .tasks tbody, .tasks tr, .tasks td { display: block; width: 100%; }
  .tasks tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .tasks tbody tr:hover { background: none; }
  .tasks td { border: none; padding: 0; }
  .tasks .num { display: none; }
  .tasks .title { grid-column: 1; }
  .tasks .actions { grid-column: 2; grid-row: 1; width: auto; }
  .spotlight-title { font-size: 24px; }
  .tasks .time-cell { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
  .tasks .time-cell::before { content: attr(data-label); width: 40px; color: var(--muted); font-size: 13px; }
  .tasks .status-cell { grid-column: 1; }
  .tasks .taken-cell { grid-column: 2; text-align: right; align-self: center; }
  .tasks .qty-cell { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
  .tasks .status-cell, .tasks .taken-cell { order: 1; }
  .tasks .qty-cell::before { content: attr(data-label); width: 40px; color: var(--muted); font-size: 13px; }
  .done-counter { justify-content: flex-start; }
  .done-sub { text-align: left; }
  .summary-total { margin-left: 0; }
  .today-day { font-size: 48px; }
  .date-panel { align-items: flex-start; }
  .calendar { right: auto; left: 0; }
  .today-weekday { font-size: 17px; }
}
