/* ====================== Tokens — flat, zen, minimal ====================== */
:root {
    --safe-top: 0px;
    --bottom-inset: 0px;

    --bg:        #ffffff;
    --surface:   #ffffff;
    --surface-2: #f4f5f7;
    --border:    #ebecef;
    --text:      #1a1c20;
    --text-2:    #707684;
    --text-3:    #a4a9b4;
    --accent:    #2f6df6;
    --danger:    #e5484d;
    --line:      1px solid var(--border);
    --radius:    14px;
    --radius-sm: 10px;
    --tap: rgba(0,0,0,.045);
}
[data-theme="dark"] {
    --bg:        #0e0f12;
    --surface:   #16181d;
    --surface-2: #1d2026;
    --border:    #262a31;
    --text:      #eef0f3;
    --text-2:    #8b91a0;
    --text-3:    #5b6170;
    --accent:    #5b8dff;
    --danger:    #ff6166;
    --tap: rgba(255,255,255,.05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior: none; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg); color: var(--text);
    display: flex; flex-direction: column;
    height: 100vh; height: 100dvh;
    font-size: 15px;
    transition: background .2s, color .2s;
}
.ic { display: block; }
button { font-family: inherit; }

#safe-top { height: var(--safe-top); flex: 0 0 auto; }

.app-header { flex: 0 0 auto; padding: 8px 18px 6px; }
.app-header[hidden] { display: none; }
.app-header h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }

.app-main { flex: 1 1 auto; position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 14px; }
.screen[hidden] { display: none; }

/* ====================== Tab bar ====================== */
.tabbar {
    flex: 0 0 auto; display: flex;
    background: var(--surface); border-top: var(--line);
    padding: 6px 6px calc(6px + var(--bottom-inset));
}
.tab {
    flex: 1; background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 5px 0; color: var(--text-3);
    font-size: 10px; font-weight: 600;
    transition: color .15s;
}
.tab-ico { display: inline-flex; }
.tab.active { color: var(--accent); }

/* ====================== NOW — zen ====================== */
.screen-now { padding: 0 22px 14px; }
.now { height: 100%; display: flex; flex-direction: column; }
.now-body { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; text-align: center; }
.now-context { font-size: 13px; color: var(--text-3); font-weight: 500; margin-bottom: 12px; }
.now-context:empty { display: none; }
.now-text { font-size: 24px; line-height: 1.3; font-weight: 600; letter-spacing: -.02em; color: var(--text); max-width: 320px; }
.now-empty { color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.now-empty[hidden], .now-live[hidden] { display: none; }
.now-empty p { margin: 0; font-size: 16px; }
.now-empty-ic { color: var(--text-3); }

.now-foot { flex: 0 0 auto; padding-bottom: 6px; }
.now-controls { display: flex; gap: 26px; justify-content: center; }
.ctrl {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    color: var(--text-2); font-size: 12px; font-weight: 500;
    padding: 4px;
    transition: color .15s, transform .1s;
}
.ctrl span { width: 52px; height: 52px; border-radius: 50%; border: var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--text); background: var(--surface); }
.ctrl:active { transform: scale(.94); }
.ctrl:active span { background: var(--tap); }
.now-progress { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 16px; min-height: 14px; }

