*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #0d0f14;
    --surface: #161920;
    --surface2: #1e2230;
    --border: #2a2f42;
    --accent: #00e5a0;
    --accent-dim: rgba(0, 229, 160, 0.12);
    --accent-glow: rgba(0, 229, 160, 0.35);
    --text: #e8ecf5;
    --text-muted: #6b748f;
    --text-dim: #9aa3be;
    --danger: #ff5a6e;
    --danger-dim: rgba(255, 90, 110, 0.12);
    --danger-border: rgba(255, 90, 110, 0.55);
    --custom: #f5a623;
    --custom-dim: rgba(245, 166, 35, 0.10);
    --custom-border: rgba(245, 166, 35, 0.55);
    --edited: #a78bfa;
    --edited-dim: rgba(167, 139, 250, 0.10);
    --edited-border: rgba(167, 139, 250, 0.55);
    --today-bg: rgba(0, 229, 160, 0.04);
    --today-border: rgba(0, 229, 160, 0.28);
    --mono: 'IBM Plex Mono', monospace;
    --sans: 'Syne', sans-serif;
    --radius: 10px;
    --transition: 0.18s ease;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}
body.sheet-open { overflow: hidden; }

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,229,160,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,229,160,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.wrapper {
    width: 100%;
    max-width: 680px;
    position: relative;
    z-index: 1;
    padding-bottom: 60px;
}

/* ── Header ── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-top: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 16px var(--accent-glow);
    flex-shrink: 0;
}

h1 {
    font-size: clamp(1.2rem, 4vw, 1.55rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.1;
}

h1 span { color: var(--accent); }

.entry-count-badge {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    white-space: nowrap;
}

/* ── Tab navigation ── */
.tab-nav {
    display: flex;
    gap: 2px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-radius: 7px;
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 9px 16px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.tab-btn:hover { color: var(--text-dim); }

.tab-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: 0 0 12px var(--accent-dim);
}

.tab-btn .tab-count {
    font-family: var(--mono);
    font-size: 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 6px;
}

.tab-btn.active .tab-count {
    background: rgba(0,229,160,0.08);
    border-color: rgba(0,229,160,0.25);
    color: var(--accent);
}

/* ── Color Palette ── */
.palette-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.palette-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.palette-swatches {
    display: flex;
    gap: 10px;
    align-items: center;
}

.palette-swatch {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12);
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
    flex-shrink: 0;
}

.palette-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(255,255,255,0.15);
}

.palette-swatch input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* ── Input card ── */
.input-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-card:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.input-wrap { flex: 1; position: relative; }

input[type="text"], input[type="date"], input[type="time"], input[type="datetime-local"] {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 16px;
    padding: 12px 14px;
    outline: none;
    transition: border-color var(--transition);
    -webkit-appearance: none;
}

input[type="date"], input[type="time"], input[type="datetime-local"] {
    color-scheme: dark;
    cursor: pointer;
}

input[type="text"]::placeholder { color: var(--text-muted); }
input[type="text"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus { border-color: var(--accent); }

.btn-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-shrink: 0;
}
#procTemplateSelect {
    min-width: 118px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 0 10px;
    cursor: pointer;
}
#procTemplateSelect:focus { border-color: var(--accent); outline: none; }

.add-btn {
    background: var(--accent);
    color: #0d0f14;
    border: none;
    border-radius: 8px;
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 12px 22px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
    display: flex;
    align-items: center;
    gap: 7px;
}

.add-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.add-btn:active { transform: translateY(0); }

/* ── Custom entry button ── */
.custom-trigger-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 16px;
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    position: relative;
}

.custom-trigger-btn:hover {
    border-color: var(--custom);
    color: var(--custom);
    background: var(--custom-dim);
    box-shadow: 0 0 10px rgba(245,166,35,0.2);
}

.custom-trigger-btn.active {
    border-color: var(--custom);
    color: var(--custom);
    background: var(--custom-dim);
}

/* ── Custom entry panel ── */
.custom-panel {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.28s ease, opacity 0.22s ease, margin-top 0.22s ease;
    margin-top: 0;
}

