/* ============================================================
   Mamosh APP — structure + Bujo Pro theme (mobile-first)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

:root {
  --font-main: "Nunito", system-ui, "Segoe UI", sans-serif;
  --font-hand: "Caveat", "Lalezar", "Vazirmatn", cursive;
  --nav-h: 62px;
  --wobble: 200px 14px 210px 15px/15px 210px 14px 200px;
  --wobble2: 15px 210px 14px 200px/200px 14px 210px 15px;
  --ink: #3A3F47;
  --dotsize: 19px;
  --cell: 12px; --gap: 3px;
}

html[data-mode="light"] {
  --bg: #FDFCF8; --bg-soft: #FAF7EF; --card: #FFFDF7;
  --text: #33383F; --text-dim: #666C74; --muted: #A2A7AD;
  --border: var(--ink); --border-soft: rgba(58,63,71,.28);
  --accent: #E85D5D; --accent-2: #3E9EE8; --accent-contrast: #FFFDF7;
  --chip-bg: #F3F0E6;
  --shadow: 1.5px 2px 0 rgba(58,63,71,.15);
  --dot: rgba(60,65,72,.20);
  --dial-track: #EEEDE3;
  --now-color: #E85D5D;
  --hl-0: #EEEDE3; --hl-1: #FFE08A; --hl-2: #FFD43B; --hl-3: #FCC419; --hl-4: #F59F00;
  --c-rest: #B9BDC4; --c-meal: #FFA94D; --c-work: #4DABF7; --c-learn: #B197FC;
  --c-body: #69DB7C; --c-fun: #FF85C0; --c-admin: #FFD43B;
  --hl-done: rgba(255,212,59,.45);
  --tip-bg: #33383F; --tip-text: #FFFDF7;
}
html[data-mode="dark"] {
  --bg: #211E19; --bg-soft: #2A2620; --card: #2B2721;
  --text: #ECE6D9; --text-dim: #B4AC9C; --muted: #7E776A;
  --border: #C9C1B0; --border-soft: rgba(201,193,176,.3);
  --accent: #F07B6F; --accent-2: #6CB8EC; --accent-contrast: #211E19;
  --chip-bg: #332E26;
  --shadow: 1.5px 2px 0 rgba(0,0,0,.45);
  --dot: rgba(236,230,217,.10);
  --dial-track: #353027;
  --now-color: #F07B6F;
  --hl-0: #353027; --hl-1: #6E5A24; --hl-2: #8A6F1D; --hl-3: #B08A20; --hl-4: #D9AE2E;
  --c-rest: #6E675A; --c-meal: #E89650; --c-work: #5FA8E8; --c-learn: #9C86D8;
  --c-body: #58B86C; --c-fun: #DE79A8; --c-admin: #D3B53A;
  --hl-done: rgba(217,174,46,.28);
  --tip-bg: #ECE6D9; --tip-text: #211E19;
  --ink: #C9C1B0;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.3px);
  background-size: var(--dotsize) var(--dotsize);
  color: var(--text); font-family: "Vazirmatn", var(--font-main);
  font-size: 15.5px; line-height: 1.55; min-height: 100vh;
  transition: background-color .3s, color .3s;
}
html[lang="en"] body { font-family: var(--font-main); }
html[lang="fa"] body { line-height: 1.85; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
svg.ico { display: block; flex: none; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- shell ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 30px); }
@media (min-width: 900px) { .app { padding-bottom: 40px; } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 38px; height: 38px; flex: none; }
.logo svg { width: 100%; height: 100%; }
.brand-name { font-family: var(--font-hand); font-size: 26px; font-weight: 700; transform: rotate(-1.5deg); display: inline-block; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  min-width: 42px; height: 42px; padding: 0 13px; border-radius: var(--wobble);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13px; font-weight: 700;
  background: var(--card); color: var(--text);
  border: 2px solid var(--border); box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.btn-icon:active { transform: translateY(1px); }
.btn-icon svg { width: 18px; height: 18px; }
.avatar-btn {
  width: 42px; height: 42px; border-radius: 48% 52% 50% 50%/52% 48% 52% 48%;
  border: 2px solid var(--border); background: var(--chip-bg);
  display: grid; place-items: center; font-family: var(--font-hand);
  font-size: 20px; font-weight: 700; color: var(--accent);
  transform: rotate(-3deg); transition: transform .15s ease;
}
.avatar-btn:active { transform: rotate(0); }
html[data-mode="dark"] .i-sun { display: block; } html[data-mode="dark"] .i-moon { display: none; }
html[data-mode="light"] .i-sun { display: none; } html[data-mode="light"] .i-moon { display: block; }

/* ---------- navigation ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around; gap: 2px;
  background: var(--bg); border-top: 2px solid var(--border-soft);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0));
}
@media (min-width: 900px) { .bottom-nav { display: none; } }
.nav-item {
  flex: 1; max-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 12px; color: var(--muted);
  font-size: 10.5px; font-weight: 800; position: relative;
  transition: color .18s ease, transform .15s ease;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item:active { transform: scale(.94); }
.nav-item.active { color: var(--accent); }
.nav-item.active::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%) rotate(-3deg);
  width: 34px; height: 9px; border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 40%, transparent);
}
/* desktop tabs */
.top-tabs { display: none; }
@media (min-width: 900px) {
  .top-tabs { display: flex; gap: 9px; margin: 4px 0 20px; }
  .tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 17px; border: 2px solid var(--border); border-radius: var(--wobble);
    font-size: 14px; font-weight: 800; color: var(--text-dim);
    background: var(--card); box-shadow: var(--shadow); position: relative;
  }
  .tab:nth-child(2n) { border-radius: var(--wobble2); }
  .tab.active { background: var(--accent); color: var(--accent-contrast); }
  .tab.active::after {
    content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%) rotate(-3deg);
    width: 40px; height: 10px; border-radius: 3px;
    background: color-mix(in srgb, var(--accent-2) 45%, transparent);
  }
}

