:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #76767c;
  --line: #e4e2dd;
  --accent: #d9480f;
  --w0: #d9480f;
  --w1: #e8803f;
  --w2: #b9b4aa;
  --done: #2b8a3e;
  --rec: #5f3dc4;
  --rec-bg: #f1edff;
  --danger: #e03131;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --card: #1e1e21;
    --text: #ececef;
    --muted: #8d8d95;
    --line: #2e2e33;
    --accent: #ff7a3d;
    --w0: #ff7a3d;
    --w1: #d9884f;
    --w2: #6b675f;
    --done: #51cf66;
    --rec: #b197fc;
    --rec-bg: #2a2440;
    --danger: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-card h1 { margin: 0 0 4px; font-size: 26px; }

/* ---------- header + tabs ---------- */
.top {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-end; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 24px 16px 12px;
}
.brand { margin-right: auto; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; text-transform: capitalize; }
.tabs { display: flex; gap: 4px; background: var(--line); padding: 4px; border-radius: 10px; }
.tabs a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 7px; text-decoration: none;
  color: var(--muted); font-weight: 500;
}
.tabs a.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.tabs .ico { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 48px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 24px 0; }
.empty a { color: var(--accent); }

/* ---------- controls ---------- */
input:not([type=checkbox]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: not-allowed; }
button[type=submit] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.icon { padding: 4px 9px; font-size: 13px; line-height: 1.3; min-width: 32px; }
.ghost { background: transparent; }
.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.on-rec { color: var(--rec); border-color: var(--rec); background: var(--rec-bg); }
.inline-form { display: flex; gap: 8px; margin-bottom: 10px; max-width: 520px; }
.row { display: flex; gap: 8px; }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.chip.rec { background: var(--rec-bg); color: var(--rec); }
.legend { margin: 0 0 16px; font-size: 13px; }

/* ---------- today ---------- */
.global { margin-bottom: 16px; display: grid; gap: 8px; }
.global .head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.global .big { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.global .bar { height: 10px; margin: 0; }

.pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 12px; }
.bar i { display: block; height: 100%; background: var(--done); transition: width .25s; }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tasks li { border-left: 4px solid var(--w2); border-radius: 6px; background: var(--bg); }
.tasks li.w0 { border-color: var(--w0); }
.tasks li.w1 { border-color: var(--w1); }
.tasks li.rec { background: var(--rec-bg); }
.tasks label { display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; }
.tasks input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--done); flex: none; }
.tasks .label { flex: 1; overflow-wrap: anywhere; }
.tasks li.w0 .label { font-size: 17px; font-weight: 600; }
.tasks li.w2 .label { font-size: 14px; color: var(--muted); }
.tasks li.done .label { text-decoration: line-through; color: var(--muted); }
.rec-mark { color: var(--rec); font-weight: 700; margin-right: 4px; }
.weight {
  font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 99px;
  background: var(--card); color: var(--muted); font-variant-numeric: tabular-nums; flex: none;
}

/* ---------- config ---------- */
.section-title {
  margin: 16px 0 6px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rows li {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 8px; border-radius: 8px; background: var(--bg);
}
.rows li .label { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.rows li.picked { border-left: 4px solid var(--w2); }
.rows li.picked.w0 { border-color: var(--w0); }
.rows li.picked.w1 { border-color: var(--w1); }
.rows li.rec { background: var(--rec-bg); }
.rows li.is-done .label { text-decoration: line-through; color: var(--muted); }
.rows li.hint { color: var(--muted); font-size: 13px; padding: 4px 2px; background: none; }
.actions { display: flex; gap: 4px; flex: none; margin-left: auto; }

.add-task { display: flex; gap: 6px; margin-top: 12px; align-items: center; }
.add-task input[name=label] { flex: 1; min-width: 0; }
.rec-toggle { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--rec); white-space: nowrap; cursor: pointer; }
.rec-toggle input { accent-color: var(--rec); }
details { margin-top: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details .rows { margin-top: 6px; }

/* ---------- noise ---------- */
.noise-form { display: grid; gap: 10px; max-width: 620px; margin-bottom: 20px; }
.noise-form .hint { margin: -2px 0 0; font-size: 13px; }
.noise-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.noise-toolbar label { display: flex; align-items: center; gap: 8px; }
.noise-toolbar select { width: auto; }
.note { display: grid; gap: 6px; }
.note.editing { outline: 2px solid var(--accent); }
.note h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.note a.link { color: var(--accent); overflow-wrap: anywhere; font-size: 14px; }
.note p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .desc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6;
  overflow: hidden;
}
.note .desc.expanded { display: block; -webkit-line-clamp: unset; line-clamp: none; overflow: visible; }
.note .more {
  justify-self: start; padding: 0; border: 0; background: none;
  color: var(--accent); font-size: 14px; font-weight: 500; cursor: pointer;
}
.note .more:hover { text-decoration: underline; }
.note footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.note footer .when { font-size: 12px; margin-right: auto; }

.toast {
  position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--danger); color: #fff; padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px);
  z-index: 20;
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .top { padding: 16px 16px 8px; align-items: center; }
  .brand h1 { font-size: 22px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  main { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  /* Tabs become a bottom bar */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    border-radius: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line); justify-content: space-around;
  }
  .tabs a { flex: 1; flex-direction: column; gap: 0; font-size: 12px; padding: 6px 4px; }
  .tabs a.active { box-shadow: none; background: var(--bg); color: var(--accent); }
  .tabs .ico { display: block; font-size: 20px; line-height: 1.1; }
  .icon { min-width: 38px; min-height: 36px; }
  .inline-form { max-width: none; }
  .global .big { font-size: 28px; }
}
