/* =========================================================
   Taskboard styles
   1. Tokens   2. Base   3. Buttons & fields   4. Layout
   5. Sidebar  6. Tasks  7. Forms & cards   8. Insights
   9. Auth     10. Responsive   11. Motion
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --paper: #edf0f5;
  --surface: #ffffff;
  --ink: #151d2b;
  --muted: #5e6b7c;
  --line: #dce1e9;
  --chip: #e8ecf1;
  --accent: #2f44d6;
  --accent-soft: #e4e8fc;
  --on-accent: #ffffff;
  --done: #1e8e5a;
  --danger: #b3362b;
  --danger-soft: #fbe4e2;
  --high: #a14a08;
  --high-soft: #fdebd9;
  --shadow: 0 10px 28px -18px rgba(21, 29, 43, 0.45);

  --c-blue: #2f44d6; --c-green: #1e8e5a; --c-orange: #d9730d;
  --c-pink: #c2255c; --c-violet: #7048e8; --c-teal: #0b7285;

  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f141c; --surface: #171e29; --ink: #e8ecf2; --muted: #93a0b2;
    --line: #2a3342; --chip: #263042; --accent: #8c9bff; --accent-soft: #222b4a;
    --on-accent: #0f141c; --done: #4cc38a; --danger: #ff8a7d; --danger-soft: #3a2022;
    --high: #ffa760; --high-soft: #3a2a1a; --shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.8);
    --c-blue: #8c9bff; --c-green: #4cc38a; --c-orange: #ffa760;
    --c-pink: #f783ac; --c-violet: #b197fc; --c-teal: #3bc9db;
  }
}
.pc-blue { --pc: var(--c-blue); } .pc-green { --pc: var(--c-green); }
.pc-orange { --pc: var(--c-orange); } .pc-pink { --pc: var(--c-pink); }
.pc-violet { --pc: var(--c-violet); } .pc-teal { --pc: var(--c-teal); }

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.5; }
h1, h2 { font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); }
h2 { font-size: 1.15rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
kbd { font: inherit; font-size: 0.8rem; padding: 0.05rem 0.4rem; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; background: var(--surface); }
.dot { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--pc, var(--muted)); flex: none; }
.dot-lg { width: 0.9rem; height: 0.9rem; margin-right: 0.55rem; }

/* ---------- 3. Buttons and fields ---------- */
.btn { display: inline-block; font: inherit; font-weight: 600; cursor: pointer; border: 0; background: var(--accent);
  color: var(--on-accent); padding: 0.6rem 1.1rem; border-radius: var(--radius-md); text-decoration: none; text-align: center; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-quiet { background: transparent; color: var(--muted); padding: 0.35rem 0.7rem; font-weight: 500; }
.btn-quiet:hover { color: var(--ink); background: var(--accent-soft); filter: none; }
.btn-danger-hover:hover { color: var(--danger); background: var(--danger-soft); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-block { width: 100%; margin-top: 1.25rem; padding: 0.7rem 1rem; }

input, select, textarea { font: inherit; width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--surface); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; }
input[type="date"], select { width: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }

/* ---------- 4. Layout ---------- */
.topbar { display: flex; align-items: center; gap: 1.5rem; max-width: 64rem; margin: 0 auto; padding: 1rem 1.25rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 650; font-size: 1.15rem;
  letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.mark { width: 1.7rem; height: 1.7rem; }
.mark rect { fill: var(--accent); }
.mark path { fill: none; stroke: var(--on-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.mainnav { display: flex; gap: 0.25rem; margin-right: auto; }
.mainnav a { padding: 0.35rem 0.8rem; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500; }
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.account { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; font-size: 0.9rem; white-space: nowrap; }
.account-link { color: var(--muted); text-decoration: none; }
.account-link:hover { color: var(--ink); text-decoration: underline; }
.mainnav + .account { margin-left: 0; }

.page { max-width: 64rem; margin: 0 auto; padding: 0.5rem 1.25rem 3rem; }
.flashes { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem; }
.flash { margin: 0 0 0.75rem; padding: 0.7rem 1rem; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--muted); border-radius: var(--radius-md); }
.flash-success { border-left-color: var(--done); }
.flash-info { border-left-color: var(--accent); }
.flash-error { border-left-color: var(--danger); color: var(--danger); }

.board { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: 2.25rem; align-items: start; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1.1rem; }
.panel-head h1 { display: flex; align-items: center; }
.today { margin: 0; color: var(--muted); font-size: 0.95rem; white-space: nowrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); }

/* ---------- 5. Sidebar ---------- */
.sidebar { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.5rem 1rem 0.75rem; box-shadow: var(--shadow); }
.ring { position: relative; width: 7.5rem; height: 7.5rem; margin: 0 auto 1rem; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: var(--accent-soft); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 226.19; stroke-dashoffset: var(--offset); }
.ring.is-complete .ring-fill { stroke: var(--done); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; }
.summary-line { text-align: center; font-weight: 650; font-size: 1.1rem; margin: 0; }
.summary-sub { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 0.1rem 0 1.1rem; overflow-wrap: anywhere; }

.side-list { display: grid; gap: 0.15rem; list-style: none; margin: 0; padding: 0; }
.side-list a { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.7rem; border-radius: var(--radius-md);
  color: var(--muted); text-decoration: none; font-weight: 500; min-width: 0; }
.side-list a:hover { background: var(--accent-soft); color: var(--ink); }
.side-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.side-list .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.side-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list a:not(.active) .count { font-size: 0.9rem; }
.views { border-top: 1px solid var(--line); padding-top: 0.7rem; }
.views a.is-alert .count { color: var(--danger); font-weight: 700; }
.projects { border-top: 1px solid var(--line); margin-top: 0.7rem; padding-top: 0.7rem; }
.projects h2 { font-size: 0.95rem; color: var(--muted); font-weight: 600; padding: 0 0.7rem; margin-bottom: 0.4rem; }
.project-item { position: relative; display: flex; align-items: center; }
.project-item > a { flex: 1; }
.project-item form { position: absolute; right: 0.2rem; }
.project-item:hover .count, .project-item:focus-within .count { visibility: hidden; }
.new-project { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.new-project input { padding: 0.45rem 0.65rem; font-size: 0.92rem; }
.new-project .btn { padding: 0.45rem 0.8rem; }
.side-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; margin-top: 0.7rem;
  border-top: 1px solid var(--line); padding-top: 0.6rem; }

/* ---------- 6. Composer, toolbar, tasks ---------- */
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 0.4rem 0.4rem 0.6rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-main { display: flex; gap: 0.5rem; }
.composer-main input { border: 0; background: transparent; outline: none; font-size: 1.05rem; }
.composer-main .btn { white-space: nowrap; }
.composer-extra { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.2rem 0.6rem 0; }
.inline-field { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.88rem; }
.inline-field input, .inline-field select { padding: 0.3rem 0.5rem; font-size: 0.9rem; }

.toolbar { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.toolbar input[type="search"] { flex: 1; min-width: 0; }

.tasks { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.task { display: flex; align-items: flex-start; gap: 0.9rem; padding: 0.85rem 1rem; border-left: 3px solid transparent; }
.task + .task { border-top: 1px solid var(--line); }
.task:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.task.is-overdue { border-left-color: var(--danger); }
.task-body { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
.title { overflow-wrap: anywhere; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.title:hover { color: var(--accent); }
.notes { color: var(--muted); font-size: 0.9rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; margin-top: 0.2rem; }
.added { color: var(--muted); font-size: 0.8rem; }
.task.is-done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.chip { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.55rem;
  border-radius: 999px; background: var(--chip); color: var(--muted); }
.chip-overdue { background: var(--danger-soft); color: var(--danger); }
.chip-today { background: var(--accent-soft); color: var(--accent); }
.chip-soon { color: var(--ink); }
.chip-high { background: var(--high-soft); color: var(--high); }
.chip-project { color: var(--ink); }
.task.is-done .chip { opacity: 0.7; }

.check { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; padding: 0; cursor: pointer; margin-top: 0.1rem;
  border-radius: 50%; border: 2px solid var(--muted); background: transparent; }
.check svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: var(--on-accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check:hover { border-color: var(--done); }
.check:hover svg { stroke: var(--done); opacity: 0.7; }
.is-done .check { background: var(--done); border-color: var(--done); }
.is-done .check svg { opacity: 1; stroke: var(--on-accent); }

.task-actions { display: flex; align-items: center; gap: 0.1rem; }
.icon-btn { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; padding: 0; cursor: pointer; border: 0;
  background: transparent; color: var(--muted); border-radius: var(--radius-md); text-decoration: none; }
.icon-btn svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--danger); background: var(--accent-soft); }
a.icon-btn:hover { color: var(--accent); }
.icon-sm { width: 1.7rem; height: 1.7rem; }
.icon-sm svg { width: 1rem; height: 1rem; }
@media (hover: hover) {
  .task .icon-btn { opacity: 0; }
  .task:hover .icon-btn, .task:focus-within .icon-btn { opacity: 1; }
  .project-item .icon-btn { opacity: 0; }
  .project-item:hover .icon-btn, .project-item:focus-within .icon-btn { opacity: 1; }
}

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius-lg); }
.empty p { margin: 0.2rem 0; }
.empty-title { color: var(--ink); font-weight: 650; font-size: 1.1rem; }
.shortcuts { color: var(--muted); font-size: 0.85rem; margin: 1rem 0 0; text-align: right; }

/* ---------- 7. Forms and cards ---------- */
.form-card { max-width: 38rem; margin: 1rem auto; }
.form-card h1 { margin-bottom: 1rem; }
.form-card h2 { margin: 1.75rem 0 0.5rem; }
.form-card label, .auth-card label { display: block; margin: 1rem 0 0.3rem; font-size: 0.9rem; font-weight: 500; }
.form-card input:not([type="radio"]):not([type="date"]), .form-card textarea, .auth-card input { width: 100%; }
.lead { color: var(--muted); margin: 0 0 0.5rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-start; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 1.5rem; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.center { text-align: center; }

.segmented { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
.segmented legend { padding: 0; margin: 1rem 0 0.3rem; font-size: 0.9rem; font-weight: 500; float: left; width: 100%; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label { margin: 0; padding: 0.5rem 1rem; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 0.95rem; }
.segmented label:first-of-type { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.segmented label:last-of-type { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.segmented label + input + label { border-left: 0; }
.segmented input:checked + label { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 650; }
.segmented input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- 8. Insights ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { display: grid; gap: 0.2rem; padding: 1.1rem 1.25rem; }
.stat-num { font-size: 2.2rem; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat.is-alert .stat-num { color: var(--danger); }

.chart-card { margin-bottom: 1rem; }
.bars { display: flex; align-items: flex-end; gap: 0.4rem; height: 12rem; margin-top: 1rem; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.25rem; }
.bar { width: 100%; max-width: 2.2rem; height: var(--h); min-height: 4px; background: var(--accent-soft); border-radius: 6px 6px 3px 3px; }
.bar.is-today { background: var(--accent); }
.bar-col:hover .bar { background: var(--accent); }
.bar-value { font-size: 0.8rem; color: var(--muted); min-height: 1.2em; font-variant-numeric: tabular-nums; }
.bar-label { font-size: 0.78rem; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.meter-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.85rem; }
.meter-list li { display: grid; grid-template-columns: minmax(6rem, 10rem) 1fr 3rem; align-items: center; gap: 0.75rem; }
.meter-name { display: flex; align-items: center; gap: 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 0.6rem; border-radius: 999px; background: var(--chip); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--muted); }
.meter-high { background: var(--high); } .meter-normal { background: var(--accent); } .meter-low { background: var(--muted); }
.meter-project { background: var(--pc, var(--accent)); }
.meter-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }

/* ---------- 9. Login and register ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2.5rem; align-items: center; min-height: 60vh; }
.auth-intro h2 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem); max-width: 16ch; }
.sample { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 0.6rem; max-width: 18rem; }
.sample li { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0.9rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-md); }
.sample .dot { width: 1.1rem; height: 1.1rem; border: 2px solid var(--muted); background: transparent; }
.sample .is-done { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.sample .is-done .dot { background: var(--done); border-color: var(--done); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.alt { color: var(--muted); font-size: 0.9rem; margin: 1.25rem 0 0; }

/* ---------- 10. Responsive ---------- */
@media (max-width: 52rem) {
  .board { grid-template-columns: 1fr; gap: 1.25rem; }
  .sidebar { position: static; display: grid; grid-template-columns: auto 1fr; column-gap: 1.25rem; align-items: center; padding: 1rem; }
  .ring { width: 5.5rem; height: 5.5rem; margin: 0; grid-row: span 2; }
  .ring-label { font-size: 1.15rem; }
  .summary-line, .summary-sub { text-align: left; margin: 0; }
  .views, .projects, .side-actions { grid-column: 1 / -1; }
  .views { margin-top: 0.9rem; grid-auto-flow: column; grid-auto-columns: max-content; gap: 0.25rem; overflow-x: auto; }
  .views a { white-space: nowrap; }
  .views .count { margin-left: 0.4rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; gap: 1.5rem; min-height: 0; }
  .auth-intro { display: none; }
  .shortcuts { display: none; }
}
@media (max-width: 32rem) {
  .account-link { display: none; }
  .topbar { gap: 0.4rem; padding-inline: 1rem; }
  .mainnav a { padding: 0.3rem 0.6rem; }
  .account .btn { white-space: nowrap; padding-inline: 0.5rem; }
  .composer-main { flex-direction: column; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input[type="search"] { flex: 1 1 100%; }
  .today { display: none; }
  .meter-list li { grid-template-columns: 5.5rem 1fr 2.6rem; }
}

/* ---------- 11. Motion: the progress ring draws in once ---------- */
@media (prefers-reduced-motion: no-preference) {
  .ring-fill { animation: ring-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
  @keyframes ring-in { from { stroke-dashoffset: 226.19; } }
  .bar { transform-origin: bottom; animation: bar-in 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  @keyframes bar-in { from { transform: scaleY(0); } }
  .btn, .check, .icon-btn, .side-list a, .mainnav a { transition: background-color .15s, color .15s, border-color .15s, filter .15s; }
}