.custom-panel.open {
    max-height: 240px;
    opacity: 1;
    margin-top: 14px;
}

.custom-panel-inner {
    border-top: 1px solid var(--custom-border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-panel-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--custom);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-panel-label::before {
    content: '✦';
    font-size: 9px;
}

.custom-fields {
    display: flex;
    gap: 10px;
}

.custom-fields input[type="date"],
.custom-fields input[type="time"] {
    flex: 1;
    padding: 10px 12px;
    font-size: 0.82rem;
}

.custom-add-btn {
    background: var(--custom-dim);
    color: var(--custom);
    border: 1px solid var(--custom-border);
    border-radius: 8px;
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 10px 18px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    flex-shrink: 0;
}

.custom-add-btn:hover {
    background: rgba(245, 166, 35, 0.18);
    box-shadow: 0 0 12px rgba(245,166,35,0.2);
}

.hint {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ── Section header ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 2px;
}

.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Import / Export buttons (icon-only) ── */
.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.icon-btn svg { flex-shrink: 0; }

.icon-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 8px var(--accent-dim);
}

/* Clear button */
.clear-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 4px 8px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    height: 28px;
    display: flex;
    align-items: center;
}

.clear-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-dim);
}

/* Persistence info button */
.info-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.72rem;
    cursor: default;
}

.question-mark {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    flex-shrink: 0;
    font-family: var(--mono);
}

.question-mark:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.tooltip {
    position: fixed;
    width: min(300px, calc(100vw - 24px));
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--text-dim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.tooltip p + p { margin-top: 8px; }
.tooltip strong { color: var(--text); }

.tooltip-title {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.tooltip.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Sort controls ── */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sort-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.68rem;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
    white-space: nowrap;
}

.sort-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.sort-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.sort-dir {
    font-size: 10px;
    line-height: 1;
    display: inline-block;
    transition: transform 0.18s ease;
}

.sort-sep {
    color: var(--border);
    font-size: 0.7rem;
    user-select: none;
}

/* ── Toolbar row ── */
.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 2px;
    flex-wrap: wrap;
    row-gap: 8px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.toolbar-divider {
    width: 1px;
    height: 14px;
    background: var(--border);
    margin: 0 3px;
}

.filter-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.filter-toggle-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 0 10px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    white-space: nowrap;
}

.filter-toggle-btn:hover,
.filter-toggle-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.filter-toggle-btn .chevron {
    display: inline-block;
    transition: transform 0.22s ease;
    font-size: 10px;
}

.filter-toggle-btn.active .chevron {
    transform: rotate(180deg);
}

.filter-active-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
    display: none;
}

.filter-active-dot.visible { display: block; }

/* Filter panel */
.filter-panel {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.22s ease, margin-bottom 0.22s ease;
    margin-bottom: 0;
}

.filter-panel.open {
    max-height: 200px;
    opacity: 1;
    margin-bottom: 14px;
}

.filter-panel-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-search-wrap {
    flex: 1;
    position: relative;
}

.filter-search-wrap svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.filter-search-wrap input {
    padding-left: 34px !important;
}

.filter-date-wrap { flex-shrink: 0; }

.filter-date-wrap input[type="date"] {
    padding: 11px 12px;
    font-size: 0.82rem;
    width: 160px;
}

.filter-chips {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-chip-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
}

.filter-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 3px 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-chip.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.filter-chip.custom-chip.active {
    background: var(--custom-dim);
    border-color: var(--custom-border);
    color: var(--custom);
}

.filter-chip.edited-chip.active {
    background: var(--edited-dim);
    border-color: var(--edited-border);
    color: var(--edited);
}

.filter-chip.overdue-chip.active {
    background: var(--danger-dim);
    border-color: var(--danger-border);
    color: var(--danger);
}

.filter-clear-link {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-left: auto;
    transition: color var(--transition);
    background: none;
    border: none;
    padding: 0;
}

.filter-clear-link:hover { color: var(--danger); }

.results-count-row {
    min-height: 20px;
    margin-bottom: 8px;
    padding: 0 2px;
}

/* Results count */
.results-count {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    display: none;
}

