/* ============ Design tokens ============ */
:root {
    --bg: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --border: #e3e8ef;
    --text: #1d2939;
    --text-muted: #667085;
    --text-faint: #98a2b3;
    --primary: #0b3d5c;
    --primary-dark: #082c43;
    --accent: #2e9e5b;
    --accent-light: #e8f8ee;
    --accent-border: #b9ecc9;
    --danger: #e5484d;
    --danger-light: #fdecec;
    --info: #3a7bd5;
    --info-light: #eaf2fb;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.14);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1720;
        --surface: #17212c;
        --surface-2: #1d2833;
        --border: #2a3744;
        --text: #eaf0f6;
        --text-muted: #9aa9b8;
        --text-faint: #6b7a89;
        --primary: #4fa3d9;
        --primary-dark: #a9d4f2;
        --accent: #3ecb7a;
        --accent-light: #143423;
        --accent-border: #205939;
        --danger: #ff6b6f;
        --danger-light: #3a1618;
        --info: #6fa8f0;
        --info-light: #16283d;
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 40px env(safe-area-inset-left);
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============ App shell ============ */
.wrap {
    max-width: 760px;
    margin: 0 auto;
    background: var(--surface);
    padding: 20px 16px 40px;
}
@media (min-width: 700px) {
    body { padding-top: 32px; padding-bottom: 60px; }
    .wrap {
        border-radius: var(--radius-lg);
        padding: 34px 38px 44px;
        box-shadow: var(--shadow);
    }
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.header-actions { display: flex; align-items: center; gap: 8px; }

h1 {
    margin: 0 0 6px;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--primary);
}
@media (min-width: 700px) { h1 { font-size: 26px; } }

.badge {
    background: #ffe8b3;
    color: #7a5200;
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 11px;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
@media (prefers-color-scheme: dark) { .badge { background: #4a3a12; color: #ffd98a; } }

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 17px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover { background: var(--border); }
.icon-btn:active { transform: scale(0.94); }

.sub {
    margin: 4px 0 18px;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.55;
}

/* ============ Alerts ============ */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13.5px;
    font-weight: 500;
}
.alert.success { background: var(--accent-light); border: 1px solid var(--accent-border); color: var(--accent); }
.alert.error { background: var(--danger-light); border: 1px solid var(--danger); color: var(--danger); }
.alert.info { background: var(--info-light); border: 1px solid var(--info); color: var(--info); }

/* ============ Progress ============ */
.progress-box { margin-bottom: 22px; }
.progress-bar-bg {
    background: var(--border);
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
}
.progress-bar-fill {
    background: linear-gradient(90deg, var(--accent), #58d488);
    height: 100%;
    border-radius: 20px;
    transition: width 0.35s ease;
    width: 0%;
}
.progress-text {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ============ Checklist groups ============ */
.group { margin-bottom: 24px; }
.group h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    margin: 0 0 12px;
}
.group-icon { font-size: 17px; }

.doc-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 9px;
    background: var(--surface-2);
    transition: background 0.2s, border-color 0.2s;
}
.doc-row.checked {
    background: var(--accent-light);
    border-color: var(--accent-border);
}
@media (min-width: 700px) {
    .doc-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }
}

.doc-label {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    flex: 1 1 260px;
    cursor: pointer;
    font-size: 14.5px;
    line-height: 1.5;
    position: relative;
}
.doc-label input[type="checkbox"] {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.check-visual {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 2px solid var(--text-faint);
    background: var(--surface);
    position: relative;
    margin-top: 1px;
    transition: background 0.15s, border-color 0.15s;
}
.doc-label input[type="checkbox"]:checked + .check-visual {
    background: var(--accent);
    border-color: var(--accent);
}
.check-visual::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s ease;
}
.doc-label input[type="checkbox"]:checked + .check-visual::after {
    transform: rotate(45deg) scale(1);
}
.doc-label input[type="checkbox"]:focus-visible + .check-visual {
    outline: 2px solid var(--info);
    outline-offset: 2px;
}
.doc-label-text { color: var(--text); }
.doc-row.checked .doc-label-text { color: var(--text-muted); }

.note-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}
.note-input:focus { outline: 2px solid var(--info); outline-offset: 1px; }
@media (min-width: 700px) {
    .note-input { flex: 1 1 180px; width: auto; }
}

/* ============ Buttons ============ */
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 26px;
    position: sticky;
    bottom: 12px;
}
.save-btn, .ghost-btn, .primary-btn {
    border: none;
    padding: 14px 22px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.save-btn, .primary-btn {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
}
.save-btn:hover, .primary-btn:hover { background: var(--primary-dark); }
.save-btn:active, .primary-btn:active { transform: scale(0.98); }
.save-btn:disabled, .primary-btn:disabled { opacity: 0.55; }
.save-btn { flex: 1 1 160px; max-width: 260px; }
.primary-btn { width: 100%; }

.ghost-btn {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    flex: 1 1 160px;
    max-width: 260px;
}
.ghost-btn:hover { background: var(--border); }
.ghost-btn.small { flex: 0 0 auto; padding: 9px 16px; font-size: 13.5px; }
.ghost-btn.danger { color: var(--danger); border-color: var(--danger); }
.ghost-btn.danger:hover { background: var(--danger-light); }
.ghost-btn:disabled { opacity: 0.5; cursor: default; }

.link-btn {
    background: none;
    border: none;
    color: var(--info);
    font-size: 13.5px;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px 0;
    display: block;
    margin: 0 auto;
}

.footer-note {
    margin-top: 28px;
    font-size: 12px;
    color: var(--text-faint);
    text-align: center;
    line-height: 1.6;
}
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }

/* ============ Lock screen ============ */
.lock-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.lock-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 34px 26px 28px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.lock-icon { font-size: 38px; margin-bottom: 10px; }
.lock-view.hidden { display: none; }
.lock-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 6px;
}
.lock-sub {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}
.pin-input {
    width: 100%;
    padding: 14px;
    font-size: 20px;
    letter-spacing: 6px;
    text-align: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: var(--surface-2);
    color: var(--text);
}
.pin-input:focus { outline: none; border-color: var(--info); background: var(--surface); }
.pin-input.small { font-size: 15px; letter-spacing: 3px; padding: 10px; }

.lock-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 12px;
}

.faceid-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--primary);
    background: var(--surface);
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 14px;
}
.faceid-btn:hover { background: var(--surface-2); }
.faceid-btn:disabled { opacity: 0.6; }

/* ============ Settings panel ============ */
.settings-panel {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 32, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    padding: 0;
}
@media (min-width: 700px) {
    .settings-panel { align-items: center; }
}
.settings-card {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 24px 22px 30px;
    max-height: 88vh;
    overflow-y: auto;
}
@media (min-width: 700px) {
    .settings-card { border-radius: var(--radius-lg); padding: 30px 30px 26px; }
}
.settings-card h2 {
    margin: 0 0 18px;
    font-size: 18px;
    color: var(--primary);
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.settings-row-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.settings-row-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.settings-block {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.settings-block .settings-row-title { margin-bottom: 10px; }
.settings-card .link-btn { margin-top: 14px; }

/* ============ Small screens ============ */
@media (max-width: 480px) {
    .doc-row { padding: 14px 12px; }
    .doc-label { font-size: 15px; }
    .lock-card { padding: 30px 20px 24px; }
}
