/* Layout: one column like a pocket diary page. Times run down the left edge; sections sit within thumb reach. */
:root {
  --bg: #e9eff1; --page: #fbfdfd; --ink: #13232c; --soft: #52656f; --line: #cad6da;
  --accent: #0b5566; --on-accent: #ffffff; --late: #a62b1f;
  --life: #7d5700; --health: #96305a; --work: #2c559c;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101a20; --page: #18262e; --ink: #e8f0f2; --soft: #a3b5bd; --line: #33454f;
    --accent: #7fd0e0; --on-accent: #06272f; --late: #ff9d8f;
    --life: #e8bd62; --health: #f19abf; --work: #9dbdf5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0 auto; max-width: 42rem; min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(10rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--bg); color: var(--ink); font: 1.0625rem/1.45 var(--body);
  overflow-wrap: anywhere;
}
h1, h2 { font-family: var(--display); text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.1875rem; }
p { margin: 0; }
a { color: var(--accent); }

button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 48px; border: 0; border-radius: 10px; padding: 8px 16px; background: transparent; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary, #add { background: var(--accent); color: var(--on-accent); font-weight: 650; }
.quiet { color: var(--accent); font-weight: 600; padding-inline: 10px; }
.outline { border: 1px solid var(--line); color: var(--accent); font-weight: 600; }
.danger { color: var(--late); font-weight: 600; }

header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 14px; }
main, section { display: grid; gap: 12px; min-width: 0; }
main { gap: 28px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; min-height: 48px; }
.section-head > div { display: flex; flex-wrap: wrap; }
.late-head { color: var(--late); }
.empty, .hint { color: var(--soft); }
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; border-block: 1px solid var(--line); padding-block: 10px; }
.notice p { flex: 1 1 14rem; }
#problem { margin-bottom: 16px; padding: 12px; border: 2px solid var(--late); border-radius: 10px; color: var(--late); font-weight: 600; }

/* Seven-day strip */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week button { display: grid; justify-items: center; gap: 2px; padding: 8px 0; min-height: 68px; font-size: .875rem; color: var(--soft); }
.week b { font: 650 1.25rem/1.2 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.week i { width: 6px; height: 6px; border-radius: 50%; }
.week .busy { background: currentColor; }
.week [aria-pressed="true"], .week [aria-pressed="true"] b { background: var(--accent); color: var(--on-accent); }
.daybar { display: flex; justify-content: space-between; gap: 8px; }

/* Rows */
.rows { list-style: none; margin: 0; padding: 0; background: var(--page); border: 1px solid var(--line); border-radius: 12px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-height: 64px; }
.row + .row { border-top: 1px solid var(--line); }
.timed .row { grid-template-columns: 5.25rem minmax(0, 1fr) auto; }
.time { padding-left: 12px; color: var(--soft); font-size: .9375rem; font-variant-numeric: tabular-nums; }
.open { display: grid; gap: 1px; text-align: left; width: 100%; min-height: 64px; align-content: center; padding: 8px 12px; border-radius: 12px; }
.open strong { font-weight: 600; }
.meta { color: var(--soft); font-size: .9375rem; }
.tag { font-weight: 650; }
.life { color: var(--life); } .health { color: var(--health); } .work { color: var(--work); } .late { color: var(--late); }
.done strong { text-decoration: line-through; color: var(--soft); }
.side { padding-right: 8px; }
.call { display: grid; place-items: center; min-height: 48px; padding-inline: 12px; font-weight: 600; }
.tick { width: 48px; padding: 0; display: grid; place-items: center; }
.tick span { width: 28px; height: 28px; border: 2px solid var(--soft); border-radius: 8px; display: grid; place-items: center; font-weight: 800; line-height: 1; }
.tick[aria-pressed="true"] span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Filters and search */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: var(--page); padding-inline: 14px; }
.chips [aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

/* Bottom controls */
#nav {
  position: fixed; inset: auto 0 0; z-index: 5; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  background: var(--page); border-top: 1px solid var(--line);
}
#nav button { padding-inline: 2px; color: var(--soft); font-size: .9375rem; overflow-wrap: normal; }
#nav [aria-current] { color: var(--accent); font-weight: 700; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 8px; }
#add {
  position: fixed; z-index: 4; min-height: 56px; padding-inline: 22px;
  right: max(16px, env(safe-area-inset-right, 0px), calc((100vw - 42rem) / 2 + 16px));
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}
#toast {
  position: fixed; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(76px + env(safe-area-inset-bottom, 0px)); margin-inline: auto; max-width: 40rem;
  padding: 6px 8px 6px 16px; min-height: 60px; border-radius: 12px; background: var(--ink); color: var(--bg);
}
#toast button { color: inherit; font-weight: 700; text-decoration: underline; }

/* Entry sheet */
dialog {
  width: 100%; max-width: 42rem; max-height: 92dvh; margin: auto auto 0; border: 0; border-radius: 18px 18px 0 0;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--page); color: var(--ink); overflow-y: auto;
}
dialog::backdrop { background: rgb(5 15 20 / .55); }
dialog form, .stack { display: grid; gap: 16px; min-width: 0; }
.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, legend { font-weight: 600; padding: 0; }
legend { margin-bottom: 6px; }
input:not([type="checkbox"]), select, textarea {
  width: 100%; min-width: 0; min-height: 50px; padding: 10px 12px; border: 1px solid var(--soft); border-radius: 10px; background: var(--bg);
}
textarea { min-height: 96px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; }
input[type="checkbox"] { width: 26px; height: 26px; flex: none; accent-color: var(--accent); }
.times { display: grid; gap: 8px; }
.times div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.buttons .primary { flex: 1 1 8rem; }
.error { color: var(--late); font-weight: 600; }
pre { margin: 0; white-space: pre-wrap; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 10px; user-select: text; }
