/* ══════════════════════════════════
   Time Tracker — Warm Minimal Theme
   ══════════════════════════════════ */

/* ── Theme variables ── */
:root, [data-theme="light"] {
    color-scheme: light;
    --bg: #FAF7F2;
    --surface: #FFFFFF;
    --text: #2C2520;
    --text-sec: #8A8078;
    --text-ter: #A09890;
    --text-muted: #C0B8AE;
    --text-faint: #D4C8BC;
    --border: #F0ECE6;
    --accent: #D4B896;
    --accent-shadow: rgba(212,184,150,0.3);
    --overlay: rgba(44,37,32,0.4);
    --overlay-strong: rgba(44,37,32,0.5);
    --input-bg: #FAF7F2;
    --card-shadow: rgba(0,0,0,0.05);
    --badge-bg: #FFFFFF;
    --bar-bg: #F0ECE6;
    --tab-active-bg: #2C2520;
    --tab-active-text: #FAF7F2;
    --fade-color: #FAF7F2;
    --fade-surface: #FFFFFF;
    --on-accent: #2C2520;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1C1917;
    --surface: #292524;
    --text: #F5F0EB;
    --text-sec: #A8A29E;
    --text-ter: #78716C;
    --text-muted: #57534E;
    --text-faint: #44403C;
    --border: #3F3A36;
    --accent: #D4B896;
    --accent-shadow: rgba(212,184,150,0.15);
    --overlay: rgba(0,0,0,0.6);
    --overlay-strong: rgba(0,0,0,0.7);
    --input-bg: #1C1917;
    --card-shadow: rgba(0,0,0,0.2);
    --badge-bg: #292524;
    --bar-bg: #3F3A36;
    --tab-active-bg: #D4B896;
    --tab-active-text: #1C1917;
    --fade-color: #1C1917;
    --fade-surface: #292524;
    --on-accent: #2C2520;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    overflow: hidden;
}

/* ── Prevent iOS zoom on input focus ── */
input, select, textarea { touch-action: manipulation; }

/* ── App container ── */
#app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
#app.swipe-entering .loading { display: none !important; }

/* ── Subtle radial overlay on pages ── */
.page-bg::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(circle at 15% 85%, rgba(245,166,35,0.04) 0%, transparent 50%),
        radial-gradient(circle at 85% 15%, rgba(78,205,196,0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ── Scrollbar hide ── */
.scroll-hide { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; }
.scroll-hide::-webkit-scrollbar { display: none; }

/* ── Loading ── */
.loading {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 16px; height: 100%;
}
.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%;
    -webkit-animation: spin 0.8s linear infinite;
    animation: spin 0.8s linear infinite;
}
@-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-ter); font-size: 13px; }

/* ── Login ── */
.login-wrap {
    display: flex; align-items: center; justify-content: center;
    height: 100%; padding: 20px;
}
.login-card {
    width: 100%; max-width: 360px;
    background: var(--surface); border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 2px 12px var(--card-shadow);
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; color: var(--text); }
.login-subtitle { font-size: 13px; color: var(--text-ter); text-align: center; margin-bottom: 24px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-ter); margin-bottom: 5px; font-weight: 500; }
.form-group input {
    width: 100%; padding: 11px 14px;
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 16px;
    font-family: inherit; outline: none;
    -webkit-appearance: none; appearance: none;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-muted); }