.results-count.visible { display: block; }

/* ── Entry list ── */
.entry-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lazy-loader {
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

.lazy-loader span {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition);
}

.lazy-loader.visible span { opacity: 1; }

/* Swipe container — clips overflow, holds delete/action zone behind */
.entry-wrap {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
}

/* Delete zone revealed behind the card on LEFT swipe */
.entry-delete-zone {
    position: absolute;
    inset: 0;
    background: #1a1220;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 22px;
    border-radius: var(--radius);
    pointer-events: none;
    transition: background 0.18s ease;
}

.entry-delete-zone svg {
    opacity: 0;
    transform: scale(0.6) rotate(-15deg);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    color: #7a3a4a;
}

.entry-wrap.swiping-left .entry-delete-zone {
    background: #1e1018;
}

.entry-wrap.swiping-left .entry-delete-zone svg {
    opacity: 0.6;
    transform: scale(0.9) rotate(0deg);
    color: #c4566a;
}

.entry-wrap.will-delete .entry-delete-zone {
    background: #2a0d18;
}

.entry-wrap.will-delete .entry-delete-zone svg {
    opacity: 1;
    transform: scale(1.1) rotate(0deg);
    color: #e8748a;
}

/* ── Red aura / glow on left-swipe (intensifies with distance) ── */
.entry-wrap.swiping-left > .entry-item {
    --g: var(--swipe-glow, 0);
    box-shadow:
        0 0 calc(6px + 12px * var(--g))  calc(1px + 3px * var(--g)) rgba(232, 116, 138, calc(0.08 + 0.30 * var(--g))),
        0 0 calc(14px + 26px * var(--g)) calc(2px + 6px * var(--g)) rgba(232, 116, 138, calc(0.04 + 0.14 * var(--g)));
    border-color: rgba(232, 116, 138, calc(0.15 + 0.40 * var(--g)));
    transition: box-shadow 0.06s linear, border-color 0.06s linear;
}

.entry-wrap.will-delete > .entry-item {
    box-shadow: 0 0 18px 5px rgba(232, 116, 138, 0.40),
                0 0 40px 10px rgba(232, 116, 138, 0.18);
    border-color: rgba(232, 116, 138, 0.60);
}

/* ── Confirm-delete overlay (appears ON TOP of the card) ── */
.confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    border-radius: var(--radius);
    background: rgba(42, 13, 24, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.entry-wrap.confirm-delete .confirm-overlay {
    opacity: 1;
    pointer-events: auto;
}

.confirm-overlay .confirm-delete-btn {
    background: #c4566a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 8px 18px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    animation: confirmBtnPulse 1.5s ease-in-out infinite;
}

.confirm-overlay .confirm-delete-btn:active {
    transform: scale(0.95);
    background: #e8748a;
}

@keyframes confirmBtnPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(232, 116, 138, 0.3); }
    50% { box-shadow: 0 0 18px rgba(232, 116, 138, 0.6); }
}

.confirm-overlay .confirm-cancel-btn {
    background: rgba(255,255,255,0.08);
    color: var(--text-dim);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.confirm-overlay .confirm-cancel-btn:active {
    background: rgba(255,255,255,0.15);
}

.entry-wrap.confirm-delete > .entry-item {
    box-shadow: 0 0 16px 4px rgba(232, 116, 138, 0.30),
                0 0 36px 8px rgba(232, 116, 138, 0.12);
    border-color: rgba(232, 116, 138, 0.50);
}

/* Auto-dismiss progress bar */
.confirm-timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #e8748a, #c4566a);
    border-radius: 0 0 var(--radius) var(--radius);
    animation: timerShrink 4s linear forwards;
}

@keyframes timerShrink {
    from { width: 100%; }
    to { width: 0%; }
}

/* Right-swipe card feedback */
.entry-wrap.swiping-right > .entry-item {
    border-color: rgba(91, 160, 208, 0.25);
}

.entry-wrap.will-action > .entry-item {
    border-color: rgba(126, 200, 240, 0.4);
    box-shadow: 0 0 12px rgba(126, 200, 240, 0.1);
}

