/* style.css — Docket (same palette, type and button sizes as the workout and food trackers) */

:root {
    --bg: #08080a;
    --surface: #161618;
    --surface-2: #202023;
    --surface-hover: #2a2a2e;
    --border: #242428;
    --border-light: #34343a;

    --text: #f2f2f3;
    --text-2: #95959d;
    --text-3: #6c6c74;

    --blue: #2f7be0;
    --blue-press: #2666c2;
    --green: #43a047;
    --green-press: #388e3c;
    --done-bg: #294b27;
    --red: #e0443c;
    --yellow: #ffc933;

    --radius: 12px;
    --radius-sm: 8px;
    --tap: 48px;          /* minimum touch target */
    --dock-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { overscroll-behavior-y: none; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overflow-x: hidden;
}
/* Selection only where he types or might copy a number. */
input, textarea, .item-details { -webkit-user-select: text; user-select: text; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.hidden { display: none !important; }

.icon-btn {
    width: var(--tap); height: var(--tap); flex: none; border-radius: 50%; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--blue); color: #fff; transition: transform .06s, background .12s;
}
.icon-btn:active { transform: scale(0.94); background: var(--blue-press); }

.content { padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--dock-h) + env(safe-area-inset-bottom) + 28px); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    min-height: var(--tap); background: var(--surface-2); border: none; color: var(--text);
    padding: 12px 18px; border-radius: var(--radius); font-size: 15px; font-weight: 700;
    cursor: pointer; transition: background .12s, transform .06s;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.98); background: var(--surface-hover); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-press); }
.btn-done { background: var(--green); color: #fff; }
.btn-done:active { background: var(--green-press); }
.btn-quiet { background: transparent; color: var(--blue); padding: 12px 14px; }
.btn-quiet:active { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--red); }
.btn-danger.armed { background: var(--red); color: #fff; }
.btn-lg { width: 100%; min-height: 52px; font-size: 16px; }
.btn svg { flex: none; }

/* ── Push banner / status ───────────────────────────────── */
.push-banner {
    display: flex; align-items: center; gap: 12px; justify-content: space-between;
    background: color-mix(in srgb, var(--blue) 14%, var(--surface)); border-radius: var(--radius);
    padding: 8px 8px 8px 14px; margin: 0 0 14px; font-size: 15px; color: var(--text);
}
.push-banner .btn { flex-shrink: 0; }
.status-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--surface); border-radius: var(--radius); padding: 4px 4px 4px 14px;
    margin: 0 0 12px; font-size: 14px; color: var(--text-2); min-height: 52px;
}
.status-bar.error { background: color-mix(in srgb, var(--red) 14%, var(--surface)); color: var(--text); }

/* ── Items (no section labels: the when line says it) ───── */
#list > * + * { margin-top: 18px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--surface); border-radius: var(--radius); transition: background .1s; }
.item.done .item-head { opacity: .5; }
.item.done .item-text { text-decoration: line-through; }
.item.pending { opacity: .6; }