.btn {
    width: 100%; padding: 13px; background: var(--accent); color: var(--text);
    border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    -webkit-appearance: none; appearance: none;
    box-shadow: 0 2px 8px var(--accent-shadow);
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.form-error { color: #E53935; font-size: 12px; text-align: center; margin-top: 10px; min-height: 18px; }
.code-hint { font-size: 12px; color: var(--text-ter); text-align: center; margin-bottom: 14px; }

/* ── Tab Bar ── */
.tab-bar {
    display: flex; border-top: 1px solid var(--border);
    background: var(--surface); flex-shrink: 0;
}
.tab-bar button {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 7px 0 5px;
    background: none; border: none; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}
.tab-bar button span {
    font-size: 11px; font-weight: 500; color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
}
.tab-bar button.active span { font-weight: 700; color: var(--text); }
.tab-bar-safe { height: 15px; flex-shrink: 0; background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }

/* ── Page header ── */
.page-hdr {
    padding: 10px 18px 0; flex-shrink: 0;
    display: flex; justify-content: center; align-items: center;
    position: relative; z-index: 1;
}
.page-hdr-label {
    font-size: 11px; color: var(--text-ter); font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
}
.page-hdr-date { font-size: 11px; color: var(--text-ter); position: absolute; right: 18px; }

/* ── Sub-page header (back arrow) ── */
.sub-hdr {
    padding: 12px 16px; flex-shrink: 0;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border);
}
.sub-hdr button {
    background: none; border: none; cursor: pointer; padding: 0;
    display: flex; align-items: center;
    -webkit-appearance: none; appearance: none;
}
.sub-hdr-title { font-size: 15px; font-weight: 700; color: var(--text); }

/* ── Goals page header ── */
.goals-hdr {
    padding: 12px 16px 0; flex-shrink: 0;
    display: flex; justify-content: space-between; align-items: center;
    position: relative; z-index: 1;
}
.goals-hdr button {
    background: none; border: none; cursor: pointer; padding: 4px;
    -webkit-appearance: none; appearance: none;
}
.goals-hdr-title { font-size: 14px; font-weight: 700; color: var(--text); }

/* ── Summary badges ── */
.summary-row {
    display: flex; gap: 8px; padding: 10px 16px 6px;
    flex-shrink: 0; position: relative; z-index: 1;
}
.summary-badge {
    flex: 1; padding: 8px 10px; border-radius: 10px;
    background: var(--surface); box-shadow: 0 1px 3px var(--card-shadow);
    display: flex; align-items: center; gap: 8px;
}
.summary-badge .num { font-size: 16px; font-weight: 700; }
.summary-badge .of { font-size: 16px; font-weight: 700; color: var(--text-muted); }
.summary-badge .lbl { font-size: 16px; font-weight: 700; color: var(--text-muted); margin-left: auto; }

/* ── Section divider ── */
.section-div {
    display: flex; align-items: center; gap: 6px; padding: 8px 0 2px;
    margin-top: 10px;
}
.section-div .badge {
    font-size: 14px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
    letter-spacing: 0.08em;
    white-space: nowrap;
}
.section-div .line { flex: 1; height: 1px; background: var(--border); }

/* ── Goal row ── */
.goal-row { padding: 5px 0; }
.goal-row-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.goal-row-emoji { font-size: 14px; flex-shrink: 0; }
.goal-row-name { font-size: 13px; font-weight: 600; color: var(--text); }
.goal-row-period {
    font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
    letter-spacing: 0.03em;
}
.goal-row-status { margin-left: auto; font-size: 12px; font-weight: 600; margin-right: 56px; }
.goal-row-bar-wrap { display: flex; align-items: center; gap: 6px; }
.goal-row-bar {
    flex: 1; height: 12px; background: var(--bar-bg); border-radius: 3px;
    overflow: hidden;
}
.goal-row-bar-fill {
    height: 100%; border-radius: 3px;
    transition: width 0.3s;
}
.goal-row-nums {
    font-size: 11px; font-weight: 600; flex-shrink: 0;
    font-family: 'DM Mono', monospace;
    width: 50px; text-align: right;
}

/* ── Goal settings row ── */
.gs-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.gs-row-emoji { font-size: 18px; flex-shrink: 0; }
.gs-row-name { font-size: 13px; font-weight: 600; color: var(--text); }
.gs-row-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.gs-row-type {
    font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
}
.gs-row-target { font-size: 11px; font-weight: 600; color: var(--text-sec); font-family: 'DM Mono', monospace; }
.gs-row-period { font-size: 9px; color: var(--text-muted); }

/* ── Add goal button ── */
.add-goal-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 12px; margin-top: 10px;
    border-radius: 12px; background: var(--surface);
    border: 2px dashed var(--text-muted); cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}

/* ── App settings row ── */
.as-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 14px 0; border-bottom: 1px solid var(--border);
    background: none; border-left: none; border-right: none; border-top: none;
    cursor: pointer; text-align: left;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.as-row-icon { font-size: 18px; }