/* ====================== LIST ====================== */
.project-picker {
    width: 100%; display: flex; align-items: center; gap: 8px;
    background: var(--surface-2); border: none; cursor: pointer;
    border-radius: var(--radius-sm); padding: 11px 14px; margin: 6px 0 14px;
    color: var(--text); font-size: 16px; font-weight: 700;
}
.pp-ic, .pp-chev { display: inline-flex; color: var(--text-2); }
.pp-name { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tree { display: flex; flex-direction: column; gap: 16px; padding-bottom: 88px; }
.list-head { display: flex; align-items: center; gap: 4px; margin: 0 2px 6px; }
.list-head h3 { margin: 0; flex: 1; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.list-head .iconbtn { width: 28px; height: 28px; color: var(--text-3); }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.swipe { position: relative; border-radius: var(--radius-sm); overflow: hidden; }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; color: #fff; }
.swipe-bg .ic { display: none; }
.swipe.bg-today  .swipe-bg { background: var(--accent); }
.swipe.bg-today  .swipe-bg .left { display: block; }
.swipe.bg-delete .swipe-bg { background: var(--danger); }
.swipe.bg-delete .swipe-bg .right { display: block; margin-left: auto; }

.task-row {
    position: relative; display: flex; align-items: center; gap: 10px;
    background: var(--surface); border: var(--line);
    padding: 10px 12px; border-radius: var(--radius-sm);
    touch-action: pan-y; will-change: transform;
}
.task-row.sub { margin-left: 22px; }
.twist { color: var(--text-3); width: 18px; height: 18px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.twist.empty { visibility: hidden; }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.task-row.completed .task-title { color: var(--text-3); text-decoration: line-through; }
.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 11px; color: var(--text-3); }
.task-meta .ic { width: 13px; height: 13px; }
.task-meta .today-flag { color: var(--accent); display: inline-flex; align-items: center; gap: 3px; }

.round-check {
    width: 22px; height: 22px; flex: 0 0 auto; cursor: pointer;
    border: 2px solid var(--text-3); border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; transition: background .15s, border-color .15s;
}
.round-check .ic { width: 14px; height: 14px; opacity: 0; }
.round-check.checked { background: var(--accent); border-color: var(--accent); }
.round-check.checked .ic { opacity: 1; }

.iconbtn { background: none; border: none; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-sm); }
.iconbtn:active { background: var(--tap); }
.iconbtn.solid { background: var(--accent); color: #fff; }

.fab {
    position: absolute; right: 18px; bottom: calc(18px + var(--bottom-inset));
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--accent); color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(47,109,246,.35);
}
.fab:active { transform: scale(.94); }
.empty-hint { color: var(--text-3); font-size: 13px; text-align: center; padding: 24px 0; }

/* ====================== PROFILE ====================== */
.profile { display: flex; flex-direction: column; align-items: center; padding-top: 14px; }
.profile-avatar { width: 76px; height: 76px; border-radius: 50%; background: var(--surface-2); background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.profile-name { margin: 12px 0 2px; font-size: 19px; font-weight: 700; }
.profile-username { margin: 0; color: var(--text-3); font-size: 13px; }
.profile-stats { display: flex; gap: 10px; margin: 20px 0; width: 100%; }
.stat { flex: 1; background: var(--surface-2); border-radius: var(--radius); padding: 14px 6px; text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-2); margin-top: 3px; }
.settings-group { width: 100%; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px; font-size: 15px; border-bottom: var(--line); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: none; padding: 6px 11px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
[data-theme="dark"] .seg button.active { background: var(--accent); color: #fff; box-shadow: none; }
.version { color: var(--text-3); font-size: 11px; margin-top: 22px; }

/* ====================== Modals ====================== */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
/* prompt & confirm must always sit above the sheets that can trigger them */
#prompt-modal { z-index: 60; }
#confirm-modal { z-index: 70; }
.modal-overlay[hidden] { display: none; }
.modal-sheet { width: 100%; max-width: 540px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + var(--bottom-inset)); max-height: 90vh; overflow-y: auto; animation: slideup .24s cubic-bezier(.2,.8,.2,1); }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.modal-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 14px; }
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-title-input { flex: 1; border: none; background: none; font-size: 18px; font-weight: 700; color: var(--text); outline: none; }
.modal-note { width: 100%; border: var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); padding: 11px; font-size: 14px; margin-top: 12px; min-height: 60px; resize: vertical; font-family: inherit; outline: none; }
.modal-subhead { margin: 18px 0 8px; font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.modal-subtasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.modal-subtasks li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 9px; font-size: 14px; }
.modal-subtasks li.done span.t { color: var(--text-3); text-decoration: line-through; }
.modal-subtasks li span.t { flex: 1; }
.modal-subtasks .mini-del { color: var(--text-3); cursor: pointer; background: none; border: none; display: inline-flex; padding: 2px; }
.modal-add-sub { display: flex; gap: 8px; margin-top: 8px; }
.modal-add-sub input { flex: 1; border: var(--line); background: var(--surface-2); color: var(--text); border-radius: 9px; padding: 10px 12px; font-size: 14px; outline: none; }
.modal-footer { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary, .btn-ghost, .btn-danger { flex: 1; border: none; border-radius: var(--radius-sm); padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.full { flex: none; width: 100%; margin-top: 14px; }
.btn-danger { background: var(--danger); color: #fff; }
.prompt-input { width: 100%; border: var(--line); background: var(--surface-2); color: var(--text); border-radius: var(--radius-sm); padding: 12px; font-size: 16px; margin: 6px 0 2px; outline: none; }
#prompt-title, #confirm-title { margin: 2px 0; font-size: 17px; font-weight: 700; }
.confirm-text { color: var(--text-2); font-size: 14px; margin: 6px 0 0; }

.project-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.project-list li { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 16px; }
.project-list li.active { background: var(--surface-2); font-weight: 700; }
.project-list li .pj-ic { color: var(--text-2); display: inline-flex; }
.project-list li .pj-name { flex: 1; }
.project-list li .pj-del { color: var(--text-3); background: none; border: none; cursor: pointer; display: inline-flex; padding: 4px; }
.project-list li .pj-check { color: var(--accent); display: inline-flex; }

/* ====================== Toast ====================== */
.toast { position: fixed; left: 50%; bottom: calc(82px + var(--bottom-inset)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; z-index: 90; }
.toast[hidden] { display: none; }
