/* Daily Planner Pro – web. Colours copied from desktop Ui.cs. */
:root {
    --big: #F59E0B;
    --medium: #3B82F6;
    --small: #10B981;
    --pending: #F97316;
    --danger: #EF4444;
    --accent: #6366F1;
    --sidebar: #0B1220;
    --radius: 14px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="light"] {
    --bg: #F4F6FA;
    --card: #FFFFFF;
    --border: #E3E8EF;
    --text: #0F172A;
    --muted: #64748B;
    --faint: #94A3B8;
    --hover: #F1F5F9;
}

html[data-theme="dark"] {
    --bg: #0F172A;
    --card: #1E293B;
    --border: #2B3A52;
    --text: #E2E8F0;
    --muted: #94A3B8;
    --faint: #64748B;
    --hover: #26344A;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.6rem; margin: 0; font-weight: 650; outline: none; }
h2 { font-size: 1.05rem; margin: 0 0 10px; font-weight: 600; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.grow { flex: 1; }
.icon { flex-shrink: 0; }

/* ---------- loading ---------- */
.loading {
    height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; color: var(--muted);
}

/* ---------- shell: phone first ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }

.content {
    padding: 20px 16px calc(84px + env(safe-area-inset-bottom));
    max-width: 1100px;
    margin: 0 auto;
}

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; justify-content: space-around;
    background: var(--card); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.bottom-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 0; font-size: 0.72rem; color: var(--muted); text-decoration: none; border-radius: 10px;
}
.bottom-link.active { color: var(--accent); font-weight: 600; }

/* ---------- tablet / desktop: sidebar ---------- */
@media (min-width: 900px) {
    .shell { display: grid; grid-template-columns: 240px 1fr; }
    .bottom-nav { display: none; }
    .content { padding: 32px 36px; width: 100%; }

    .sidebar {
        display: flex; flex-direction: column;
        position: sticky; top: 0; height: 100vh;
        background: var(--sidebar); color: #CBD5E1; padding: 20px 14px;
        overflow-y: auto;
    }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-name { font-weight: 650; color: #FFFFFF; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: var(--accent); color: #FFFFFF; font-weight: 700; font-size: 0.8rem;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px;
    border-radius: 10px; color: #CBD5E1; text-decoration: none;
}
.side-link:hover { background: rgba(255, 255, 255, 0.06); }
.side-link.active { background: var(--accent); color: #FFFFFF; }

.side-art {
    margin-top: auto; position: relative; height: 30vh; min-height: 150px; max-height: 290px;
    border-radius: 12px; overflow: hidden; flex-shrink: 0;
}
.side-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: bottom; }
.side-shade { position: absolute; inset: 0; background: linear-gradient(rgba(11,18,32,0) 55%, rgba(11,18,32,0.92)); }
.quote {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 0 16px 16px;
    font-size: 0.85rem; font-style: italic; color: #FFFFFF; line-height: 1.4; text-align: center;
}
.quote.plain-quote { position: static; margin-top: auto; padding: 16px 8px 4px; color: #CBD5E1; border-top: 1px solid #1E293B; }

/* ---------- page parts ---------- */
.page-head { margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }

.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}

.empty { text-align: center; padding: 40px 20px; }
.empty-icon {
    width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.empty p { color: var(--muted); max-width: 420px; margin: 6px auto 0; line-height: 1.5; }
.empty h2, .empty p { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; }   /* full text, never cut off */

.list { padding: 4px 0; }
.list-row {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px;
    color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--hover); }

/* ---------- settings controls ---------- */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.segmented button { border: none; background: transparent; padding: 8px 18px; }
.segmented button.on { background: var(--accent); color: #FFFFFF; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
    width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid var(--border); padding: 0;
}
.swatch.system { background: var(--card); font-size: 0.75rem; color: var(--muted); }
.swatch.on { outline: 3px solid var(--text); outline-offset: 2px; }

.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- error bar ---------- */
#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    background: #FEF3C7; color: #78350F; padding: 12px 16px;
}
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* =================== Phase 3: shared controls =================== */
.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--card); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.small-btn { padding: 5px 12px; font-size: 0.85rem; }
.link { background: none; border: none; color: var(--accent); padding: 4px 6px; display: inline-flex; align-items: center; gap: 5px; }
.icon-btn {
    background: none; border: none; color: var(--muted); padding: 6px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.tiny { padding: 2px; color: var(--c, var(--muted)); }

.field {
    width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--bg); color: var(--text); font: inherit;
}
.field:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
textarea.field { resize: vertical; }
.label { display: block; font-size: 0.85rem; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.error { color: var(--danger); font-size: 0.85rem; margin: 6px 0 0; }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.pill {
    display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
    color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
}
.pill.solid { background: var(--accent); color: #FFFFFF; padding: 4px 12px; font-size: 0.8rem; }

/* ---------- modal ---------- */
.modal-back {
    position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
    width: 100%; max-height: 90vh; display: flex; flex-direction: column;
    background: var(--card); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 6px 18px 12px; overflow-y: auto; line-height: 1.5; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
@media (max-width: 600px) {
    .modal-back { align-items: flex-end; padding: 0; }
    .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }
}

.quick-dates { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented button.on { color: #FFFFFF; }

/* why dialog */
.tier { display: flex; gap: 14px; padding: 8px; border-radius: 10px; margin-bottom: 6px; }
.tier.picked { background: color-mix(in srgb, var(--c) 10%, transparent); }
.tier-badge {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem; color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent);
}
.tier-name { color: var(--c); }
.tier p { margin: 2px 0 0; }
.why-list { padding-left: 18px; color: var(--muted); }
.why-list b { color: var(--text); }

/* review / carry lists */
.review-list { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-top: 6px; padding: 4px 0; max-height: 50vh; overflow-y: auto; }
.review-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.review-row input { width: 18px; height: 18px; flex-shrink: 0; }
.status { white-space: pre-line; color: var(--muted); font-size: 0.9rem; }

/* =================== Today page =================== */
.today-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.today-head h1 { margin-right: 6px; }

.today-top { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 12px; }
.greeting { display: flex; align-items: center; gap: 14px; flex: 1 1 300px; }
.greeting h2 { font-size: 1.3rem; margin: 0; }
.greeting p { margin: 2px 0 0; }
.greet-icon { display: flex; }

.stats-card { display: flex; align-items: center; gap: 4px; margin: 0; padding: 12px; flex: 0 1 auto; }
.ring {
    width: 74px; height: 74px; border-radius: 50%; flex-shrink: 0; margin-right: 8px;
    background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
    display: flex; align-items: center; justify-content: center;
}
.ring > div {
    width: 60px; height: 60px; border-radius: 50%; background: var(--card);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring small { font-size: 0.65rem; color: var(--muted); }
.counter {
    display: flex; flex-direction: column; align-items: center; gap: 2px; width: 96px; padding: 4px;
    background: none; border: none; border-left: 1px solid var(--border); border-radius: 0; text-align: center;
}
button.counter:hover { background: var(--hover); border-radius: 8px; }
.counter b { font-size: 1.4rem; color: var(--c); }
.counter span { font-size: 0.72rem; color: var(--muted); line-height: 1.2; }

.banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px;
    border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--pending) 45%, transparent);
    background: color-mix(in srgb, var(--pending) 9%, var(--card));
}
.banner p { margin: 2px 0 0; font-size: 0.88rem; }
.banner-icon { color: var(--pending); display: flex; }

.feel-card { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px; background: color-mix(in srgb, #A855F7 6%, var(--card)); }
.feel-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.feel-label .icon { color: #A855F7; }
.feel-card .field { flex: 1 1 220px; width: auto; }

.today-body { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 1100px) { .today-body { grid-template-columns: 1fr 320px; } }
.tasks-card { margin: 0; }
.side-col .card { margin-bottom: 14px; }

.tasks-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tasks-bar .search { width: 190px; }
.check.small { font-size: 0.85rem; color: var(--muted); padding: 0; }
.check.small input { width: 16px; height: 16px; }
.expand-links { display: flex; align-items: center; gap: 2px; margin: 6px 0 2px; font-size: 0.85rem; }
.hint { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 8px 4px; }
.hint .icon { color: var(--big); }

.group-head {
    display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
    margin: 12px 0 4px; padding: 8px 12px; border-radius: 10px; color: var(--c);
    background: color-mix(in srgb, var(--c) 12%, transparent);
}
.group-title { font-size: 0.98rem; }
.mini-bar { width: 70px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--border)); overflow: hidden; display: inline-block; }
.mini-bar > span { display: block; height: 100%; background: var(--c, var(--accent)); }
.mini-bar.wide { width: 90px; --c: var(--accent); margin: 0 8px; }

.task-row, .step-row { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 8px; min-height: 38px; }
.task-row:hover, .step-row:hover { background: var(--hover); }
.type-bar { width: 3px; align-self: stretch; margin: 4px 2px; border-radius: 2px; background: var(--c); flex-shrink: 0; }
.tick { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--c); }
.inline {
    flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; color: var(--text);
    font: inherit; padding: 6px 8px; border-radius: 8px;
}
.inline:focus { border-color: var(--border); background: var(--card); outline: none; }
.inline.strong { font-weight: 600; }
.task-text { flex: 1; min-width: 0; padding: 6px 8px; overflow-wrap: anywhere; }
.finished .task-text { color: var(--faint); text-decoration: line-through; }
.note { font-size: 0.75rem; color: var(--faint); white-space: nowrap; }
.row-actions { display: flex; gap: 0; opacity: .45; transition: opacity .12s; }
.task-row:hover .row-actions, .step-row:hover .row-actions, .row-actions:focus-within { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

.step-row { margin-left: 34px; font-size: 0.92rem; }
.step-row .inline { color: var(--muted); }
.steps-info { margin: 2px 0 4px 44px; font-size: 0.78rem; }
.steps-done { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px 44px; font-size: 0.88rem; color: var(--small); }
.add-line {
    display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--faint);
    padding: 6px 0 6px 36px; font-size: 0.88rem;
}
.add-line:hover { color: var(--accent); }
.add-line.step-add { padding-left: 44px; }
.add-line.stuck { color: var(--big); }

.card-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.card-title .icon { color: var(--accent); }
.glance { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; color: var(--muted); font-size: 0.9rem; }
.glance b { color: var(--text); }
.glance > span:first-child { flex: 1; }

.moods { display: flex; flex-wrap: wrap; gap: 6px; }
.mood { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: 0.8rem; }
.mood.on { border-color: var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); font-weight: 600; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
    display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 10px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.tile:hover { background: var(--hover); }
.tile .icon { color: var(--accent); }
.tile span { display: flex; flex-direction: column; font-size: 0.85rem; }
.tile small { color: var(--muted); }

@media (max-width: 600px) {
    .stats-card { width: 100%; justify-content: space-between; }
    .counter { width: auto; flex: 1; }
    .tasks-bar .search { width: 100%; }
}

/* =================== Settings =================== */
.settings-section h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.settings-section h2 .icon { color: var(--accent); }
.setting-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-text { flex: 1 1 260px; min-width: 0; }
.setting-text b { display: block; font-weight: 600; }
.setting-text span { color: var(--muted); font-size: 0.85rem; }
.setting-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setting-ctl .field { width: 260px; }
.setting-ctl .field.short { width: 120px; }
.setting-ctl select.field { width: 180px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stepper button { border: none; background: var(--bg); width: 34px; height: 34px; font-size: 1.1rem; }
.stepper span { min-width: 64px; text-align: center; font-weight: 600; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #FFFFFF; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.privacy-line { margin: 4px 0 10px; color: var(--muted); font-size: 0.9rem; }
.privacy-line b { color: var(--text); }
.special-list { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 8px 0; }
.special-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; }
.special-row .when { width: 170px; color: var(--muted); font-size: 0.85rem; flex-shrink: 0; }
.special-add { display: flex; gap: 8px; flex-wrap: wrap; }
.special-add .field { flex: 1 1 140px; width: auto; }
.coming { font-size: 0.8rem; color: var(--faint); font-style: italic; }
@media (max-width: 600px) { .setting-ctl .field { width: 100%; } .setting-ctl { width: 100%; } }

/* =================== Phase 4: Plan, Tasks, Routines, Habits =================== */
.plan-layout, .split { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 1100px) {
    .plan-layout { grid-template-columns: 1fr 380px; }
    .split { grid-template-columns: 1fr 460px; }
}
.plan-layout .card, .split .card { margin-bottom: 0; }
.split-detail { display: flex; flex-direction: column; gap: 14px; }

.month-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-title { font-size: 1.15rem; min-width: 150px; text-align: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.segmented { display: inline-flex; flex-wrap: wrap; }
.segmented button { white-space: nowrap; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 0.75rem; font-weight: 600; color: var(--muted); padding: 0 4px 4px; }
.cal-cell {
    min-height: 78px; padding: 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--card);
    display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; color: var(--text); min-width: 0;
}
.cal-cell:hover { background: var(--hover); }
.cal-cell.out { opacity: 0.45; }
.cal-cell.today { border-color: var(--accent); border-width: 1.5px; }
.cal-cell.today .cal-day { color: var(--accent); font-weight: 700; }
.cal-cell.sel { background: color-mix(in srgb, var(--accent) 18%, var(--card)); border-color: var(--accent); }
.cal-day { font-weight: 600; font-size: 0.9rem; }
.cal-dots { display: flex; gap: 3px; }
.cal-note { font-size: 0.68rem; color: var(--muted); line-height: 1.1; }
.cal-note.pending { color: var(--pending); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--c); flex-shrink: 0; }
.dot.filled { background: var(--c); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 0.78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
@media (max-width: 600px) {
    .cal-cell { min-height: 52px; padding: 4px; }
    .cal-note { display: none; }
}

.week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.week-card {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left; min-height: 220px;
    padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.week-card.today { border-color: var(--accent); }
.week-card.sel { background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.week-task { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.week-task .task-text { padding: 2px 0; }
.week-task.finished .task-text { color: var(--faint); text-decoration: line-through; }

.day-title { font-size: 1.2rem; margin: 0; }
.add-row { display: flex; gap: 8px; margin: 10px 0 14px; }
.type-title { font-size: 0.95rem; margin: 14px 0 4px; }
.indent { margin: 0 0 4px 16px; }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 2px 0 2px 4px; }
.plan-row.finished .task-text { color: var(--faint); }

.tasks-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tasks-filters .search { width: 260px; }
.task-table { padding: 6px; }
.tt-row {
    display: grid; grid-template-columns: 130px 90px 1fr 170px; gap: 10px; align-items: center;
    width: 100%; padding: 8px 10px; border: none; border-radius: 8px; background: none; color: var(--text); text-align: left;
}
button.tt-row:nth-of-type(even) { background: color-mix(in srgb, var(--hover) 60%, transparent); }
button.tt-row:hover { background: var(--hover); }
.tt-head { font-weight: 600; color: var(--muted); font-size: 0.85rem; background: var(--hover); }
.tt-date { font-size: 0.88rem; }
.tt-text { overflow-wrap: anywhere; }
.strike { text-decoration: line-through; }
.pad { padding: 10px; }
@media (max-width: 700px) {
    .tt-row { grid-template-columns: 1fr auto; }
    .tt-head { display: none; }
    .tt-row .tt-text { grid-column: 1 / -1; grid-row: 1; }
    .tasks-filters .search { width: 100%; }
}

.page-head.with-action { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { margin-bottom: 16px; }
.routine-card {
    display: flex; align-items: center; gap: 8px; padding: 12px 10px; margin-bottom: 8px; cursor: pointer;
    border-radius: 14px; border: 1px solid var(--border); background: var(--card);
}
.routine-card.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.routine-card.paused { opacity: 0.6; }
.routine-card p { margin: 2px 0 0; }
.routine-icon {
    width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent);
}
.detail-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.detail-head h2 { margin: 0; font-size: 1.3rem; }
.routine-step { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.routine-step.finished .task-text { color: var(--faint); text-decoration: line-through; }
.routine-step.not-due .task-text { color: var(--faint); }
.mini-bar.full { width: 100%; height: 10px; border-radius: 5px; margin-top: 8px; }
.step-edit { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.step-edit .field { flex: 1 1 200px; width: auto; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.day-picker { display: inline-flex; gap: 3px; }
.day-picker button {
    width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg);
    font-size: 0.75rem; color: var(--muted); padding: 0;
}
.day-picker button.on { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }

.habit-summary { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.habit-table { overflow-x: auto; }
.habit-row { display: grid; grid-template-columns: minmax(140px, 1fr) repeat(7, 46px) 90px 36px; align-items: center; gap: 2px; padding: 6px 8px; min-width: 560px; }
.habit-head { background: var(--hover); border-radius: 8px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.habit-day { display: flex; flex-direction: column; align-items: center; }
.habit-day small { color: var(--faint); font-weight: 400; }
.habit-day.today { color: var(--accent); }
.habit-cell {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: transparent;
    color: #FFFFFF; font-weight: 700; padding: 0;
}
.habit-cell.on { background: var(--small); border-color: var(--small); }
.habit-streak { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 0.88rem; }
.habit-streak .icon { color: var(--big); }

/* =================== Phase 5: Notes and journal =================== */
.btn-row.tight { margin-top: 0; }
.notes-layout { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.notes-layout .card { margin-bottom: 0; }
@media (min-width: 1100px) {
    .notes-layout { grid-template-columns: 220px 320px 1fr; }
    .back-btn { display: none !important; }
}
@media (max-width: 1099px) {
    .notes-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
    .notes-nav .nav-label, .notes-nav > .faint { display: none; }
    .notes-layout .notes-editor { display: none; }
    .notes-layout.editing .notes-editor { display: block; }
    .notes-layout.editing .notes-nav, .notes-layout.editing .notes-list { display: none; }
}
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 2px;
    border: none; border-radius: 8px; background: none; color: var(--text); font-size: 0.9rem;
}
.nav-item:hover { background: var(--hover); }
.nav-item.on { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }
@media (max-width: 1099px) { .notes-nav .nav-item { width: auto; } }
.nav-cat { display: flex; align-items: center; }
.nav-cat .icon-btn { opacity: 0; }
.nav-cat:hover .icon-btn { opacity: 1; }
@media (hover: none) { .nav-cat .icon-btn { opacity: 1; } }
.nav-label { font-size: 0.7rem; font-weight: 700; color: var(--faint); margin: 14px 10px 6px; letter-spacing: 0.05em; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px; }
.pill.tag { border: none; --c: #64748B; cursor: pointer; }
.pill.tag.on { --c: var(--accent); }
.pill .x { background: none; border: none; color: inherit; padding: 0 0 0 4px; font-size: 0.9rem; }

.notes-list { display: flex; flex-direction: column; gap: 6px; max-height: 75vh; overflow-y: auto; }
.notes-list > .field { margin-bottom: 6px; }
.note-item { display: flex; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; background: color-mix(in srgb, var(--hover) 60%, transparent); }
.note-item.on { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.note-icon {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent);
}
.note-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.note-top { display: flex; align-items: center; gap: 6px; }
.note-top b { flex: 1; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.notes-editor { display: flex; flex-direction: column; min-height: 60vh; }
.back-btn { align-self: flex-start; margin-bottom: 6px; }
.title-input {
    font: inherit; font-size: 1.4rem; font-weight: 700; line-height: 1.3; border: none; background: none; color: var(--text);
    padding: 4px 2px; width: 100%; resize: none; overflow: hidden; field-sizing: content; min-height: 2.2em;
}
.title-input:focus { outline: none; }
.note-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 4px; }
.small-select { width: auto !important; padding: 5px 8px; font-size: 0.85rem; }
.tag-input { border: none; background: none; color: var(--text); font: inherit; font-size: 0.85rem; width: 110px; padding: 4px; }
.tag-input:focus { outline: 1px solid var(--border); border-radius: 6px; }
.toolbar { display: flex; gap: 2px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 0; margin: 4px 0 10px; }
.toolbar button { width: 34px; height: 32px; border: none; border-radius: 6px; background: none; color: var(--text); font-size: 1rem; }
.toolbar button:hover { background: var(--hover); }
.note-body {
    flex: 1; min-height: 320px; width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg); color: var(--text); font: inherit; font-size: 0.95rem; line-height: 1.6; padding: 12px;
}
.note-body:focus { outline: none; border-color: var(--accent); }
.note-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.locked { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 380px; margin: 60px auto; gap: 6px; }
.locked-icon { color: #A855F7; }
.locked h2 { margin: 8px 0 0; }
.field.pin { font-size: 1.4rem; text-align: center; letter-spacing: 0.4em; }
.rec-key {
    font-family: Consolas, "Courier New", monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.05em; text-align: center;
    padding: 14px; margin: 8px 0; border-radius: 10px; background: var(--hover); user-select: all; overflow-wrap: anywhere;
}

.tpl-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 800px) { .tpl-grid { grid-template-columns: 200px 240px 1fr; height: 440px; } }
.tpl-areas, .tpl-list, .tpl-preview { overflow-y: auto; }
@media (max-width: 799px) { .tpl-areas, .tpl-list { max-height: 180px; border-bottom: 1px solid var(--border); } }
.tpl-preview h3 { margin-top: 0; }

/* =================== Phase 6: Statistics, Focus, tour =================== */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric {
    display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius);
    border: 1px solid var(--border); background: color-mix(in srgb, var(--c) 8%, var(--card));
}
.metric b { font-size: 1.6rem; margin-top: 8px; }
.metric > span:last-child { color: var(--muted); font-size: 0.85rem; }
.metric-icon {
    width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: var(--c); background: color-mix(in srgb, var(--c) 20%, transparent);
}
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: 1fr 1fr; } }
.two-col .card { margin-bottom: 16px; }

.donut-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut { width: 170px; height: 170px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.donut > div {
    width: 122px; height: 122px; border-radius: 50%; background: var(--card);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut b { font-size: 1.6rem; }
.donut small { color: var(--muted); }
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 10px; }
.donut-legend > div { display: flex; align-items: center; gap: 10px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.bar-val { font-size: 0.72rem; color: var(--muted); }
.bar-track { flex: 1; width: 100%; max-width: 36px; display: flex; align-items: flex-end; border-radius: 6px; background: var(--hover); }
.bar-fill { width: 100%; border-radius: 6px; background: var(--accent); min-height: 2px; }
.bar-day { font-size: 0.75rem; color: var(--muted); }

.heat-wrap { overflow-x: auto; }
.heat { display: grid; grid-template-rows: repeat(7, 15px); grid-auto-flow: column; grid-auto-columns: 15px; gap: 3px; }
.heat .heat-label { grid-column: 1; font-size: 0.65rem; color: var(--faint); width: 28px; line-height: 15px; }
.heat { grid-template-columns: 30px; }
.heat-sq { width: 15px; height: 15px; border-radius: 3px; display: inline-block; background: var(--hover); }
.heat-sq.empty { background: transparent; }
.heat-sq.lvl1 { background: color-mix(in srgb, var(--small) 14%, transparent); }
.heat-sq.lvl2 { background: color-mix(in srgb, var(--small) 33%, transparent); }
.heat-sq.lvl3 { background: color-mix(in srgb, var(--small) 53%, transparent); }
.heat-sq.lvl4 { background: color-mix(in srgb, var(--small) 75%, transparent); }
.heat-sq.lvl5 { background: var(--small); }
.heat-sq.today { outline: 1.5px solid var(--accent); }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; }

.exec-row { display: grid; grid-template-columns: 170px 1fr 44px; align-items: center; gap: 10px; padding: 5px 0; font-size: 0.9rem; }
.exec-row b { text-align: right; }
.mini-bar.full-row { width: 100%; height: 8px; border-radius: 4px; }
@media (max-width: 600px) { .exec-row { grid-template-columns: 1fr 70px 36px; } }

.second-look {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; margin-bottom: 6px; padding: 8px 10px;
    border: none; border-radius: 8px; background: var(--hover); color: var(--text);
}
.second-look .grow { display: flex; flex-direction: column; min-width: 0; }
.second-look .task-text { padding: 0; }
.insights { background: color-mix(in srgb, var(--big) 6%, var(--card)); }
.insight { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.insight .icon { color: var(--small); }

.table-scroll { overflow-x: auto; }
.db-row {
    display: grid; grid-template-columns: 120px 50px 80px 80px 60px minmax(100px, 1fr) 150px; gap: 10px; align-items: center;
    width: 100%; min-width: 720px; padding: 8px 10px; border: none; border-radius: 8px; background: none; color: var(--text); text-align: left;
}
button.db-row:nth-of-type(even) { background: color-mix(in srgb, var(--hover) 60%, transparent); }
button.db-row:hover { background: var(--hover); }
.db-head { font-weight: 600; font-size: 0.85rem; color: var(--muted); background: var(--hover); }

.focus-card { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px; }
.focus-mode { font-weight: 700; font-size: 0.8rem; letter-spacing: 0.1em; color: var(--accent); }
.focus-mode.break { color: var(--small); }
.focus-task {
    margin-top: 8px; width: 100%; text-align: center; font: inherit; font-weight: 600; font-size: 1rem;
    border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); padding: 6px;
}
.focus-task:focus { border-color: var(--border); outline: none; }
.focus-time { font-size: 4.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 8px 0; }
.btn-row.center { justify-content: center; margin-top: 4px; }
.btn.wide { min-width: 110px; }

.tour-page { min-height: 300px; }
.tour-motto { color: var(--accent); }
.tour-example { border-left: 4px solid var(--c); padding: 8px 12px; margin-bottom: 10px; border-radius: 6px; background: color-mix(in srgb, var(--c) 8%, transparent); }
.tour-example p { margin: 4px 0 0; }

/* =================== Phase 7: import dialog =================== */
.check input[type=radio] { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); align-self: flex-start; margin-top: 3px; }
.modal-body .check { align-items: flex-start; margin-bottom: 8px; }

/* over the 1-3-5 limit after combining two devices */
.pill.over { --c: var(--pending); border: none; cursor: pointer; white-space: nowrap; }

/* "Completed today" sub-line: tasks planned for an earlier day */
.counter-sub { font-size: 0.65rem; color: var(--faint); line-height: 1.1; }

/* import: over-limit tasks decided before importing */
.conflicts { border: 1px solid color-mix(in srgb, var(--pending) 45%, var(--border)); border-radius: 10px; padding: 10px 12px; margin: 8px 0 12px; max-height: 45vh; overflow-y: auto; }
.conflict-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--border); }
.conflict-row .grow { min-width: 200px; }
.conflict-row .error.full { flex-basis: 100%; margin: 0; }

.type-hint { margin: 8px 0 10px; }

/* Medium task steps chip and Change type menu */
.steps-chip { margin: 0 0 4px 44px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: 0.78rem; }
.steps-chip:hover { color: var(--accent); border-color: var(--accent); }
.type-option {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text);
}
.type-option:hover:not(:disabled) { background: var(--hover); }
.type-option:disabled { opacity: 0.6; cursor: default; }

/* routine editor: order buttons and minutes box */
.order-btns { display: inline-flex; flex-direction: column; }
.order-btns .icon-btn { padding: 0 4px; font-size: 0.7rem; line-height: 1.1; }
.order-btns .icon-btn:disabled { opacity: 0.3; }
.step-edit .field.min-box { flex: 0 0 64px; width: 64px; text-align: center; }

/* ---- spotlight tour ---- */
.tour-blocker { position: fixed; inset: 0; z-index: 900; }
.tour-dim { position: fixed; inset: 0; z-index: 901; background: rgba(0,0,0,.55); pointer-events: none; }
.tour-hole { position: fixed; z-index: 901; border-radius: 12px; border: 2.5px solid var(--accent);
             box-shadow: 0 0 0 9999px rgba(0,0,0,.55); pointer-events: none; transition: all .25s ease; }
.tour-bubble { position: fixed; z-index: 902; background: var(--card, #fff); color: var(--text);
               border-radius: 14px; padding: 16px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-height: 70vh; overflow: auto; }
.tour-bubble p { margin: 6px 0 12px; line-height: 1.45; }
.tour-title { font-size: 1.05rem; }
.tour-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.small-btn { padding: 6px 12px; }
.tour-link { background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font: inherit; opacity: .8; }
.tour-fab { display: none; }
@media (max-width: 899px) {
    .tour-fab { display: flex; align-items: center; justify-content: center; position: fixed; top: 10px; right: 10px;
                z-index: 50; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border, #ccc);
                background: var(--card, #fff); color: var(--text); font-weight: 700; cursor: pointer; }
}

/* ---- routines: compact steps, drag & drop, planned time ---- */
.over-text { color: #F97316; }
.free-text { color: #16A34A; }
.card-tools { display: flex; align-items: center; gap: 4px; }
.phone-only { display: none; }
@media (hover: none), (max-width: 899px) { .phone-only { display: inline-flex; } }
.menu-wrap { position: relative; display: inline-flex; }
.mini-menu, .days-pop { position: absolute; right: 0; top: 100%; z-index: 20; display: flex; flex-direction: column; gap: 4px;
    background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.days-pop { flex-direction: row; align-items: center; }
.mini-menu button { background: none; border: 0; padding: 6px 10px; text-align: left; cursor: pointer; font: inherit; color: var(--text); white-space: nowrap; }
.mini-menu button:hover { background: var(--hover); }
.plan-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan-row .time-box { flex: 0 0 72px; width: 72px; text-align: center; }
.step-line { display: flex; align-items: center; gap: 6px; padding: 3px 0; min-height: 40px; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.step-line.drop-above { border-top-color: var(--accent); }
.step-line.drop-below { border-bottom-color: var(--accent); }
.routine-card.drop-above { box-shadow: 0 -3px 0 var(--accent); }
.routine-card.drop-below { box-shadow: 0 3px 0 var(--accent); }
.dragging .step-line > *, .dragging .routine-card > * { pointer-events: none; }
.drag-handle { cursor: grab; color: var(--faint); padding: 0 4px; user-select: none; touch-action: none; letter-spacing: -2px; }
.step-text { flex: 1; resize: none; field-sizing: content; min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
.step-line .field.min-box { flex: 0 0 46px; width: 46px; text-align: center; padding-left: 2px; padding-right: 2px; }
.days-chip { border: 1px solid var(--border); background: var(--hover); color: var(--text); border-radius: 999px; padding: 4px 10px;
    font: inherit; font-size: .8rem; cursor: pointer; white-space: nowrap; }