/* ---------- views / cards ---------- */
.view { display: none; }
.view.active { display: block; animation: viewIn .3s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--wobble);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card:nth-child(2n) { border-radius: var(--wobble2); }
.card h3 {
  margin: 0 0 12px; font-family: var(--font-hand); font-size: 21px; font-weight: 700;
  transform: rotate(-.5deg); display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.view-title { font-family: var(--font-hand); font-size: clamp(28px, 6vw, 36px); font-weight: 700; transform: rotate(-1deg); margin: 2px 0 14px; display: inline-block; }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: 2px solid var(--border); border-radius: var(--wobble);
  background: var(--card); font-weight: 800; font-size: 14px; box-shadow: var(--shadow);
  transition: transform .15s ease, background-color .2s, color .2s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.subtle { background: var(--chip-bg); }
.btn.danger { color: #D64545; border-color: #D64545; }
.btn.sm { padding: 7px 13px; font-size: 12.5px; }
.btn svg { width: 17px; height: 17px; }
.btn.block { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 800; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select, .input {
  width: 100%; padding: 12px 14px; font-size: 16px; /* no iOS zoom */
  background: var(--bg-soft); border: 2px solid var(--border-soft); border-radius: 10px;
  color: var(--text); transition: border-color .2s;
}
.field input:focus, .field select:focus, .input:focus { outline: none; border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.form-error { color: #D64545; font-size: 13px; font-weight: 700; min-height: 20px; margin: 4px 0; }

.seg { display: inline-flex; background: var(--chip-bg); border: 2px solid var(--border-soft); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 800; color: var(--text-dim); }
.seg button.active { background: var(--accent); color: var(--accent-contrast); }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border: 2px solid var(--border-soft); border-radius: var(--wobble2);
  font-size: 13px; font-weight: 800; color: var(--text-dim); background: var(--card);
  transition: all .18s ease;
}
.chip svg { width: 16px; height: 16px; }
.chip.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); transform: rotate(-1deg); }

/* ---------- hero (today) ---------- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 2px 18px; flex-wrap: wrap; }
.date-line { font-size: 12.5px; font-weight: 800; color: var(--accent); letter-spacing: .3px; }
.greeting { margin: 3px 0 6px; font-family: var(--font-hand); font-size: clamp(32px, 6vw, 44px); font-weight: 700; transform: rotate(-1deg); display: inline-block; line-height: 1.2; }
.greeting::after { content: ""; display: block; height: 8px; border-radius: 40% 55% 45% 50%; background: linear-gradient(90deg, var(--accent), transparent 94%); opacity: .5; }
.hero-sub { margin: 0; color: var(--text-dim); font-size: 14px; }
.week-strip { display: flex; gap: 6px; margin-top: 12px; direction: ltr; flex-wrap: wrap; }
.ws-day { width: 40px; padding: 6px 0 5px; text-align: center; border-radius: 9px 12px 10px 13px/12px 10px 13px 9px; background: var(--chip-bg); border: 1.5px solid transparent; }
.ws-day .ws-w { display: block; font-size: 10px; color: var(--muted); font-weight: 800; }
.ws-day .ws-d { display: block; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ws-day.wknd { background: transparent; border-color: var(--border-soft); }
.ws-day.today { background: transparent; border: 2px solid var(--accent); border-radius: 48% 52% 50% 50%/52% 48% 52% 48%; transform: rotate(-2deg); }
.ws-day.today .ws-d { color: var(--accent); }

.progress-wrap { position: relative; width: 112px; height: 112px; flex: none; }
.progress-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-wrap .track { fill: none; stroke: var(--dial-track); stroke-width: 8; }
.progress-wrap .bar { fill: none; stroke: var(--accent); stroke-width: 7.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.7,.3,1); }
.progress-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.progress-label b { font-size: 22px; font-weight: 800; }
.progress-label span { font-size: 10.5px; color: var(--text-dim); }

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-bottom: 16px; }
.stat { display: flex; align-items: center; gap: 11px; padding: 13px 14px; background: var(--card); border: 2px solid var(--border); border-radius: var(--wobble); }
.stat:nth-child(2) { transform: rotate(.6deg); }
.stat:nth-child(3) { transform: rotate(-.5deg); }
.stat-ico { width: 40px; height: 40px; display: grid; place-items: center; flex: none; background: var(--chip-bg); border-radius: 10px; color: var(--accent); }
.stat-ico svg { width: 19px; height: 19px; }
.stat b { display: block; font-size: 16.5px; font-weight: 800; }
.stat span { font-size: 11.5px; color: var(--text-dim); }

/* ---------- tasks ---------- */
.add-task { display: flex; gap: 8px; margin-bottom: 13px; }
.add-task input { flex: 1; min-width: 0; }
.add-task button { width: 50px; flex: none; border: 2px solid var(--border); border-radius: var(--wobble2); background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; box-shadow: var(--shadow); }
.add-task button svg { width: 20px; height: 20px; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.task { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--bg-soft); border-radius: 10px; animation: viewIn .25s ease; }
.task .chk { width: 27px; height: 27px; flex: none; border: 2px solid var(--border); border-radius: 7px 4px 8px 5px/5px 8px 4px 7px; display: grid; place-items: center; color: transparent; background: transparent; transition: all .18s ease; }
.task .chk svg { width: 14px; height: 14px; }
.task .chk:hover { transform: rotate(-4deg) scale(1.06); }
.task.done .chk { border-color: var(--accent); color: var(--accent); transform: rotate(-5deg); }
.task .t-title { flex: 1; min-width: 0; font-weight: 650; font-size: 14.5px; overflow-wrap: anywhere; }
.task.done .t-title { color: var(--text-dim); background: linear-gradient(0deg, transparent 40%, var(--hl-done) 40%, var(--hl-done) 92%, transparent 92%); border-radius: 3px; padding-inline: 4px; animation: markerSweep .45s cubic-bezier(.2,.7,.3,1); }
@keyframes markerSweep { from { background-size: 0% 100%; background-repeat: no-repeat; } to { background-size: 100% 100%; background-repeat: no-repeat; } }
.task .t-meta { display: flex; align-items: center; gap: 7px; flex: none; }
.pri { width: 8px; height: 8px; border-radius: 50%; }
.pri.p2 { background: #E85D5D; } .pri.p1 { background: #F0A93E; } .pri.p0 { background: var(--border-soft); }
.est { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.task .del { flex: none; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.task .del svg { width: 13px; height: 13px; }
.task:hover .del, .task .del:focus-visible { opacity: 1; }
.task .del:hover { color: #D64545; background: rgba(214,69,69,.12); }
.filters { display: flex; gap: 5px; }
.filter-btn { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; color: var(--text-dim); border: 1.5px solid transparent; }
.filter-btn.active { border-color: var(--border-soft); background: var(--chip-bg); color: var(--accent); }
.empty-note { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--text-dim); padding: 28px 10px; font-size: 14px; }
.empty-note .en-ico { color: var(--accent); opacity: .85; }

.today-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .today-grid { grid-template-columns: 1.7fr 1fr; } }
.side { display: grid; gap: 16px; }

/* mini habits */
.mini-habit { display: flex; align-items: center; gap: 11px; padding: 9px 2px; border-bottom: 1.5px dashed var(--border-soft); }
.mini-habit:last-child { border-bottom: none; }
.mh-ico { width: 34px; height: 34px; display: grid; place-items: center; background: var(--chip-bg); border-radius: 9px; flex: none; color: var(--accent); }
.mh-ico svg { width: 17px; height: 17px; }
.mh-name { flex: 1; font-size: 13.5px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--dial-track); }
.mh-dot.on { background: var(--accent); }
.mh-dot.today { width: 15px; height: 15px; border: 2px solid var(--accent); }
.mh-dot.today.on { background: var(--accent); }
.mh-dots { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.upnext-item { display: flex; align-items: center; gap: 11px; padding: 9px 2px; }
.un-time { font-size: 12.5px; font-weight: 800; color: var(--accent); border: 1.5px solid var(--border-soft); padding: 3px 9px; border-radius: 8px; font-variant-numeric: tabular-nums; background: transparent; }
.un-name { font-size: 13.5px; font-weight: 700; }

/* ---------- heatmap ---------- */
.heatmap-scroll { overflow-x: auto; padding: 4px 2px 8px; }
.heatmap { display: inline-grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--cell)); grid-auto-columns: var(--cell); gap: var(--gap); direction: ltr; }
.hm-cell { width: var(--cell); height: var(--cell); border-radius: 50%; background: var(--hl-0); }
.hm-cell.l1 { background: var(--hl-1); } .hm-cell.l2 { background: var(--hl-2); }
.hm-cell.l3 { background: var(--hl-3); } .hm-cell.l4 { background: var(--hl-4); }
.hm-cell:hover { outline: 1.5px solid var(--text-dim); outline-offset: -1px; }
.hm-months { display: grid; position: relative; height: 16px; margin-bottom: 4px; margin-inline-start: calc(30px + var(--gap)); direction: ltr; }
.hm-months span { position: absolute; top: 0; font-size: 10px; color: var(--muted); white-space: nowrap; }
.hm-flex { display: flex; gap: var(--gap); align-items: flex-start; }
.hm-labels { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: var(--gap); width: 30px; flex: none; direction: ltr; }
.hm-labels span { font-size: 9.5px; color: var(--muted); line-height: var(--cell); height: var(--cell); }
.heatmap-legend { display: flex; align-items: center; gap: 5px; margin-top: 9px; font-size: 11px; color: var(--text-dim); flex-wrap: wrap; }
.heatmap-legend .s { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.streak-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 800; padding: 5px 12px; border: 2px solid var(--accent); color: var(--accent); background: transparent; transform: rotate(-1.5deg); border-radius: var(--wobble2); }
.streak-chip svg { width: 14px; height: 14px; }

.habit-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .habit-grid { grid-template-columns: repeat(2, 1fr); } }
.habit-card .hc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.hc-ico { color: var(--accent); display: inline-flex; } .hc-ico svg { width: 19px; height: 19px; }
.hc-name { font-weight: 800; font-size: 14.5px; flex: 1; min-width: 0; }
.hc-streak { font-size: 12px; font-weight: 800; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.hc-streak svg { width: 12px; height: 12px; }
.hc-goal { font-size: 11.5px; color: var(--text-dim); margin-bottom: 11px; }
.hc-bar { height: 7px; border-radius: 99px 92px 99px 95px/95px 99px 92px 99px; background: var(--dial-track); overflow: hidden; margin-bottom: 12px; }
.hc-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s cubic-bezier(.2,.7,.3,1); }
.hc-days { display: flex; justify-content: space-between; gap: 4px; direction: ltr; }
.hc-day { flex: 1; text-align: center; }
.hc-day .d-lbl { font-size: 9.5px; color: var(--muted); display: block; margin-bottom: 5px; }
.hc-day .d-chk { width: 100%; aspect-ratio: 1; max-width: 34px; margin: 0 auto; border: 2px solid var(--border); border-radius: 48% 52% 50% 50%/52% 48% 52% 48%; display: grid; place-items: center; color: transparent; background: transparent; transition: all .18s ease; }
.hc-day .d-chk svg { width: 12px; height: 12px; }
.hc-day .d-chk.on { color: var(--accent); border-color: var(--accent); }
.hc-day .d-chk.today { border-color: var(--accent); }
.hc-day .d-chk:active { transform: scale(.92); }

/* ---------- routine ---------- */
.routine-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .routine-grid { grid-template-columns: minmax(320px, 1.05fr) 1fr; } }
.routine-side { display: grid; gap: 16px; }
.dial-wrap { position: relative; max-width: 480px; margin: 2px auto 0; }
.dial-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.dial-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46%; text-align: center; pointer-events: none; }
.dc-time { font-family: var(--font-hand); font-size: clamp(30px, 7vw, 42px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dc-now { font-size: 10.5px; color: var(--text-dim); letter-spacing: 1px; }
.dc-act { font-size: clamp(13px, 2.4vw, 15px); font-weight: 800; margin-top: 2px; }
.dc-range { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.dial-hint { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.cat-rest { fill: var(--c-rest); background: var(--c-rest); }
.cat-meal { fill: var(--c-meal); background: var(--c-meal); }
.cat-work { fill: var(--c-work); background: var(--c-work); }
.cat-learn { fill: var(--c-learn); background: var(--c-learn); }
.cat-body { fill: var(--c-body); background: var(--c-body); }
.cat-fun { fill: var(--c-fun); background: var(--c-fun); }
.cat-admin { fill: var(--c-admin); background: var(--c-admin); }
.seg { display: inline-flex; background: var(--chip-bg); border: 2px solid var(--border-soft); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 800; color: var(--text-dim); }
.seg button.active { background: var(--accent); color: var(--accent-contrast); }
.tick { stroke: var(--border-soft); stroke-width: 1; }
.tick.major { stroke: var(--text-dim); stroke-width: 1.6; }
.tick-label { fill: var(--text-dim); font-size: 12px; font-family: var(--font-main); font-variant-numeric: tabular-nums; }
html[lang="fa"] .tick-label { font-family: "Vazirmatn"; font-size: 13px; }
.now-hand { stroke: var(--now-color); stroke-width: 2.2; stroke-linecap: round; }
.now-dot { fill: var(--now-color); }
.dial-track { fill: none; stroke: var(--dial-track); }
.seg-p { stroke: transparent; stroke-width: 15px; pointer-events: all; cursor: pointer; transition: transform .22s cubic-bezier(.2,.7,.3,1.2), opacity .2s ease, filter .2s ease; }
.seg-p.hl { filter: brightness(1.12) saturate(1.12); }
.dial-dim .seg-p:not(.hl) { opacity: .3; }
.linear-day { direction: ltr; position: relative; padding-top: 4px; }
.ld-bar { position: relative; height: 50px; border-radius: 9px; overflow: hidden; background: var(--dial-track); }
.ld-seg { position: absolute; top: 0; bottom: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: filter .18s, opacity .2s; }
.ld-seg span { font-size: 10.5px; font-weight: 800; color: #fff; padding: 0 5px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; display: none; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.ld-seg.wide span { display: block; }
.ld-seg.hl { filter: brightness(1.18); }
.linear-day.dim .ld-seg:not(.hl) { opacity: .38; }
.ld-now { position: absolute; top: 2px; bottom: 2px; width: 2px; background: var(--now-color); border-radius: 2px; }
.ld-hours { position: relative; height: 17px; margin-top: 5px; }
.ld-hours span { position: absolute; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.legend-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 1.5px solid transparent; }
.legend-list li:hover, .legend-list li.hl { background: var(--bg-soft); border-color: var(--border-soft); }
.lg-dot { width: 13px; height: 13px; border-radius: 48% 52% 50% 50%/52% 48% 52% 48%; flex: none; }
.lg-name { flex: 1; font-size: 13.5px; font-weight: 700; min-width: 0; }
.lg-range { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- timer ---------- */
.timer-card { text-align: center; }
.timer-cats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.timer-face { position: relative; width: min(78vw, 300px); margin: 0 auto 18px; }
.timer-face svg { width: 100%; height: auto; transform: rotate(-90deg); }
.timer-face .track { fill: none; stroke: var(--dial-track); stroke-width: 8; }
.timer-face .bar { fill: none; stroke: var(--accent); stroke-width: 7.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke-dashoffset .5s linear; }
.timer-mid { position: absolute; inset: 0; display: grid; place-content: center; }
.timer-mid b { font-family: var(--font-hand); font-size: clamp(40px, 11vw, 58px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.timer-mid span { font-size: 12px; color: var(--text-dim); font-weight: 700; }
.timer-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.timer-week { display: flex; justify-content: center; gap: 22px; margin-top: 18px; flex-wrap: wrap; }
.tw-item b { display: block; font-size: 21px; font-weight: 800; font-family: var(--font-hand); font-size: 27px; }
.tw-item span { font-size: 11.5px; color: var(--text-dim); }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.avatar-big { width: 74px; height: 74px; flex: none; border: 3px solid var(--border); border-radius: 48% 52% 50% 50%/52% 48% 52% 48%; background: var(--chip-bg); display: grid; place-items: center; font-family: var(--font-hand); font-size: 38px; font-weight: 700; color: var(--accent); transform: rotate(-3deg); }
.profile-name { font-family: var(--font-hand); font-size: 30px; font-weight: 700; line-height: 1.1; }
.profile-user { font-size: 12.5px; color: var(--muted); direction: ltr; unicode-bidi: plaintext; }
.level-card { display: flex; align-items: center; gap: 16px; }
.level-num { font-family: var(--font-hand); font-size: 46px; font-weight: 700; color: var(--accent); line-height: 1; }
.level-bar { flex: 1; }
.level-bar .hc-bar { margin-bottom: 6px; }
.level-pts { font-size: 12.5px; color: var(--text-dim); font-weight: 700; }
.ledger { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ledger li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1.5px dashed var(--border-soft); font-size: 13.5px; }
.ledger li:last-child { border-bottom: none; }
.ledger .l-reason { flex: 1; font-weight: 650; }
.ledger .l-delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.ledger .l-delta.pos { color: #58B86C; } .ledger .l-delta.neg { color: #D64545; }
.ledger .l-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.lb-list li { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; font-size: 14px; }
.lb-list li.me { background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1.5px dashed var(--accent); }
.lb-rank { width: 26px; height: 26px; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.lb-rank.top1 { background: var(--hl-2); color: #6B5A10; border-radius: 50% 42% 55% 45%/48% 52% 45% 55%; }
.lb-name { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }

/* ---------- settings / editors ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 4px; border-bottom: 1.5px dashed var(--border-soft); flex-wrap: wrap; }
.set-row:last-child { border-bottom: none; }
.set-label { font-weight: 700; font-size: 14px; }
.set-desc { font-size: 11.5px; color: var(--muted); }
.routine-edit-row { display: grid; grid-template-columns: 86px 86px 1fr 96px 38px; gap: 7px; margin-bottom: 8px; align-items: center; }
.routine-edit-row select, .routine-edit-row input { padding: 9px 8px; font-size: 14px; }
.habit-edit-row { display: grid; grid-template-columns: 92px 1fr 74px 38px; gap: 7px; margin-bottom: 8px; align-items: center; }
.habit-edit-row input, .habit-edit-row select { padding: 9px 8px; font-size: 14px; }
@media (max-width: 560px) {
  .routine-edit-row { grid-template-columns: 78px 78px 1fr 84px 34px; }
  .habit-edit-row { grid-template-columns: 80px 1fr 64px 34px; }
}
.icon-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-pick button { width: 40px; height: 40px; border: 2px solid var(--border-soft); border-radius: 10px; display: grid; place-items: center; color: var(--text-dim); }
.icon-pick button.on { border-color: var(--accent); color: var(--accent); transform: rotate(-4deg); }
.icon-pick svg { width: 18px; height: 18px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); padding: 26px 24px 24px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 6px; }
.login-logo .logo { width: 54px; height: 54px; }
.login-title { text-align: center; font-family: var(--font-hand); font-size: 34px; font-weight: 700; transform: rotate(-1deg); margin: 0 0 2px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0 0 18px; }
.login-topbar { position: fixed; top: 14px; inset-inline-end: 14px; display: flex; gap: 8px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0)); left: 50%;
  transform: translateX(-50%) translateY(8px); z-index: 60;
  background: var(--tip-bg); color: var(--tip-text);
  padding: 10px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease; max-width: 88vw; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { #toast { bottom: 26px; } }

#tip { position: fixed; z-index: 99; pointer-events: none; background: var(--tip-bg); color: var(--tip-text);
  padding: 7px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,.28); opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; }
#tip.on { opacity: 1; transform: translateY(0); }

.skel { background: linear-gradient(90deg, var(--chip-bg), var(--bg-soft), var(--chip-bg)); background-size: 200% 100%; animation: skel 1.2s linear infinite; border-radius: 10px; min-height: 60px; }
@keyframes skel { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ================= v2 additions ================= */
.list-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); background: var(--chip-bg); border-radius: 7px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.mini-tag svg { width: 11px; height: 11px; }
.t-sub { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.sub-chk-btn { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 6px; transition: transform .2s; flex: none; }
.sub-chk-btn svg { width: 14px; height: 14px; }
.subtask-row { display: flex; align-items: center; gap: 9px; padding: 7px 4px 7px 14px; border-bottom: 1.5px dashed var(--border-soft); font-size: 13.5px; }
.subtask-row:last-child { border-bottom: none; }
.subtask-row.done span { text-decoration: line-through; color: var(--muted); }
.chk.sm2 { width: 20px; height: 20px; border-radius: 6px 3px 7px 4px/4px 7px 3px 6px; border-width: 1.5px; }
.chk.sm2 svg { width: 10px; height: 10px; }
.subtasks-box { margin-top: 6px; }

/* editor sheet */
.ed-backdrop { position: fixed; inset: 0; background: rgba(20,17,12,.45); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .25s; }
.ed-backdrop.on { opacity: 1; pointer-events: auto; }
.ed-sheet { position: fixed; z-index: 81; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto;
  background: var(--card); border-top: 2.5px solid var(--border); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom, 0)); transform: translateY(105%); transition: transform .3s cubic-bezier(.2,.7,.3,1); }
.ed-sheet.on { transform: translateY(0); }
@media (min-width: 700px) { .ed-sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; max-height: 82vh; transform: translate(-50%, -46%) scale(.96); opacity: 0; pointer-events: none; border-radius: var(--wobble); }
  .ed-sheet.on { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; } }
.ed-grab { width: 44px; height: 5px; border-radius: 99px; background: var(--border-soft); margin: 4px auto 10px; }
@media (min-width: 700px) { .ed-grab { display: none; } }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ed-head h3 { margin: 0; font-family: var(--font-hand); font-size: 24px; }
.ed-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-sec { border-top: 1.5px dashed var(--border-soft); margin-top: 14px; padding-top: 12px; }
.ed-sec > b { font-size: 13px; color: var(--text-dim); }
.att-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1.5px dashed var(--border-soft); font-size: 13px; }
.att-row:last-child { border-bottom: none; }

/* search overlay */
.search-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(20,17,12,.45); display: none; padding: 20px; overflow: auto; }
.search-overlay.on { display: grid; place-items: start center; }
.search-panel { width: min(520px, 100%); margin-top: 8vh; }
.sr-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 10px 8px; border-radius: 10px; font-size: 14px; border-bottom: 1.5px dashed var(--border-soft); color: var(--text); }
.sr-row:hover { background: var(--bg-soft); }
.sr-row svg { color: var(--muted); }
.no-res2 { text-align: center; color: var(--muted); padding: 20px; font-size: 13.5px; }

/* week view */
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
@media (max-width: 860px) { .week-grid { grid-template-columns: repeat(2, 1fr); } .week-grid .week-col:last-child { grid-column: span 2; } }
.week-col { background: var(--bg-soft); border: 2px solid var(--border-soft); border-radius: 12px 9px 13px 10px/10px 13px 9px 12px; padding: 8px; min-height: 120px; }
.week-col.today { border-color: var(--accent); transform: rotate(-.4deg); }
.wc-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.wc-head b { font-size: 12px; } .wc-head span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wc-add { margin-inline-start: auto; width: 24px; height: 24px; border-radius: 7px; color: var(--accent); display: grid; place-items: center; }
.wc-add svg { width: 13px; height: 13px; }
.wc-timeline { position: relative; height: 90px; border-radius: 8px; overflow: hidden; background: var(--chip-bg); margin-bottom: 8px; }
.rb { position: absolute; left: 0; right: 0; opacity: .5; }
.tpill { position: absolute; left: 2px; right: 2px; z-index: 2; background: var(--card); border: 1.5px solid var(--accent);
  color: var(--text); border-radius: 7px; font-size: 9.5px; font-weight: 800; padding: 1px 4px; text-align: start; overflow: hidden; white-space: nowrap; }
.tpill.done { border-color: var(--border-soft); color: var(--muted); text-decoration: line-through; }
.wc-untimed { display: flex; flex-direction: column; gap: 4px; }
.task-chip { text-align: start; background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 8px; padding: 3px 7px; font-size: 11px; font-weight: 700; color: var(--text); }
.task-chip.done { text-decoration: line-through; color: var(--muted); }
.more-lbl { font-size: 10.5px; color: var(--muted); text-align: center; }

/* review card */
.mood-row { display: flex; gap: 8px; }
.mood-btn { width: 46px; height: 46px; border: 2px solid var(--border-soft); border-radius: 48% 52% 50% 50%/52% 48% 52% 48%; display: grid; place-items: center; color: var(--muted); font-size: 20px; transition: all .15s; }
.mood-btn[data-m="1"] { filter: grayscale(.9); } .mood-btn[data-m="2"] { filter: grayscale(.6); }
.mood-btn[data-m="4"] { color: var(--accent); } .mood-btn[data-m="5"] { color: var(--accent); transform: rotate(-6deg); }
.mood-btn:hover { border-color: var(--accent); transform: scale(1.08); }
.wr-bars { display: flex; gap: 8px; align-items: flex-end; justify-content: space-between; }
.wr-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wr-day { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.wr-bar { width: 100%; max-width: 34px; height: 90px; background: var(--chip-bg); border-radius: 8px 8px 4px 4px; display: flex; align-items: flex-end; overflow: hidden; }
.wr-bar i { display: block; width: 100%; background: var(--accent); border-radius: inherit; opacity: .8; }
.wr-num { font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wr-mood { font-size: 13px; height: 16px; }
