/* Day Plan — single stylesheet for both pages.
   Tokens taken from the approved Figma file 4MwXZi1XydU1PunOlAIBLt (v1),
   frames 1:2, 1:16, 3:65, 4:54, 6:2, 6:56, 8:2.
   Desktop-first: the base rules size the app for 1200px+, media queries
   tighten it for tablet and phone. No CSS framework. */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-muted: #f7f6f2;
  --surface-done: #f2f1ec;
  --surface-running: #fbefde;
  --border: #e8e4dc;
  --divider: #ece8e0;
  --text: #1f1b16;
  --text-muted: #75706a;
  --text-subtle: #9a958c;
  --track-fill: #b8b3a8;
  --accent: #d97706;
  --danger: #b3422e;
  --scrim: rgba(26, 23, 20, 0.45);

  --radius-card: 12px;
  --radius-field: 10px;
  --radius-sheet: 20px;
  --shadow-soft: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sheet: 0 -4px 20px 0 rgba(0, 0, 0, 0.12);

  --content-width: 760px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.4;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- app shell */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--content-width);
  margin: 0 auto;
  padding-bottom: 76px; /* room for the fixed tab bar */
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 24px 18px;
}

.date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-arrow {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}
.date-arrow:hover { background: var(--surface-muted); color: var(--text); }
.date-arrow:active { background: var(--divider); }
.date-arrow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.date-label {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.day-summary {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.day-summary .running-accent { color: var(--accent); }

.divider {
  height: 1px;
  background: var(--divider);
}

.app-main {
  flex: 1 0 auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ------------------------------------------------------------ auth slot */

.auth-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-name {
  font-weight: 500;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: #d8d2c7;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.signout-link, .signin-link {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
.signin-link { color: var(--text); box-shadow: var(--shadow-soft); }
.signout-link:hover, .signin-link:hover { background: var(--surface-muted); }

/* ------------------------------------------------- signed-out hero (1:2) */

.signin-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px 8px;
  background: var(--bg);
}

.signin-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  max-width: 340px;
}

.signin-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.signin-tagline {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 280px;
}

.google-btn {
  margin-top: 28px;
  width: 311px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  box-shadow: var(--shadow-soft);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  transition: background 120ms ease, box-shadow 120ms ease;
}
.google-btn:hover { background: var(--surface-muted); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.google-btn:active { background: var(--divider); }

.google-badge {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #4285f4;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.signin-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-subtle);
}

.signed-out-note {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ------------------------------------------------------ task list (1:26) */

.list-meta {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.72px;
  color: var(--text-subtle);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.task-card:hover { border-color: #ddd7cb; }
.task-card.dragging { opacity: 0.55; }

.task-card.is-running {
  background: var(--surface-running);
  border: 1.5px solid var(--accent);
  padding: 13.5px;
}

.task-card.is-complete {
  background: var(--surface-done);
}

.task-row-1 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-check {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.task-check:hover { border-color: var(--text-subtle); }
.task-card.is-complete .task-check {
  background: var(--text-subtle);
  border-color: var(--text-subtle);
  color: #fff;
}

.task-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-card.is-complete .task-name {
  color: var(--text-subtle);
  text-decoration: line-through;
}

.task-handle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--text-subtle);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: grab;
}
.task-handle:hover { background: var(--divider); color: var(--text-muted); }

.task-row-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.task-times {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.task-card.is-running .task-times { color: var(--accent); }

.progress-track {
  height: 4px;
  width: 100%;
  max-width: 320px;
  border-radius: 2px;
  background: var(--divider);
  overflow: hidden;
}
.progress-track.wide { max-width: none; }

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--track-fill);
  transition: width 400ms ease;
}
.progress-fill.accent { background: var(--accent); }
.task-card.is-running .progress-fill { background: var(--accent); }
.task-card.is-complete .progress-fill { background: var(--text-subtle); }

.timer-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.timer-btn:hover { border-color: var(--accent); color: var(--accent); }
.timer-btn:active { transform: scale(0.94); }
.timer-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.task-card.is-running .timer-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.task-card.is-complete .timer-btn {
  background: var(--text-subtle);
  border-color: var(--text-subtle);
  color: #fff;
}

.timer-icon { font-size: 13px; line-height: 1; }
.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;
}

.add-task-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.add-task-row:hover { background: var(--surface-muted); border-color: var(--text-subtle); color: var(--text); }
.add-task-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.add-plus { font-size: 16px; font-weight: 600; }

.empty-note {
  margin: 0;
  font-size: 14px;
  color: var(--text-subtle);
  padding: 6px 2px;
}

/* -------------------------------------------------------- timeline (3:65) */

.timeline-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch-planned { background: var(--divider); border: 1px solid var(--border); }
.swatch-actual { background: var(--accent); }

.timeline-head {
  display: grid;
  grid-template-columns: 56px 1fr 1fr;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--divider);
}
.timeline-col-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.72px;
  color: var(--text-subtle);
}

.timeline { display: flex; flex-direction: column; }

.timeline-hour {
  display: grid;
  grid-template-columns: 56px 1fr 1fr;
  gap: 8px;
  align-items: stretch;
  min-height: 34px;
  border-bottom: 1px solid var(--divider);
  padding: 3px 0;
}
.timeline-time {
  font-size: 11px;
  color: var(--text-subtle);
  padding-top: 2px;
}
.timeline-slot { position: relative; display: flex; flex-direction: column; gap: 3px; }

.timeline-block {
  border-radius: 6px;
  font-size: 11px;
  padding: 3px 8px;
  color: var(--text-muted);
  background: var(--divider);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timeline-block.actual { background: var(--track-fill); color: #fff; }
.timeline-block.actual.is-running { background: var(--accent); color: #fff; }

/* --------------------------------------------------------- week (4:54) */

.week-total {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.week-total-figures { display: flex; gap: 32px; flex-wrap: wrap; }
.figure { display: flex; flex-direction: column; gap: 2px; }
.figure-value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.figure-value.accent { color: var(--accent); }
.figure-label { font-size: 13px; color: var(--text-muted); }

.week-note { margin: 0; font-size: 13px; color: var(--text-muted); }

.day-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.day-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.day-row.is-today {
  background: var(--surface-running);
  border: 1.5px solid var(--accent);
  padding: 11.5px 13.5px;
}

.day-dow { font-size: 11px; font-weight: 600; letter-spacing: 0.72px; color: var(--text-subtle); display: block; }
.day-row.is-today .day-dow { color: var(--accent); }
.day-dom { font-size: 18px; font-weight: 600; display: block; }

.day-bars { display: flex; flex-direction: column; gap: 5px; }

.day-figures { text-align: right; display: flex; flex-direction: column; gap: 4px; }
.day-planned { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.day-actual { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.day-actual.zero { color: var(--text-subtle); font-weight: 400; }
.day-row.is-today .day-actual { color: var(--accent); }

/* AC-3: the per-day difference. Subordinate to planned/actual in size, but
   bold whenever the day ran over or under its plan. */
.day-difference { font-size: 12px; font-weight: 400; color: var(--text-subtle); white-space: nowrap; }
.day-difference.is-over { font-weight: 700; color: var(--accent); }
.day-difference.is-under { font-weight: 700; color: var(--text-muted); }

/* ---------------------------------------------------------- tab bar */

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 0;
  z-index: 20;
}

.tab {
  flex: 0 1 200px;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
}
.tab .tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: transparent;
}
.tab.is-active { color: var(--text); font-weight: 600; }
.tab.is-active .tab-dot { background: var(--accent); }
.tab:hover { color: var(--text-muted); }
.tab.is-active:hover { color: var(--text); }

/* -------------------------------------------------- editor sheet (6:2) */

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 12px 20px 28px;
  background: var(--surface);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  z-index: 31;
}

.sheet-grab {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.sheet-title { margin: 0; font-size: 18px; font-weight: 600; }
.sheet-close {
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 8px;
}
.sheet-close:hover { background: var(--surface-muted); color: var(--text); }

.sheet-form { display: flex; flex-direction: column; gap: 20px; width: 100%; }

.field-group { display: flex; flex-direction: column; gap: 8px; flex: 1 1 0; min-width: 0; }
.field-row { display: flex; gap: 12px; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.72px;
  color: var(--text-subtle);
}

.field {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-field);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.field::placeholder { color: var(--text-subtle); font-weight: 400; }
.field:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.field-suffix {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
}
.field-suffix:focus-within { border-color: var(--accent); background: var(--surface); }
.field-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 12px 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.field-input:focus { outline: none; }
.suffix { font-size: 14px; color: var(--text-subtle); }

.logged-note {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.primary-btn {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: var(--radius-field);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background 120ms ease, transform 100ms ease;
}
.primary-btn:hover { background: #c26a05; }
.primary-btn:active { transform: scale(0.99); }
.primary-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.secondary-row { display: flex; gap: 12px; width: 100%; }
.secondary-btn {
  flex: 1 1 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.secondary-btn:hover { background: var(--surface-muted); }
.secondary-btn.danger { color: var(--danger); }
.secondary-btn.danger:hover { background: #fdf1ee; }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.toast.is-error { background: var(--danger); }

/* --------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .app { max-width: 100%; }
  .app-header { padding: 22px 20px 16px; }
  .app-main { padding: 12px 16px 20px; }
  .week-total-figures { gap: 24px; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .app-header { padding: 20px 16px 16px; }
  .date-label { font-size: 20px; }
  .app-main { padding: 12px 12px 20px; }
  .signin-panel { padding: 24px 20px 4px; }
  .figure-value { font-size: 22px; }
  .week-total-figures { gap: 18px; }
  .day-row { grid-template-columns: 46px 1fr auto; gap: 10px; padding: 10px 12px; }
  .field-row { flex-direction: column; }
  .user-name { max-width: 120px; }
  .signin-link, .signout-link { font-size: 12px; padding: 5px 8px; }
  .sheet { width: 100%; }
  .task-times { white-space: normal; }
}