/* Action zone revealed behind the card on RIGHT swipe */
.entry-action-zone {
    position: absolute;
    inset: 0;
    background: #121828;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 22px;
    border-radius: var(--radius);
    pointer-events: none;
    transition: background 0.18s ease;
}

.entry-action-zone svg {
    opacity: 0;
    transform: scale(0.6) rotate(15deg);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    color: #3b6080;
}

.entry-wrap.swiping-right .entry-action-zone {
    background: #0f1a2a;
}

.entry-wrap.swiping-right .entry-action-zone svg {
    opacity: 0.6;
    transform: scale(0.9) rotate(0deg);
    color: #5ba0d0;
}

.entry-wrap.will-action .entry-action-zone {
    background: #0d1e30;
}

.entry-wrap.will-action .entry-action-zone svg {
    opacity: 1;
    transform: scale(1.1) rotate(0deg);
    color: #7ec8f0;
}

.entry-item {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: slideIn 0.22s ease both;
    transition: border-color var(--transition), background var(--transition), box-shadow 0.22s ease;
    position: relative;
    z-index: 1;
    cursor: grab;
    will-change: transform;
    touch-action: pan-y;
}

.entry-item:active { cursor: grabbing; }

.entry-item.snap-back {
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color var(--transition),
                background var(--transition);
}

.entry-item.snap-delete {
    transition: transform 0.22s ease, opacity 0.22s ease;
}

/* Today highlight */
.entry-item.today {
    background: var(--today-bg);
    border-color: var(--today-border);
}

.entry-item.today:hover {
    background: rgba(0, 229, 160, 0.07);
    border-color: rgba(0, 229, 160, 0.38);
}

/* Custom entry */
.entry-item.custom-entry {
    border-left: 3px solid var(--custom);
    padding-left: 14px;
}

.entry-item.custom-entry.today {
    border-left-color: var(--custom);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Swipe hint — always-visible pulsing indicator */
.entry-item::after { content: none; }

.swipe-hint {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
    z-index: 2;
    opacity: 0.35;
    animation: hintPulse 3s ease-in-out infinite;
}
.swipe-hint svg { color: var(--text-muted); }
@keyframes hintPulse { 0%,100% { opacity: 0.35; } 50% { opacity: 0.1; } }
.entry-wrap:hover .swipe-hint { opacity: 0.55; animation: none; }

.entry-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
    flex-shrink: 0;
}

.entry-item.custom-entry .entry-dot {
    background: var(--custom);
    box-shadow: 0 0 6px rgba(245,166,35,0.4);
}

.entry-body { min-width: 0; }

.entry-text {
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.entry-text.no-text { color: var(--text-muted); font-style: italic; font-weight: 400; }

.custom-badge {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--custom);
    background: var(--custom-dim);
    border: 1px solid var(--custom-border);
    border-radius: 4px;
    padding: 1px 5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-shrink: 0;
    font-style: normal;
}

.edited-badge {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--edited);
    background: var(--edited-dim);
    border: 1px solid var(--edited-border);
    border-radius: 4px;
    padding: 1px 5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex-shrink: 0;
    font-style: normal;
}

.entry-ts {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    display: none;
}

.empty-state.visible { display: block; }
.empty-icon { font-size: 2rem; margin-bottom: 12px; opacity: 0.5; }

.empty-state p {
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.6;
}

/* Hidden file input */
#importFileInput { display: none; }

/* Toast notification */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 18px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent);
    z-index: 999;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease;
    opacity: 0;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    white-space: normal;
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    word-break: break-word;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-color: var(--danger);
    color: var(--danger);
}

/* ── View toggle ── */
.view-toggle {
    display: flex;
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 2px;
    gap: 1px;
}