.as-row-label { font-size: 14px; font-weight: 600; color: var(--text); }
.as-row-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Timer display ── */
.timer-digits {
    position: relative; display: inline-block;
    font-size: 46px; font-weight: 300; color: var(--text);
    letter-spacing: -2px; font-family: 'DM Mono', monospace;
    line-height: 1; text-align: center;
}
.timer-digits .sep { color: var(--text-faint); }
.net-dot {
    position: absolute; left: -14px; top: 50%;
    width: 8px; height: 8px; border-radius: 50%;
    transform: translateY(-50%); transition: background 0.3s;
}
.timer-sub { font-size: 14px; color: var(--text-sec); margin-top: 4px; text-align: center; }

/* ── Timer controls ── */
.timer-controls {
    display: flex; justify-content: center; gap: 8px;
    padding: 6px 18px 4px; flex-shrink: 0;
    position: relative; z-index: 1;
}
.btn-start {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 22px; border-radius: 10px;
    background: var(--accent); border: none; cursor: pointer;
    box-shadow: 0 2px 10px var(--accent-shadow);
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.btn-start.running {
    background: var(--accent); opacity: 0.75; box-shadow: 0 2px 10px var(--accent-shadow);
}
.btn-start span { font-size: 13px; font-weight: 600; color: var(--on-accent); }
.btn-start.running span { color: var(--on-accent); }
.btn-reset {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 10px;
    background: var(--bar-bg); border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.btn-reset span { font-size: 13px; font-weight: 600; color: var(--text-sec); }

/* ── Category grid ── */
.cat-grid-wrap {
    flex-shrink: 0; padding: 0 14px;
    position: relative; z-index: 1; overflow: hidden;
}
.cat-grid-scroll {
    height: 100%; overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
}
.cat-grid-scroll::-webkit-scrollbar { display: none; }
.cat-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
    padding: 2px 0 4px; width: 100%;
}
.cat-btn {
    position: relative;
    display: flex; align-items: center; gap: 7px;
    padding: 0 10px; height: 44px; border-radius: 12px;
    background: var(--surface); border: none;
    cursor: pointer; transition: all 0.15s;
    box-shadow: 0 1px 3px var(--card-shadow);
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
    min-width: 0; overflow: hidden; width: 100%;
}
.cat-btn.selected { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.cat-btn-emoji { font-size: 16px; flex-shrink: 0; }
.cat-btn-name {
    font-size: 14px; font-weight: 500; color: var(--text-sec);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.2; min-width: 0; flex: 1;
}
.cat-btn.selected .cat-btn-name { font-weight: 700; color: var(--text); }
.cat-fade-top,
.cat-fade-bottom {
    position: absolute; left: 14px; right: 14px;
    pointer-events: none; z-index: 2;
}
.cat-fade-top { top: 0; height: 8px; background: linear-gradient(to bottom, var(--fade-color), transparent); opacity: 0.6; }
.cat-fade-bottom { bottom: 0; height: 14px; background: linear-gradient(to top, var(--fade-color), transparent); }

/* ── Save button ── */
.btn-save {
    width: 100%; padding: 12px; border-radius: 12px;
    background: var(--accent); color: var(--on-accent);
    font-size: 14px; font-weight: 600; border: none; cursor: pointer;
    box-shadow: 0 3px 12px var(--accent-shadow);
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.btn-save:active { opacity: 0.85; }
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mini chart ── */
.mchart-period {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 4px; padding: 0 2px; flex-shrink: 0;
}
.mchart-period-label { font-size: 14px; color: var(--text-ter); font-weight: 600; }
.mchart-period-date { font-size: 13px; color: var(--text-muted); }
.mchart-scroll {
    flex: 1; min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
    border-radius: 8px;
}
.mchart-scroll::-webkit-scrollbar { display: none; }
.mchart-rows { display: flex; flex-direction: column; gap: 2px; padding-bottom: 32px; }
.mchart-row {
    display: flex; align-items: center; gap: 6px;
    height: 20px; transition: opacity 0.2s;
}
.mchart-row-emoji { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; }
.mchart-row-bar {
    flex: 1; background: var(--bar-bg); border-radius: 3px;
    overflow: hidden; transition: height 0.2s;
    position: relative;
}
.mchart-row-fill {
    height: 100%; border-radius: 3px;
    display: flex; align-items: center; padding-left: 3px;
    min-width: 30px; transition: width 0.3s;
}
.mchart-row-fill-text {
    font-weight: 700; color: var(--on-accent); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    text-shadow: 0 0.5px 1px rgba(0,0,0,0.15);
    line-height: 1;
}
.mchart-row-time {
    width: 36px; text-align: right; flex-shrink: 0;
    font-family: 'DM Mono', monospace;
}
.mchart-fade {
    position: absolute; bottom: 0; left: 0; right: 0; height: 14px;
    background: linear-gradient(to top, var(--fade-color), transparent);
    pointer-events: none;
}

/* ── Goal widgets (circles) ── */
.gw-wrap { display: flex; gap: 6px; padding: 0 14px; flex-shrink: 0; }
.gw-box {
    flex: 1; background: var(--surface); border-radius: 10px;
    padding: 8px 6px; overflow: hidden; position: relative;
}
.gw-box-min { border: none; box-shadow: 0 0 8px 1px rgba(129,199,132,0.35); }
.gw-box-max { border: none; box-shadow: 0 0 8px 1px rgba(239,154,154,0.35); }
.gw-empty-hint {
    font-size: 11px; color: var(--text-muted); text-align: center;
    padding: 10px 6px; line-height: 1.3;
}
.gw-scroll {
    max-height: 118px; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
}
.gw-scroll::-webkit-scrollbar { display: none; }
.gw-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.gw-item { display: flex; flex-direction: column; align-items: center; width: 48px; }
.gw-item-ring { position: relative; width: 38px; height: 38px; }
.gw-item-emoji {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); font-size: 14px;
    line-height: 1; text-align: center;
}
.gw-item-label {
    font-size: 9.5px; font-weight: 700; margin-top: 1px;
    font-family: 'DM Mono', monospace;
    white-space: nowrap;
}
.gw-fade {
    position: absolute; bottom: 0; left: 0; right: 0; height: 8px;
    background: linear-gradient(to top, var(--fade-surface), transparent);
    pointer-events: none; border-radius: 0 0 10px 10px;
}

/* ── Reports ── */
.report-period-tabs {
    display: flex; align-items: center; gap: 4px; padding: 8px 16px;
    flex-shrink: 0; position: relative; z-index: 1;
}
.page-gear-btn {
    background: none; border: none; cursor: pointer; padding: 4px;
    display: flex; align-items: center; justify-content: center;
    -webkit-appearance: none; appearance: none; flex-shrink: 0;
}
.date-nav-gear {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
}
.report-period-tab {
    padding: 6px 12px; border-radius: 8px;
    font-size: 11px; font-weight: 600;
    background: var(--bar-bg); color: var(--text-sec);
    border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.report-period-tab.active { background: var(--tab-active-bg); color: var(--tab-active-text); }
.report-total {
    text-align: center; padding: 8px 16px;
    font-size: 28px; font-weight: 300;
    font-family: 'DM Mono', monospace;
    color: var(--text);
}
.report-total-label { font-size: 11px; color: var(--text-ter); font-weight: 500; }
.report-bars { padding: 0 16px; }
.report-bar-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0;
}
.report-bar-emoji { font-size: 14px; width: 22px; text-align: center; flex-shrink: 0; }
.report-bar-info { flex: 1; min-width: 0; }
.report-bar-name { font-size: 12px; font-weight: 600; color: var(--text); }
.report-bar-track {
    height: 10px; background: var(--bar-bg); border-radius: 3px;
    overflow: hidden; margin-top: 3px;
}
.report-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.report-bar-time {
    font-size: 11px; font-weight: 600; color: var(--text-sec);
    font-family: 'DM Mono', monospace; flex-shrink: 0; width: 50px; text-align: right;
}
.report-bar-pct { font-size: 9px; color: var(--text-muted); flex-shrink: 0; width: 30px; text-align: right; }

/* ── Journal / Log ── */
.log-day-hdr {
    font-size: 11px; font-weight: 700; color: var(--text-ter);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 12px 0 4px;
    border-bottom: 1px solid var(--border);
}
.log-entry {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.log-entry-time {
    font-size: 13px; color: var(--text-ter); flex-shrink: 0;
    font-family: 'DM Mono', monospace; white-space: nowrap;
}
.log-entry-center {
    flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
    margin-left: 10px;
}
.log-entry-emoji { font-size: 16px; flex-shrink: 0; }
.log-entry-name {
    font-size: 14px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.log-entry-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.log-entry-dur {
    font-size: 13px; font-weight: 600; color: var(--text-sec);
    font-family: 'DM Mono', monospace; flex-shrink: 0; white-space: nowrap;
}
.log-entry-edit {
    flex-shrink: 0; color: var(--text-muted); padding: 4px;
    display: flex; align-items: center;
}
.log-empty { text-align: center; padding: 40px 0; color: var(--text-muted); font-size: 13px; }

/* ── Modal overlay ── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
    background: var(--bg); border-radius: 16px 16px 0 0;
    width: 100%; max-width: 500px; max-height: calc(100vh - 70px);
    padding: 20px 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}
.modal-sheet-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 16px; text-align: center; }
.modal-close {
    position: absolute; top: 10px; right: 10px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; padding: 0;
    font-size: 20px; color: var(--ts); cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.modal-sheet .form-group input,
.modal-sheet .form-group select {
    width: 100%; padding: 11px 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 15px;
    font-family: inherit; outline: none;
    -webkit-appearance: none; appearance: none;
}
.modal-sheet .form-group select { padding-right: 32px; }
.modal-sheet .form-group select option[disabled] { color: var(--text-muted); }
.modal-sheet .form-group select:invalid { color: var(--text-muted); }
.me-datetime-row { display: flex; gap: 8px; }
.me-datetime-row .form-group { flex: 1; }
.modal-actions .btn { color: var(--on-accent); }
#meDateStart, #meTimeStart { border-color: transparent; box-shadow: 0 0 8px 1px rgba(129,199,132,0.35); }
#meDateEnd, #meTimeEnd { border-color: transparent; box-shadow: 0 0 8px 1px rgba(239,154,154,0.35); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn,
.modal-actions .btn-danger,
.modal-actions .btn-secondary { flex: 1; }
.btn-danger {
    width: 100%; padding: 13px; background: var(--surface); color: #E53935;
    border: 1px solid #FFCDD2; border-radius: 10px; font-size: 14px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}
.btn-secondary {
    width: 100%; padding: 13px; background: var(--bar-bg); color: var(--text-sec);
    border: none; border-radius: 10px; font-size: 14px; font-weight: 600;
    font-family: inherit; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}

/* ── Emoji picker grid in modal ── */
.emoji-cat-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    max-height: 200px; overflow-y: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.emoji-cat-grid::-webkit-scrollbar { display: none; }
.emoji-cat-option {
    display: flex; align-items: center; gap: 6px;
    padding: 8px; border-radius: 10px; background: var(--surface);
    border: 2px solid transparent; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.emoji-cat-option.selected { border-color: var(--accent); background: #D4B89614; }
.emoji-cat-option span:first-child { font-size: 16px; }
.emoji-cat-option span:last-child { font-size: 10px; color: var(--text-sec); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Category edit modal ── */
.ce-emoji-name-row {
    display: flex; gap: 8px; margin-bottom: 14px;
}
.ce-emoji-btn {
    width: 48px; height: 48px; flex-shrink: 0;
    border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
    font-size: 24px; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    -webkit-appearance: none; appearance: none;
}
.ce-emoji-btn:focus { border-color: var(--accent); }
.ce-name-input {
    flex: 1; padding: 11px 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 15px;
    font-family: inherit; outline: none;
    -webkit-appearance: none; appearance: none;
}
.ce-name-input:focus { border-color: var(--accent); }
.ce-name-input::placeholder { color: var(--text-muted); }

/* Color swatches */
.ce-section-label {
    font-size: 12px; color: var(--text-ter); font-weight: 500;
    margin-bottom: 6px;
}
.ce-color-grid {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.ce-color-swatch {
    width: 32px; height: 32px; border-radius: 8px;
    border: 2px solid transparent; cursor: pointer;
    position: relative; transition: border-color 0.15s;
    -webkit-appearance: none; appearance: none; padding: 0;
}
.ce-color-swatch.selected { border-color: var(--text); }
.ce-color-swatch.selected::after {
    content: '✓'; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 14px; font-weight: 700; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.ce-color-custom-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.ce-color-custom-input {
    width: 40px; height: 32px; border: 1px solid var(--border);
    border-radius: 8px; padding: 2px; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}

/* Emoji picker overlay */
.ep-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay-strong); z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.ep-sheet {
    background: var(--bg); border-radius: 16px;
    width: 100%; max-width: 360px; max-height: 70vh;
    padding: 16px; display: flex; flex-direction: column;
    overflow: hidden;
}
.ep-title {
    font-size: 15px; font-weight: 700; color: var(--text);
    text-align: center; margin-bottom: 12px; flex-shrink: 0;
}
.ep-scroll {
    flex: 1; overflow-y: auto; min-height: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
}
.ep-scroll::-webkit-scrollbar { display: none; }
.ep-group-title {
    font-size: 10px; font-weight: 700; color: var(--text-ter);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 8px 0 4px;
}
.ep-grid {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.ep-cell {
    display: flex; align-items: center; justify-content: center;
    width: 100%; aspect-ratio: 1; font-size: 22px;
    border-radius: 8px; cursor: pointer; background: none;
    border: none; -webkit-appearance: none; appearance: none;
    transition: background 0.1s;
}
.ep-cell:active { background: var(--bar-bg); }

/* Goal checkbox section */
.ce-goal-section { margin-top: 14px; margin-bottom: 14px; }
.ce-goal-option {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px; background: var(--surface);
    border: 1px solid var(--border); cursor: pointer; margin-bottom: 6px;
    -webkit-appearance: none; appearance: none; width: 100%;
    font-family: 'DM Sans', sans-serif; text-align: left;
}
.ce-goal-option.active { border-color: var(--accent); background: #D4B89610; }
.ce-goal-check {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--text-faint); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.ce-goal-option.active .ce-goal-check {
    border-color: var(--accent); background: var(--accent);
}
.ce-goal-option.active .ce-goal-check::after {
    content: '✓'; color: #fff; font-size: 12px; font-weight: 700;
}
.ce-goal-label { font-size: 13px; font-weight: 600; color: var(--text); }
.ce-goal-fields {
    padding: 10px 12px; background: var(--surface); border-radius: 10px;
    border: 1px solid var(--border); margin-bottom: 10px;
}
.ce-goal-hint { font-size: 11px; color: var(--text-ter); margin-bottom: 8px; }
.ce-time-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ce-time-group { flex: 1; }
.ce-time-group label {
    display: block; font-size: 10px; color: var(--text-ter);
    margin-bottom: 3px; font-weight: 500;
}
.ce-time-group input {
    width: 100%; padding: 8px; background: var(--input-bg);
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 15px; font-family: 'DM Mono', monospace;
    text-align: center; color: var(--text); outline: none;
    -webkit-appearance: none; appearance: none;
}
.ce-time-group input:focus { border-color: var(--accent); }
.ce-period-tabs { display: flex; gap: 4px; }
.ce-period-tab {
    flex: 1; padding: 7px 0; border-radius: 8px;
    font-size: 11px; font-weight: 600; text-align: center;
    background: var(--bar-bg); color: var(--text-sec); border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.ce-period-tab.active { background: var(--tab-active-bg); color: var(--tab-active-text); }

/* ── Nav swipe (date) ── */
.date-nav {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    padding: 6px 16px; flex-shrink: 0; position: relative;
}
.log-day-total {
    position: absolute; right: 42px; top: 50%; transform: translateY(-50%);
    font-size: 11px; font-weight: 600; color: var(--text-ter);
}
.log-add-btn {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border);
    font-size: 18px; font-weight: 400; color: var(--text-sec);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; line-height: 1;
    -webkit-appearance: none; appearance: none;
}
.log-add-btn:active { background: var(--bar-bg); }
.date-nav button {
    background: none; border: none; cursor: pointer; padding: 4px;
    color: var(--text-ter);
    -webkit-appearance: none; appearance: none;
}
.date-nav-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Category drag row ── */
.cat-drag-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
    background: var(--bg);
    -webkit-transition: box-shadow 0.2s;
    transition: box-shadow 0.2s;
}
.cat-drag-row.dragging {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    border-radius: 10px;
    border-bottom: none;
    padding: 10px 8px;
    background: var(--surface);
}
.cat-drag-handle {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
    background: none; border: none; cursor: grab;
    color: var(--text-muted); font-size: 18px; font-weight: 700;
    -webkit-appearance: none; appearance: none;
    touch-action: none;
    font-family: 'DM Sans', sans-serif;
}
.cat-drag-handle:active { cursor: grabbing; color: var(--text-sec); }
.cat-drag-placeholder {
    border: 2px dashed var(--accent); border-radius: 8px;
    background: rgba(212,184,150,0.06); margin: 2px 0;
}

/* ── Preset categories section ── */
.pc-section-title {
    font-size: 12px; font-weight: 700; color: var(--text-ter);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 14px 0 6px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}
.pc-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 4px;
    background: none; border: none; border-bottom: 1px solid var(--border);
    cursor: pointer; text-align: left;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
    -webkit-transition: opacity 0.2s;
    transition: opacity 0.2s;
}
.pc-item:active { background: var(--bar-bg); }
.pc-item.inactive { opacity: 0.4; cursor: default; }
.pc-item.inactive:active { background: none; }
.pc-item-emoji { font-size: 18px; flex-shrink: 0; }
.pc-item-name { flex: 1; font-size: 13px; font-weight: 500; color: var(--text); }
.pc-item-add {
    font-size: 18px; font-weight: 600; color: var(--accent);
    width: 28px; height: 28px; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.pc-item-check {
    font-size: 14px; color: #A5D6A7;
    width: 28px; height: 28px; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Install banner ── */
.install-banner {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-shrink: 0; z-index: 50;
}
.install-banner-text {
    flex: 1; font-size: 12px; font-weight: 500; color: var(--text);
    line-height: 1.3;
}
.install-banner-btn {
    padding: 6px 14px; border-radius: 8px;
    background: var(--accent); color: var(--text); border: none;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    font-family: 'DM Sans', sans-serif; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}
.install-banner-btn:active { opacity: 0.85; }
.install-banner-close {
    background: none; border: none; cursor: pointer;
    font-size: 20px; line-height: 1; color: var(--text-muted);
    padding: 0 2px; flex-shrink: 0;
    -webkit-appearance: none; appearance: none;
}

/* ── iOS install modal steps ── */
.ios-step {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; text-align: left;
}
.ios-step-icon { flex-shrink: 0; }
.ios-step-text { font-size: 14px; font-weight: 500; color: var(--text); }

/* ── Subcategories & Archive ── */
.cat-btn-parent-dot {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px; border-radius: 50%;
    border: 1.5px solid var(--surface);
}
.ce-subcat-toggle {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer;
}
.ce-subcat-toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.ce-parent-dropdown {
    width: 100%; padding: 10px 14px; margin-top: 8px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-size: 14px; font-family: inherit;
    -webkit-appearance: none; appearance: none;
}
.archived-badge {
    font-size: 9px; font-weight: 700; color: var(--text-muted);
    background: var(--bar-bg); padding: 1px 5px; border-radius: 3px; margin-left: 4px;
}
.cat-drag-row.archived, .report-bar-row.archived { opacity: 0.5; }

/* ── Offline indicator ── */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    -webkit-transform: translateX(-50%) translateY(-100%);
    transform: translateX(-50%) translateY(-100%);
    z-index: 999;
    padding: 3px 16px;
    padding-top: calc(3px + env(safe-area-inset-top));
    background: #78716C;
    color: #FAFAF9;
    border-radius: 0 0 10px 10px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.04em;
    -webkit-transition: transform 0.3s ease;
    transition: transform 0.3s ease;
    pointer-events: none;
}
.offline-indicator.visible {
    -webkit-transform: translateX(-50%) translateY(0);
    transform: translateX(-50%) translateY(0);
}

/* ── Reminders page ── */
.rem-section-title {
    font-size: 11px; font-weight: 700; color: var(--text-ter);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 12px 0 4px;
}
.rem-row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.rem-row-info { flex: 1; min-width: 0; }
.rem-row-label {
    font-size: 14px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rem-row-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Toggle switch */
.rem-toggle {
    position: relative; display: inline-block;
    width: 42px; height: 24px; flex-shrink: 0;
}
.rem-toggle input { opacity: 0; width: 0; height: 0; }
.rem-toggle-slider {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bar-bg); border-radius: 24px; cursor: pointer;
    -webkit-transition: background 0.2s;
    transition: background 0.2s;
}
.rem-toggle-slider::before {
    content: ''; position: absolute;
    width: 18px; height: 18px; left: 3px; bottom: 3px;
    background: var(--surface); border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    -webkit-transition: transform 0.2s;
    transition: transform 0.2s;
}
.rem-toggle input:checked + .rem-toggle-slider { background: var(--accent); }
.rem-toggle input:checked + .rem-toggle-slider::before {
    -webkit-transform: translateX(18px);
    transform: translateX(18px);
}

/* Notification banner */
.rem-notif-banner {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; margin: 0; flex-shrink: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.rem-notif-icon { font-size: 18px; flex-shrink: 0; }
.rem-notif-text { flex: 1; font-size: 12px; color: var(--text-sec); line-height: 1.3; }
.rem-notif-btn {
    padding: 6px 12px; border-radius: 8px;
    background: var(--accent); color: var(--on-accent); border: none;
    font-size: 11px; font-weight: 600; white-space: nowrap;
    font-family: 'DM Sans', sans-serif; cursor: pointer;
    -webkit-appearance: none; appearance: none;
}
.rem-notif-btn:active { opacity: 0.85; }

/* Type tabs in modal */
.rem-type-tabs { display: flex; gap: 4px; }
.rem-type-tab {
    flex: 1; padding: 8px 0; border-radius: 8px;
    font-size: 12px; font-weight: 600; text-align: center;
    background: var(--bar-bg); color: var(--text-sec); border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.rem-type-tab.active { background: var(--tab-active-bg); color: var(--tab-active-text); }

/* Category select in modal */
#remCatSelect {
    width: 100%; padding: 11px 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 15px;
    font-family: inherit; outline: none;
    -webkit-appearance: none; appearance: none;
    padding-right: 32px;
}
#remCatSelect:focus { border-color: var(--accent); }

/* Interval row (hours + minutes) */
.rem-interval-row { display: flex; gap: 8px; }
.rem-interval-field { flex: 1; }
.rem-interval-field input {
    width: 100%; padding: 8px 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 15px;
    font-family: 'DM Mono', monospace; text-align: center; outline: none;
    -webkit-appearance: none; appearance: none;
}
.rem-interval-field input:focus { border-color: var(--accent); }
.rem-interval-unit {
    display: block; text-align: center;
    font-size: 10px; color: var(--text-ter); margin-top: 3px; font-weight: 500;
}

/* Active hours row */
.rem-time-row {
    display: flex; align-items: center; gap: 8px;
}
.rem-time-label { font-size: 12px; color: var(--text-ter); font-weight: 500; }
.rem-time-row input[type="time"] {
    flex: 1; padding: 8px 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 14px;
    font-family: 'DM Mono', monospace; outline: none;
    -webkit-appearance: none; appearance: none;
}
.rem-time-row input[type="time"]:focus { border-color: var(--accent); }

/* Days of week row */
.rem-days-row { display: flex; gap: 3px; }
.rem-day-btn {
    flex: 1; padding: 4px 0; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    background: var(--bar-bg); border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-appearance: none; appearance: none;
}
.rem-day-check {
    width: 16px; height: 16px; border-radius: 4px;
    border: 1.5px solid var(--text-muted);
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
    color: transparent;
}
.rem-day-btn.active .rem-day-check {
    background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.rem-day-label { font-size: 9px; font-weight: 600; color: var(--text-sec); }
