:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a65;
  --line: #e2e0d8;
  --accent: #1f5f4a;
  --accent-soft: #e3f0ea;
  --warn: #a8480f;
  --warn-soft: #fbeadc;
  --deep: #1f5f4a;
  --meeting: #7a4fb3;
  --shallow: #b07a12;
  --buffer: #8a8982;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161715;
    --card: #20211e;
    --text: #ecebe6;
    --muted: #a09f98;
    --line: #34352f;
    --accent: #6fc7a6;
    --accent-soft: #1f342c;
    --warn: #f0a068;
    --warn-soft: #3a2616;
    --deep: #6fc7a6;
    --meeting: #b596e6;
    --shallow: #e0b352;
    --buffer: #8a8982;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 64px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs a { padding: 6px 16px; color: var(--muted); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--accent); color: var(--card); }
.datenav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.datenav h1 { font-size: 17px; margin: 0 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 2px; display: flex; align-items: baseline; gap: 8px; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); }
.count.over { color: var(--warn); }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 600; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="time"], input[type="number"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  min-width: 0;
}
textarea { width: 100%; min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.ghost { background: transparent; border-color: transparent; flex: 1; padding-left: 4px; }
input.ghost:hover { border-color: var(--line); }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--card); font-weight: 600; }
button.x { border: none; background: none; color: var(--muted); padding: 2px 8px; font-size: 16px; }
button.x:hover { color: var(--warn); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.rows li.done input.ghost { text-decoration: line-through; color: var(--muted); }
.addform { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.addform input[type="text"] { flex: 1 1 200px; }
.field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field input[type="text"] { flex: 1 1 260px; }
.field label { font-weight: 600; }

.mustwin { border-left: 4px solid var(--accent); }
.mustwin input.ghost { font-size: 18px; font-weight: 600; }

.meter { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.meter div { height: 100%; background: var(--accent); }
.meter.warn div { background: var(--warn); }
.meterline { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.meterline .warn { color: var(--warn); font-weight: 600; }
.meterline input { width: 64px; padding: 2px 6px; }

.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.daycard { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg); min-width: 0; }
.daycard.today { border-color: var(--accent); }
.daycard .dayname { font-weight: 700; display: block; }
.daycard input { width: 100%; font-size: 12px; padding: 3px 5px; margin: 4px 0; }
.daycard .mw { font-size: 13px; margin: 4px 0; overflow-wrap: anywhere; }
.daycard .mw.empty { color: var(--muted); }
.daycard .mw.done { text-decoration: line-through; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; border-radius: 4px; padding: 0 5px; border: 1px solid currentColor; }
.k-deep { color: var(--deep); }
.k-meeting { color: var(--meeting); }
.k-shallow { color: var(--shallow); }
.k-buffer { color: var(--buffer); }

.blocks li { border-left: 4px solid currentColor; padding-left: 10px; margin: 4px 0; }
.blocks li > * { color: var(--text); }
.blocks .time { font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.blocks .label { flex: 1; overflow-wrap: anywhere; }
.blocks .kind { color: var(--muted); font-size: 12px; flex: none; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cols .card { margin-bottom: 0; }
.cols { margin-bottom: 14px; }
.review { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.review label { font-weight: 600; font-size: 13px; display: block; margin-bottom: 4px; }

.gate { max-width: 380px; margin: 14vh auto 0; text-align: center; padding: 28px 24px; }
.gate h1 { margin: 0 0 6px; font-size: 22px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 8px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  .weekgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols, .review { grid-template-columns: 1fr; }
  .datenav { margin-left: 0; }
}