.view-toggle-btn {
    background: none;
    border: none;
    border-radius: 5px;
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn.active { background: var(--accent-dim); color: var(--accent); }

/* ── Timeline ── */
.timeline-outer {
    position: relative;
}

.tl-day {
    margin-bottom: 32px;
}
.tl-day:last-child { margin-bottom: 0; }

.tl-day-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.tl-day-pill {
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.tl-day-pill.is-today {
    color: var(--accent);
    border-color: var(--today-border);
    background: var(--accent-dim);
}

.tl-day-rule {
    height: 1px;
    background: var(--border);
    flex: 1;
}

.tl-day-count {
    font-family: var(--mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.tl-track {
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 4px 20px;
    cursor: grab;
    user-select: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-mask-image: linear-gradient(90deg, transparent 0px, #000 24px, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0px, #000 24px, #000 calc(100% - 24px), transparent 100%);
}

.tl-track.single {
    -webkit-mask-image: none;
    mask-image: none;
    cursor: default;
}

.tl-track:active { cursor: grabbing; }

.tl-track::-webkit-scrollbar { height: 4px; }
.tl-track::-webkit-scrollbar-track { background: transparent; }
.tl-track::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.tl-track::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.tl-row {
    display: flex;
    align-items: flex-start;
    gap: 0;
    position: relative;
    min-width: max-content;
    padding: 0 16px;
}

.tl-spine {
    position: absolute;
    top: 7px;
    left: calc(16px + 65px);
    right: calc(16px + 65px);
    height: 2px;
    background: linear-gradient(90deg, var(--border), var(--border));
    z-index: 0;
    border-radius: 1px;
}

.tl-day.is-today .tl-spine {
    background: linear-gradient(90deg, var(--border) 0%, var(--today-border) 50%, var(--border) 100%);
}

.tl-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    width: 130px;
    flex-shrink: 0;
}

.tl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2.5px solid var(--bg);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
    cursor: pointer;
}

.tl-node:hover .tl-dot {
    transform: scale(1.5);
}

.tl-node.is-today .tl-dot::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    opacity: 0.35;
    animation: pulse-ring 2.4s ease-in-out infinite;
}

@keyframes pulse-ring {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50%       { opacity: 0.08; transform: scale(1.6); }
}

.tl-stem {
    width: 1px;
    height: 14px;
    flex-shrink: 0;
}

.tl-time {
    font-family: var(--mono);
    font-size: 0.58rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: center;
    transition: color 0.15s ease;
    order: -1;
}

.tl-node:hover .tl-time { color: var(--text-dim); }

.tl-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 11px;
    width: 116px;
    transition: transform 0.2s cubic-bezier(0.34, 1.3, 0.64, 1),
                box-shadow 0.2s ease,
                border-color 0.15s ease;
}

.tl-node:hover .tl-card {
    transform: translateY(-5px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}

.tl-card-name {
    font-family: var(--sans);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

.tl-card-name.no-text {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

.tl-card-badge {
    font-family: var(--mono);
    font-size: 0.56rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 2px 5px;
    border-radius: 3px;
    display: inline-block;
    margin-top: 6px;
}

.tl-node.tl-auto .tl-dot {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    color: var(--accent);
}
.tl-node.tl-auto .tl-stem { background: var(--accent); opacity: 0.3; }
.tl-node.tl-auto .tl-card { border-top: 2.5px solid var(--accent); }
.tl-node.tl-auto:hover .tl-dot { box-shadow: 0 0 0 5px var(--accent-dim), 0 0 14px var(--accent-glow); }
.tl-node.tl-auto:hover .tl-card { border-color: var(--accent); }

.tl-node.tl-custom .tl-dot {
    background: var(--custom);
    box-shadow: 0 0 0 3px var(--custom-dim);
    color: var(--custom);
}
.tl-node.tl-custom .tl-stem { background: var(--custom); opacity: 0.3; }
.tl-node.tl-custom .tl-card { border-top: 2.5px solid var(--custom); }
.tl-node.tl-custom .tl-card-badge {
    background: var(--custom-dim);
    border: 1px solid var(--custom-border);
    color: var(--custom);
}
.tl-node.tl-custom:hover .tl-dot { box-shadow: 0 0 0 5px var(--custom-dim), 0 0 14px rgba(245,166,35,0.3); }
.tl-node.tl-custom:hover .tl-card { border-color: var(--custom-border); }

.timeline-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.6;
}

.tl-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 0 2px;
}

.tl-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--text-muted);
}

