/* Tasky — clean, white, one-hand friendly.
   Theme tokens (--brand, --on-brand, --brand-ink, --brand-line, --brand-soft) are
   injected per user by base.html from app/themes.py; defaults below = "Azzurro". */
:root {
  --brand: #02abfe;
  --on-brand: #111827;
  --brand-ink: #017db9;
  --brand-line: #badcec;
  --brand-soft: #f0f7fb;

  --tk-text: #111827;
  --tk-muted: #6b7280;
  --tk-line: var(--brand-line);
  --tk-soft: var(--brand-soft);
  --tk-accent: var(--brand);
  --tk-danger: #dc2626;
  --tk-warn: #ea580c;
  --tk-soon: #ca8a04;
  --tk-ok: #16a34a;
  --tk-tabbar-h: 60px;
  --tk-chips-h: 0px;
  --tk-safe-b: env(safe-area-inset-bottom, 0px);
}
body.has-chips { --tk-chips-h: 56px; }

html, body { background: #fff; color: var(--tk-text); }
a { color: var(--brand-ink); }
a:hover { color: var(--brand-ink); filter: brightness(.85); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.has-dock { padding-bottom: calc(var(--tk-tabbar-h) + var(--tk-chips-h) + var(--tk-safe-b) + 88px); }

.tk-container { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.tk-header { padding: 10px 0 8px; }
.tk-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.tk-header .tk-sub { color: var(--tk-muted); font-size: .9rem; }

/* ---------- Task list ---------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--tk-line);
  transition: opacity .25s ease, transform .25s ease;
}
.task-row.urg-overdue { box-shadow: inset 4px 0 0 var(--tk-danger); padding-left: 12px; margin-left: -12px; }
.task-row.is-leaving { opacity: 0; transform: translateX(24px); }

.dot {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: var(--c, #475569);
}
.dot-sm { width: 12px; height: 12px; display: inline-block; vertical-align: middle; }

.task-main { flex: 1 1 auto; min-width: 0; color: inherit; text-decoration: none; padding: 4px 0; }
.task-title { display: block; font-size: 1.05rem; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; font-size: .85rem; color: var(--tk-muted); }

.task-meta .bi { color: var(--brand-ink); }
.task-meta .urg .bi, .task-meta .text-danger { color: inherit; }
.task-meta .bi.text-danger { color: var(--tk-danger) !important; }

.is-done .task-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--tk-muted); }
.is-done .dot { opacity: .45; }

/* Due-date urgency badges */
.urg { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-weight: 600; font-size: .78rem; line-height: 1.4; }
.urg-badge-overdue { background: var(--tk-danger); color: #fff; }
.urg-badge-today, .urg-badge-tomorrow { background: #ffedd5; color: #9a3412; }
.urg-badge-soon { background: #fef9c3; color: #854d0e; }
.urg-badge-overdue .bi { animation: tk-pulse 1.6s ease-in-out infinite; }
@keyframes tk-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .urg-badge-overdue .bi { animation: none; } }

/* Complete button: right side, where the thumb is */
.check {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid var(--brand-line); background: #fff; color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.check:hover, .check:focus-visible { border-color: var(--brand-ink); background: var(--brand-soft); }
.is-done .check { border-color: transparent; background: var(--brand-soft); color: var(--brand-ink); font-size: 1.2rem; }
.check .bi-arrow-counterclockwise { display: none; }
.is-done .check .bi-check-lg { display: none; }
.is-done .check .bi-arrow-counterclockwise { display: inline; }

.tk-empty { text-align: center; color: var(--tk-muted); padding: 48px 16px; }
.tk-empty .bi { font-size: 2.5rem; display: block; margin-bottom: 8px; color: var(--brand-ink); }

/* ---------- Bottom dock: chips + tab bar ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--tk-line);
  padding-bottom: var(--tk-safe-b);
}
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; height: var(--tk-chips-h);
  scrollbar-width: none; max-width: 720px; margin: 0 auto;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--tk-line); background: #fff; color: var(--tk-text);
  font-size: .9rem; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.chip .count { font-size: .75rem; opacity: .7; }
.chip-sep { flex: 0 0 1px; background: var(--tk-line); margin: 4px 2px; }

.tabbar { display: flex; height: var(--tk-tabbar-h); max-width: 720px; margin: 0 auto; border-top: 1px solid var(--tk-line); }
.tabbar a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--tk-muted); text-decoration: none; font-size: .72rem; font-weight: 500;
  position: relative;
}
.tabbar a:hover { filter: none; color: var(--tk-text); }
.tabbar a .bi { font-size: 1.35rem; line-height: 1; color: var(--brand-ink); }
.tabbar a.active { color: var(--brand-ink); font-weight: 700; }
.tabbar a.active::before {
  content: ""; position: absolute; top: -1px; left: 30%; right: 30%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--brand);
}

.fab {
  position: fixed; z-index: 1031; right: max(16px, calc((100vw - 720px) / 2 + 16px));
  bottom: calc(var(--tk-tabbar-h) + var(--tk-chips-h) + var(--tk-safe-b) + 16px);
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(17,24,39,.25); text-decoration: none;
}
.fab:hover { color: var(--on-brand); background: var(--brand); filter: brightness(.93); }

/* Post-completion "how long did it take?" sheet */
.sheet {
  position: fixed; z-index: 1032; left: 8px; right: 8px; max-width: 704px; margin: 0 auto;
  bottom: calc(var(--tk-tabbar-h) + var(--tk-chips-h) + var(--tk-safe-b) + 8px);
  background: var(--tk-text); color: #fff; border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.sheet[hidden] { display: none; }
.sheet .sheet-title { font-size: .9rem; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.sheet .sheet-close { background: none; border: 0; color: #fff; font-size: 1.4rem; line-height: 1; width: 40px; height: 40px; margin: -8px -8px -8px 0; }
.sheet .chips { padding: 0; height: auto; }
.sheet .chip { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

/* ---------- Forms ---------- */
.tk-form .form-label { font-weight: 600; font-size: .9rem; }
.tk-form .form-control, .tk-form .form-select { min-height: 48px; font-size: 1rem; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick label {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--tk-line); border-radius: 999px; cursor: pointer; font-weight: 500; background: #fff;
}
.pick input:checked + label { border-color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-ink); background: var(--brand-soft); }
.pick input:focus-visible + label { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
.tk-form .form-control, .tk-form .form-select { border-color: var(--brand-line); }
.form-control:focus, .form-select:focus { border-color: var(--brand-ink); box-shadow: 0 0 0 .2rem var(--brand-line); }

.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 280px; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches label {
  aspect-ratio: 1; border-radius: 50%; background: var(--c); cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.3rem;
}
.swatches label .bi { visibility: hidden; }
.swatches input:checked + label { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); }
.swatches input:checked + label .bi { visibility: visible; }
.swatches input:focus-visible + label { outline: 2px solid var(--brand-ink); outline-offset: 4px; }

/* Sticky action bar for forms and detail (thumb zone) */
.action-bar {
  position: sticky; bottom: calc(var(--tk-tabbar-h) + var(--tk-safe-b)); z-index: 5;
  background: #fff; padding: 12px 0; border-top: 1px solid var(--tk-line);
  display: flex; gap: 10px;
}
.action-bar .btn { min-height: 52px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
/* Primary buttons wear the brand; outline buttons the ink */
.btn-dark {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-color: var(--on-brand);
  --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-hover-color: var(--on-brand);
  --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand); --bs-btn-active-color: var(--on-brand);
}
.btn-dark:hover, .btn-dark:active { filter: brightness(.93); }
.btn-outline-dark {
  --bs-btn-color: var(--brand-ink); --bs-btn-border-color: var(--brand-ink);
  --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-color: var(--brand-ink); --bs-btn-hover-border-color: var(--brand-ink);
  --bs-btn-active-bg: var(--brand-soft); --bs-btn-active-color: var(--brand-ink); --bs-btn-active-border-color: var(--brand-ink);
}

/* Detail */
.detail-title { font-size: 1.6rem; font-weight: 700; overflow-wrap: anywhere; }
.is-done .detail-title { text-decoration: line-through; color: var(--tk-muted); }
.kv { display: grid; grid-template-columns: 9rem 1fr; gap: 10px 12px; margin: 0; }
.kv dt { color: var(--tk-muted); font-weight: 500; }
.kv dd { margin: 0; }
.notes { white-space: pre-wrap; background: var(--tk-soft); border-radius: 12px; padding: 14px; }

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { border: 1px solid var(--tk-line); border-radius: 14px; padding: 12px; }
.kpi .kpi-v { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .kpi-l { color: var(--tk-muted); font-size: .8rem; }
.chart-box { position: relative; height: 200px; }
.cat-stat { border-bottom: 1px solid var(--tk-line); padding: 14px 0; }
.cat-stat .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; font-size: .9rem; margin-top: 8px; }
.cat-stat .grid span { color: var(--tk-muted); }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

.alert { border-radius: 12px; }

/* ---------- Top bar: logo, calendar card, weather, counters ---------- */
.topbar { padding: 12px 0 12px; border-bottom: 1px solid var(--brand-line); margin-bottom: 6px; }
.topbar-row { display: flex; align-items: center; gap: 12px; }
.topbar-logo img { display: block; width: 48px; height: 48px; }
.topbar-logo:hover { filter: none; }

.cal-card {
  width: 52px; display: flex; flex-direction: column; text-align: center;
  border: 1px solid var(--brand-line); border-radius: 10px; overflow: hidden; background: #fff;
}
.cal-month {
  background: var(--brand); color: var(--on-brand);
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; line-height: 1.6;
}
.cal-day { font-size: 1.35rem; font-weight: 700; line-height: 1.1; padding-top: 2px; font-variant-numeric: tabular-nums; }
.cal-weekday { font-size: .62rem; color: var(--tk-muted); padding-bottom: 3px; }

.weather { margin-left: auto; display: flex; align-items: center; gap: 8px; min-height: 48px; }
.weather-icon { font-size: 2rem; line-height: 1; color: var(--brand-ink); }
.weather-text { display: flex; flex-direction: column; line-height: 1.15; }
.weather-temp { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.weather-place { font-size: .75rem; color: var(--tk-muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weather-loading { font-size: 2rem; color: var(--brand-line); }
.weather-ask {
  height: 40px; padding: 0 14px; border-radius: 999px; font-weight: 500;
  border: 1px solid var(--brand-line); background: #fff; color: var(--brand-ink);
}

.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.counter {
  display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px;
  border: 1px solid var(--brand-line); border-radius: 14px; background: #fff;
  color: inherit; text-decoration: none;
}
.counter:hover { filter: none; color: inherit; background: var(--brand-soft); }
.counter-n { font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.counter-l { font-size: .8rem; color: var(--tk-muted); line-height: 1.25; }
.counter-warn { color: var(--tk-danger); font-weight: 600; }
.counter.active { border-color: var(--brand-ink); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ink); }

/* ---------- Theme picker (profile) ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.theme-grid form { margin: 0; }
.theme-opt {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; border: 1px solid var(--brand-line); border-radius: 14px; background: #fff;
  font-size: .78rem; color: var(--tk-text);
}
.theme-opt img { width: 48px; height: 48px; }
.theme-opt[aria-pressed="true"] { border-color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-ink); background: var(--brand-soft); font-weight: 700; }

/* ---------- Proposals ---------- */
.paste-box summary { font-weight: 600; color: var(--brand-ink); cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; }
.prop-card { border: 1px solid var(--brand-line); border-radius: 16px; padding: 14px; margin-bottom: 16px; }
.prop-source { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--tk-muted); }
.prop-source .bi { color: var(--brand-ink); font-size: 1.1rem; }
.prop-kind { margin-left: auto; background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 2px 10px; font-weight: 600; font-size: .75rem; }
.prop-subject { font-weight: 600; margin-top: 6px; }
.prop-excerpt {
  margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--brand-line); color: var(--tk-muted); font-size: .9rem;
  white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.prop-reason { font-size: .85rem; background: var(--brand-soft); border-radius: 10px; padding: 8px 10px; margin: 8px 0 14px; }
.prop-reason .bi { color: var(--brand-ink); }
.prop-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.prop-actions .btn { min-height: 52px; font-weight: 600; }

/* Inbox shortcut in the top bar */
.inbox-btn {
  position: relative; width: 44px; height: 44px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--brand-line); border-radius: 12px; color: var(--brand-ink); font-size: 1.3rem;
}
.inbox-btn:hover { filter: none; background: var(--brand-soft); }
.inbox-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--tk-danger); color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff;
}

/* ---------- Integrations ---------- */
.integ-card { border: 1px solid var(--brand-line); border-radius: 16px; padding: 14px; margin-bottom: 14px; }
.integ-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.integ-actions form { margin: 0; }
.integ-actions .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.integ-add { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; }
.form-check-input:checked { background-color: var(--brand-ink); border-color: var(--brand-ink); }
.inbound-address {
  padding: 12px; border-radius: 12px; background: var(--brand-soft); border: 1px solid var(--brand-line);
  font-size: .95rem; overflow-wrap: anywhere; user-select: all;
}