/* The head is the tap target that expands the card. */
.item-head { padding: 14px; cursor: pointer; min-height: 56px; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.item-head:active { background: var(--surface-hover); border-radius: var(--radius); }
.when { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.item.overdue .when { color: var(--red); font-weight: 600; }
.item-text {
    font-size: 16px; font-weight: 600; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item.open .item-text { -webkit-line-clamp: unset; display: block; }

.item-body { display: none; padding: 0 14px 12px; cursor: auto; }
.item.open .item-body { display: block; animation: reveal .16s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.item-details {
    background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px;
    font-size: 15px; line-height: 1.5; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
}
.item-details a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }

.note-box {
    width: 100%; min-height: 76px; max-height: 40vh; display: block;
    background: var(--surface-2); border: 1.5px solid transparent; color: var(--text); border-radius: var(--radius-sm);
    padding: 12px 14px; font-family: inherit; font-size: 16px; line-height: 1.4; resize: none; color-scheme: dark;
}
.note-box:focus { outline: none; border-color: var(--blue); }
.note-box::placeholder, .inbox-form textarea::placeholder { color: var(--text-3); }

.item-actions { display: flex; gap: 10px; margin-top: 14px; }
.item-actions .btn { min-height: 54px; font-size: 16px; }
.item-actions .btn-snooze { flex: 1; }
.item-actions .btn-done { flex: 2; }
.item-actions .btn-reopen { flex: 1; }
.item-foot { display: flex; margin-top: 8px; justify-content: flex-end; }
.item-foot .btn { min-height: 44px; padding: 10px 12px; font-size: 14px; margin-right: -8px; }

.skeleton-card { height: 64px; background: var(--surface); border-radius: var(--radius); animation: pulse 1.4s ease-in-out infinite; }
#list > .skeleton-card + .skeleton-card { margin-top: 10px; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: .6; } }

/* ── Bottom dock ────────────────────────────────────────── */
.dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 70%, color-mix(in srgb, var(--bg) 0%, transparent));
    display: flex; justify-content: center; gap: 10px;
    pointer-events: none;
}
.dock > * { pointer-events: auto; }
.dock .icon-btn { width: 52px; height: 52px; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.dock-btn {
    flex: 1; max-width: 546px; min-height: 52px; border: 1px solid var(--border-light); border-radius: 26px;
    background: var(--surface-2); color: var(--text); font-size: 16px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.dock-btn:active { background: var(--surface-hover); transform: scale(0.99); }
body.typing .dock { display: none; }

/* ── Sheets ─────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal.sheet {
    background: var(--bg); border-top-left-radius: 18px; border-top-right-radius: 18px;
    width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh;
    padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain; animation: slideUp .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grabber { width: 38px; height: 4px; border-radius: 2px; background: var(--border-light); margin: 6px auto 4px; }
.sheet-grabber { cursor: pointer; }
.modal.sheet > .sheet-grabber { margin-bottom: 14px; }

.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
    min-height: 60px; width: 100%; text-align: left; border: none; cursor: pointer; color: var(--text);
    background: var(--surface); border-radius: var(--radius); padding: 10px 16px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 16px; font-weight: 700;
}
.choice small { font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.choice:active { background: var(--surface-hover); }

.add-form, .inbox-form { display: flex; flex-direction: column; gap: 12px; }
.add-form textarea, .add-form input, .inbox-form textarea {
    width: 100%; background: var(--surface); border: 1.5px solid transparent; color: var(--text); border-radius: var(--radius);
    padding: 12px 14px; font-family: inherit; font-size: 16px; color-scheme: dark; min-height: var(--tap);
}
.add-form textarea, .inbox-form textarea { resize: none; }
.add-form textarea:focus, .add-form input:focus, .inbox-form textarea:focus { outline: none; border-color: var(--blue); }
.add-form .check { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); min-height: var(--tap); }
.add-form .check input { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--blue); }
.add-row { display: flex; gap: 10px; }
.add-row input { flex: 1; min-width: 0; }
.type-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { min-height: 44px; background: var(--surface-2); color: var(--text-2); border: none; border-radius: 22px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.pill.active { background: var(--blue); color: #fff; }

.inbox-status { font-size: 14px; color: var(--red); text-align: center; }
.inbox-status:empty { display: none; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + var(--dock-h) + 12px);
    transform: translateX(-50%) translateY(20px); z-index: 200;
    display: flex; align-items: center; gap: 4px; max-width: calc(100vw - 32px);
    background: #fff; color: #111; padding: 4px 6px 4px 20px; min-height: 48px; border-radius: 24px;
    font-size: 15px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.toast span { padding: 8px 14px 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-action {
    min-height: 40px; padding: 8px 16px; border: none; border-radius: 20px; cursor: pointer;
    background: #e8f0fc; color: var(--blue-press); font-size: 15px; font-weight: 800;
}
.error-msg { color: var(--red); font-size: 14px; margin-top: 4px; text-align: center; }

/* ── Login ──────────────────────────────────────────────── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 20px; }
.login-box { text-align: center; width: 100%; max-width: 320px; }
.login-box img { margin-bottom: 14px; border-radius: 12px; }
.login-box h1 { font-size: 24px; font-weight: 800; margin-bottom: 18px; }
.login-box form { display: flex; gap: 8px; }
.login-box input { flex: 1; min-width: 0; min-height: var(--tap); background: var(--surface); border: 1.5px solid transparent; color: var(--text); padding: 12px 14px; border-radius: var(--radius); font-family: inherit; font-size: 16px; }
.login-box input:focus { outline: none; border-color: var(--blue); }

@media (min-width: 660px) {
    .modal.sheet { align-self: center; border-radius: 18px; max-height: 88vh; }
    .modal-backdrop { align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Habits ─────────────────────────────────────────────── */
#habits { scroll-margin-top: calc(env(safe-area-inset-top) + 16px); }
.habits-card { background: var(--surface); border-radius: var(--radius); padding: 4px 0; }
.habit { display: flex; flex-direction: column; padding: 0 0 8px; }
.habit + .habit { border-top: 1px solid var(--border); }
.habit.pending { opacity: .85; }
.hrow {
    width: 100%; min-height: 52px; display: flex; align-items: center; gap: 14px; text-align: left;
    background: none; border: none; color: var(--text); cursor: pointer; padding: 8px 16px 0;
}
.hrow:active .hcheck { transform: scale(0.9); }
.hcheck {
    width: 32px; height: 32px; flex: none; border-radius: 50%; border: 2px solid var(--border-light);
    display: inline-flex; align-items: center; justify-content: center; color: transparent;
    transition: background .12s, border-color .12s, transform .12s;
}
.habit.done .hcheck { background: var(--green); border-color: var(--green); color: #fff; }
.hname { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.habit.done .hname { color: var(--text-2); }
/* Recent days, oldest first, today last: a quiet row, each dot a 30 px tap target. */
.dots { display: flex; padding-left: 54px; margin-top: -2px; }
.dot {
    width: 30px; height: 26px; flex: none; border: none; background: none; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.dot.dx::before { background: var(--green); }
.dot.dm::before { background: color-mix(in srgb, var(--red) 55%, var(--surface)); }
.dot.do::before { background: none; box-shadow: inset 0 0 0 1.5px var(--blue); }
.dot:active::before { transform: scale(1.4); }
.hother { border-top: 1px solid var(--border); }
.hother summary {
    list-style: none; cursor: pointer; min-height: var(--tap); padding: 0 16px;
    display: flex; align-items: center; font-size: 14px; font-weight: 600; color: var(--text-3);
}
.hother summary::-webkit-details-marker { display: none; }

/* ── Claude is tracking (collapsed, read-only) ───────────── */
.followups > summary {
    list-style: none; cursor: pointer; min-height: var(--tap); padding: 0 4px;
    display: flex; align-items: center; font-size: 14px; font-weight: 600; color: var(--text-3);
}
.followups > summary::-webkit-details-marker { display: none; }
.followups[open] > summary { color: var(--text-2); }
.fu-label { font-size: 13px; font-weight: 600; color: var(--text-3); padding: 10px 4px 8px; }
.item.fu .item-text { font-weight: 500; }