.tl-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tl-legend-dot.auto { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }
.tl-legend-dot.custom { background: var(--custom); box-shadow: 0 0 6px rgba(245,166,35,0.4); }


/* ── Source viewer toggle ── */
.source-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.72rem;
    font-family: var(--mono);
    opacity: 0.3;
    transition: opacity var(--transition), transform var(--transition);
    line-height: 1;
    flex-shrink: 0;
    margin: 0 2px;
    color: var(--text);
}
.source-toggle:hover { opacity: 0.7; transform: scale(1.15); }

/* ── Source viewer modal ── */
.source-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 950;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.source-modal-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.source-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.source-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}
.source-modal-title {
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}
.source-modal-actions {
    display: flex;
    gap: 6px;
}
.source-modal-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.68rem;
    padding: 5px 10px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.source-modal-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}
.source-modal-close {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
    flex-shrink: 0;
}
.source-modal-close:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-dim);
}
.source-modal-body {
    overflow: auto;
    padding: 16px;
    flex: 1;
    min-height: 0;
    display: grid;
    gap: 12px;
    align-content: start;
}
.source-modal-text {
    font-family: var(--mono);
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--text-dim);
}
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--accent);
    border: 1px solid rgba(0,229,160,0.35);
    background: rgba(0,229,160,0.06);
    border-radius: 8px;
    text-decoration: none;
    width: fit-content;
    padding: 8px 10px;
    transition: all var(--transition);
}
.source-link:hover {
    background: rgba(0,229,160,0.12);
    border-color: var(--accent);
}
.gdrive-modal-field {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}
.gdrive-modal-field label {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.gdrive-modal-field input {
    width: 100%;
}

/* ── Google Drive icon-btn modifier ── */
.icon-btn.gdrive-btn svg { width: 13px; height: 13px; }

/* ── Ko-fi toggle ── */
.kofi-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.82rem;
    opacity: 0.3;
    transition: opacity var(--transition), transform var(--transition);
    line-height: 1;
    flex-shrink: 0;
    margin: 0 2px;
}

.kofi-toggle:hover { opacity: 0.7; transform: scale(1.15); }
.kofi-toggle.hidden { opacity: 0.15; }

/* ── Ko-fi badge ── */
.kofi-badge {
    position: fixed;
    bottom: 18px;
    right: 18px;
    opacity: 0.22;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 50;
    line-height: 0;
    border-radius: 8px;
}

.kofi-badge:hover {
    opacity: 0.85;
    transform: translateY(-2px);
}

.kofi-badge img {
    display: block;
    border: 0;
    height: 36px;
    width: auto;
}

/* ── Bottom Sheet / Action Menu ── */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sheet-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 12px 20px max(20px, env(safe-area-inset-bottom));
    z-index: 901;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.34, 1.2, 0.64, 1);
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.sheet-overlay.open .sheet {
    transform: translateY(0);
}

.sheet.dragging {
    transition: none !important;
}

.sheet-handle {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: var(--border);
    margin: 0 auto 14px;
    cursor: grab;
    touch-action: none;
}
.sheet-handle:active { cursor: grabbing; }

.sheet-title {
    font-family: var(--sans);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

.sheet-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sheet-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

.sheet-opt:hover {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-dim);
}

.sheet-opt-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.sheet-opt-text {
    flex: 1;
}

.sheet-opt-title {
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.sheet-opt-desc {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Color picker in sheet ── */
.sheet-colors {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.sheet-color-swatch {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid var(--border);
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s ease;
}

.sheet-color-swatch:hover {
    transform: scale(1.15);
    border-color: var(--text);
}

.sheet-color-swatch.selected {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.sheet-sub-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 0.06em;
}

.sheet-btn-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.sheet-btn {
    flex: 1;
    padding: 11px 16px;
    border-radius: 8px;
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all var(--transition);
    text-align: center;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.sheet-btn.primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.sheet-btn.primary:hover {
    opacity: 0.88;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.sheet-btn.secondary {
    background: var(--surface2);
    color: var(--text-muted);
}

.sheet-btn.secondary:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

/* ── Checkpoint Timeline (Processes) ── */
.cp-track {
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 0 4px;
    margin-top: 8px;
    user-select: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-mask-image: linear-gradient(90deg, transparent 0px, #000 12px, #000 calc(100% - 12px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0px, #000 12px, #000 calc(100% - 12px), transparent 100%);
    touch-action: pan-x; /* allow horizontal scroll, don't fight card swipe */
    cursor: grab;
}

.cp-track:active { cursor: grabbing; }

.cp-track::-webkit-scrollbar { height: 3px; }
.cp-track::-webkit-scrollbar-track { background: transparent; }
.cp-track::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cp-row {
    display: flex;
    align-items: flex-start;
    gap: 0;
    position: relative;
    min-width: max-content;
    padding: 0 8px;
}

.cp-spine {
    position: absolute;
    top: 7px;
    left: calc(8px + 30px);
    right: calc(8px + 40px + 30px); /* skip add-btn width */
    height: 2px;
    background: var(--border);
    z-index: 0;
    border-radius: 1px;
}

.cp-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 1;
    width: 60px;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.cp-node:hover { opacity: 0.85; }

/* Quick-add checkpoint button at end of row */
.cp-add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 1;
    width: 40px;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease;
    opacity: 0.35;
    padding-top: 0;
}

.cp-add-btn:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

.cp-add-btn:active {
    transform: scale(0.95);
}

.cp-add-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.cp-add-btn:hover .cp-add-dot {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.cp-add-dot svg {
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.cp-add-btn:hover .cp-add-dot svg {
    color: var(--accent);
}

.cp-add-label {
    font-family: var(--mono);
    font-size: 0.42rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.cp-add-btn:hover .cp-add-label {
    color: var(--accent);
}

.cp-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--surface2);
    border: 2.5px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cp-dot.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim), 0 0 8px var(--accent-glow);
}

.cp-dot.completed {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 0.55;
}

.cp-node:hover .cp-dot {
    transform: scale(1.4);
}

.cp-node.active .cp-dot::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    opacity: 0.35;
    animation: pulse-ring 2.4s ease-in-out infinite;
}

.cp-stem {
    width: 1px;
    height: 10px;
    background: var(--border);
    opacity: 0.3;
    flex-shrink: 0;
}

.cp-stem.active {
    background: var(--accent);
    opacity: 0.4;
}

.cp-label {
    font-family: var(--mono);
    font-size: 0.48rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 56px;
    line-height: 1.2;
    transition: color 0.15s ease;
    word-break: break-word;
}

.cp-node.active .cp-label {
    color: var(--accent);
    font-weight: 600;
}

.cp-node.completed .cp-label {
    color: var(--text-dim);
}

.cp-due {
    font-family: var(--mono);
    font-size: 0.42rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.cp-due.overdue {
    color: var(--danger);
    font-weight: 600;
}

/* ── Stage detail in sheet ── */
.stage-detail-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0;
}

.stage-detail-form textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 10px 14px;
    outline: none;
    resize: vertical;
    min-height: 120px;
    transition: border-color var(--transition);
}

.stage-detail-form textarea:focus { border-color: var(--accent); }

/* Larger resize handle for touch targets */
.stage-detail-form textarea::-webkit-resizer {
    background: transparent;
    border-width: 0 0 12px 12px;
    border-style: solid;
    border-color: transparent transparent var(--border) transparent;
    cursor: ns-resize;
}

/* ── Tab content panels ── */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ── Mobile ── */
@media (max-width: 520px) {
    body { padding: 12px; }
    .input-row { flex-direction: column; }
    .btn-group { flex-direction: row; }
    .add-btn { flex: 1; justify-content: center; padding: 13px; }
    .entry-item { grid-template-columns: auto 1fr auto; gap: 10px; padding: 12px 12px; }
    .custom-fields { flex-direction: column; }
    .filter-row { flex-direction: column; }
    .filter-date-wrap input[type="date"] { width: 100%; }
    .section-actions { flex-wrap: wrap; gap: 6px; }
    .palette-section { flex-wrap: wrap; gap: 8px; }
}
