/* ── Theme variables (dark default) ── */
:root {
    --bg: #1c1c1e;
    --bg-2: #2c2c2e;
    --bg-3: #3a3a3c;
    --text: #ffffff;
    --text-2: #ebebf5;
    --text-3: #98989d;
    --text-muted: #636366;
    --border: #38383a;
    --border-2: #48484a;
    --primary: #667eea;
    --primary-2: #764ba2;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #f5a623;
    --shadow: rgba(0,0,0,0.5);
    --overlay: rgba(0,0,0,0.6);
    --primary-tint: rgba(102,126,234,0.18);
    --success-tint: rgba(52,199,89,0.18);
    --danger-tint: rgba(255,59,48,0.18);

    --base-font: 16px;
    --scale: 1;
}

[data-theme="light"] {
    --bg: #ffffff;
    --bg-2: #f2f2f7;
    --bg-3: #e5e5ea;
    --text: #1c1c1e;
    --text-2: #3a3a3c;
    --text-3: #8e8e93;
    --text-muted: #aeaeb2;
    --border: #e5e5ea;
    --border-2: #d1d1d6;
    --shadow: rgba(0,0,0,0.15);
    --overlay: rgba(0,0,0,0.4);
    --primary-tint: #f0f0ff;
    --success-tint: #e8faf0;
    --danger-tint: #fff0f0;
}

body.font-2x { --scale: 1.6; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-2);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior: none;
    font-size: calc(16px * var(--scale));
}

/* ── Auth ── */
#auth-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
}
#auth-container.hidden { display: none; }

.auth-box {
    width: 100%;
    max-width: 340px;
    background: var(--bg);
    border-radius: 24px;
    padding: calc(40px * var(--scale)) calc(28px * var(--scale));
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.auth-icon { font-size: calc(48px * var(--scale)); margin-bottom: 12px; }
.auth-box h1 { font-size: calc(28px * var(--scale)); font-weight: 700; color: var(--text); }
.auth-subtitle { color: var(--text-3); font-size: calc(15px * var(--scale)); margin: 8px 0 28px; }

#google-signin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: calc(14px * var(--scale));
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border-2);
    border-radius: 12px;
    font-size: calc(16px * var(--scale));
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
#google-signin-btn:active { background: var(--bg-2); }

.message { margin-top: 14px; padding: 10px; border-radius: 10px; font-size: calc(14px * var(--scale)); }
.message.error { background: var(--danger-tint); color: var(--danger); }

/* ── App ── */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
}
#app-container.hidden { display: none; }

.header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header h1 { font-size: calc(20px * var(--scale)); font-weight: 700; color: var(--text); flex: 1; }

.icon-btn {
    background: none;
    border: none;
    font-size: calc(20px * var(--scale));
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    line-height: 1;
}

/* ── Profile image + dropdown ── */
.profile-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-img {
    width: calc(34px * var(--scale));
    height: calc(34px * var(--scale));
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid var(--border);
    display: block;
    transition: border-color 0.15s;
}
.profile-img:active { border-color: var(--primary); }

/* Red dot indicating an update is available */
.profile-wrap.has-update::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--bg);
    pointer-events: none;
}

.profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 30px var(--shadow);
    overflow: hidden;
    min-width: 180px;
    z-index: 50;
}
.profile-menu.hidden { display: none; }

.profile-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: calc(14px * var(--scale)) 18px;
    background: none;
    border: none;
    text-align: left;
    font-size: calc(15px * var(--scale));
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.profile-menu-item:last-child { border-bottom: none; color: var(--danger); }
.profile-menu-item:active { background: var(--bg-2); }

.update-pill {
    display: inline-block;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 8px;
}

/* ── Reminder List ── */
.reminders-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 100px;
    display: block;
    background: var(--bg);
    -webkit-overflow-scrolling: touch;
}

.reminder-item {
    background: var(--bg);
    padding: calc(14px * var(--scale)) 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.reminder-content { flex: 1; min-width: 0; cursor: pointer; }
.reminder-text {
    font-size: calc(16px * var(--scale));
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
    line-height: 1.4;
    margin-bottom: 6px;
}
.reminder-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.reminder-date, .reminder-repeat {
    font-size: calc(12px * var(--scale));
    color: var(--text-3);
}

.check-btn {
    background: none;
    border: 2px solid var(--success);
    color: var(--success);
    font-size: calc(14px * var(--scale));
    font-weight: 700;
    cursor: pointer;
    width: calc(28px * var(--scale));
    height: calc(28px * var(--scale));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}
.check-btn:active {
    background: var(--success);
    color: white;
}

.check-done {
    width: calc(28px * var(--scale));
    height: calc(28px * var(--scale));
    border-radius: 50%;
    background: var(--success);
    color: white;
    font-size: calc(14px * var(--scale));
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.completed-item { opacity: 0.5; }
.completed-item .reminder-text { text-decoration: line-through; }

.delete-btn {
    background: none;
    border: none;
    font-size: calc(18px * var(--scale));
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.35;
    transition: opacity 0.15s;
}
.delete-btn:active { opacity: 1; }

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    gap: 6px;
}
.empty-state.hidden { display: none; }

/* ── Section headers ── */
.section-header {
    font-size: calc(11px * var(--scale));
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 10px 16px 6px;
    background: var(--bg-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.section-header:first-child { padding-top: 14px; }

.section-overdue   { color: var(--danger); }
.section-today     { color: var(--primary); }
.section-tomorrow  { color: var(--warning); }
.section-rest      { color: var(--text-3); }
.section-completed { color: var(--text-3); margin-top: 8px; }

.section-chevron {
    font-size: calc(18px * var(--scale));
    color: var(--text-muted);
    transition: transform 0.2s;
    display: inline-block;
}
.section-chevron.expanded { transform: rotate(90deg); }

.section-empty {
    padding: 12px 16px;
    font-size: calc(14px * var(--scale));
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.empty-icon { font-size: calc(52px * var(--scale)); margin-bottom: 8px; }
.empty-state p { font-size: calc(17px * var(--scale)); font-weight: 600; color: var(--text-2); }
.empty-state span { font-size: calc(14px * var(--scale)); color: var(--text-3); }

/* ── FAB ── */
#fab-btn {
    position: fixed;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
    right: 24px;
    width: calc(58px * var(--scale));
    height: calc(58px * var(--scale));
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    font-size: calc(30px * var(--scale));
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(102,126,234,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 20;
}
#fab-btn:active { transform: scale(0.92); box-shadow: 0 2px 10px rgba(102,126,234,0.4); }
#fab-btn.hidden { display: none; }

/* ── Modal ── */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    backdrop-filter: blur(2px);
}
#modal-overlay.hidden { display: none; }

#modal-sheet {
    width: 100%;
    background: var(--bg);
    border-radius: 24px 24px 0 0;
    padding: 12px 20px 32px;
    padding-bottom: max(32px, calc(env(safe-area-inset-bottom) + 20px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 92vh;
    overflow-y: auto;
}
#modal-sheet.open { transform: translateY(0); }

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border-2);
    border-radius: 2px;
    margin: 0 auto 20px;
}
#modal-sheet h2 { font-size: calc(18px * var(--scale)); font-weight: 700; color: var(--text); margin-bottom: 24px; }

/* ── Form ── */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: calc(13px * var(--scale));
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

#reminder-text {
    width: 100%;
    padding: calc(14px * var(--scale));
    background: var(--bg-2);
    border: none;
    border-radius: 12px;
    font-size: calc(16px * var(--scale));
    color: var(--text);
    outline: none;
    transition: background 0.15s;
}
#reminder-text.error { background: var(--danger-tint); }
#reminder-text::placeholder { color: var(--text-muted); }
#reminder-text:focus { background: var(--bg-3); }

.picker-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(14px * var(--scale));
    background: var(--bg-2);
    border: none;
    border-radius: 12px;
    font-size: calc(16px * var(--scale));
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.picker-btn:active { background: var(--bg-3); }
#date-display { flex: 1; font-weight: 500; }
.chevron { color: var(--text-muted); font-size: calc(18px * var(--scale)); transform: rotate(90deg); display: inline-block; }

/* ── Calendar ── */
#calendar-wrap {
    margin-top: 8px;
    background: var(--bg-2);
    border-radius: 14px;
    padding: 14px;
    overflow: hidden;
}
#calendar-wrap.hidden { display: none; }

.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
#cal-label { font-size: calc(15px * var(--scale)); font-weight: 700; color: var(--text); }

.cal-nav {
    background: none;
    border: none;
    font-size: calc(22px * var(--scale));
    color: var(--primary);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    line-height: 1;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 4px;
}
.cal-weekdays span {
    text-align: center;
    font-size: calc(12px * var(--scale));
    font-weight: 600;
    color: var(--text-3);
    padding: 4px 0;
}

#cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(15px * var(--scale));
    color: var(--text);
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.1s;
    font-weight: 400;
}
.cal-day:active { background: var(--bg-3); }
.cal-day.empty { cursor: default; }
.cal-day.today { font-weight: 700; color: var(--primary); }
.cal-day.selected {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white !important;
    font-weight: 700;
}

/* ── Select ── */
.select-wrap { position: relative; }
.select-wrap select {
    width: 100%;
    padding: calc(14px * var(--scale));
    padding-right: 40px;
    background: var(--bg-2);
    border: none;
    border-radius: 12px;
    font-size: calc(16px * var(--scale));
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    font-weight: 500;
}
.select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    color: var(--text-muted);
    font-size: calc(18px * var(--scale));
    pointer-events: none;
}

/* ── Save button ── */
#save-btn {
    width: 100%;
    padding: calc(16px * var(--scale));
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: none;
    border-radius: 14px;
    font-size: calc(17px * var(--scale));
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.15s, transform 0.1s;
}
#save-btn:active { opacity: 0.85; transform: scale(0.98); }

/* ── Manage bar ── */
.manage-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 30;
    box-shadow: 0 -4px 20px var(--shadow);
}
.manage-bar.hidden { display: none; }

#manage-count {
    font-size: calc(14px * var(--scale));
    font-weight: 600;
    color: var(--text-3);
    text-align: center;
}

.manage-actions { display: flex; gap: 10px; }

.manage-action-btn {
    flex: 1;
    padding: calc(13px * var(--scale));
    border: none;
    border-radius: 12px;
    font-size: calc(15px * var(--scale));
    font-weight: 600;
    cursor: pointer;
}
.manage-action-btn:disabled { opacity: 0.35; cursor: default; }
.manage-action-btn.complete { background: var(--success-tint); color: var(--success); }
.manage-action-btn.delete   { background: var(--danger-tint); color: var(--danger); }

.manage-cancel-btn {
    background: var(--bg-2);
    border: none;
    border-radius: 12px;
    padding: calc(12px * var(--scale));
    font-size: calc(15px * var(--scale));
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    width: 100%;
}

.reminder-item.selectable { cursor: pointer; }
.reminder-item.selected { background: var(--primary-tint); }

.manage-checkbox {
    width: calc(22px * var(--scale));
    height: calc(22px * var(--scale));
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
    margin-right: 4px;
}

/* ── Bulk Upload Page ── */
#bulk-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-2);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
#bulk-overlay.hidden { display: none; }
#bulk-overlay.open { transform: translateX(0); }
#bulk-sheet {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bulk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: calc(17px * var(--scale));
    font-weight: 600;
    color: var(--text);
}
.bulk-back-btn {
    background: none;
    border: none;
    font-size: calc(26px * var(--scale));
    color: var(--primary);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    width: 36px;
}

.bulk-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    -webkit-overflow-scrolling: touch;
}

.bulk-premium-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    font-size: calc(12px * var(--scale));
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 20px;
    padding: 5px 14px;
    margin-bottom: 16px;
}

.bulk-title {
    font-size: calc(24px * var(--scale));
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.2;
}

.bulk-sub {
    font-size: calc(15px * var(--scale));
    color: var(--text-3);
    margin-bottom: 24px;
    line-height: 1.5;
}

.bulk-format-card {
    background: var(--bg);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}
.bulk-format-title {
    font-size: calc(11px * var(--scale));
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    padding: 10px 14px 6px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
}
.bulk-format-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: calc(13px * var(--scale));
    color: var(--text-2);
    gap: 8px;
}
.bulk-format-row:last-child { border-bottom: none; }
.bulk-format-row.header-row {
    font-weight: 700;
    font-size: calc(12px * var(--scale));
    color: var(--primary);
    background: var(--primary-tint);
}
.bulk-format-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bulk-tips { display: flex; flex-direction: column; gap: 14px; }
.bulk-tip {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}
.bulk-tip-icon { font-size: calc(22px * var(--scale)); flex-shrink: 0; line-height: 1; margin-top: 2px; }
.bulk-tip strong { font-size: calc(14px * var(--scale)); font-weight: 600; color: var(--text); display: block; margin-bottom: 3px; }
.bulk-tip p { font-size: calc(13px * var(--scale)); color: var(--text-3); margin: 0; line-height: 1.4; }

.bulk-footer {
    padding: 16px 20px;
    padding-bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.bulk-upload-btn {
    width: 100%;
    padding: calc(18px * var(--scale));
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: none;
    border-radius: 16px;
    font-size: calc(18px * var(--scale));
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    letter-spacing: 0.2px;
}
.bulk-upload-btn:active { opacity: 0.85; transform: scale(0.98); }

/* ── CSV Import Modal ── */
#import-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    backdrop-filter: blur(2px);
}
#import-overlay.hidden { display: none; }

#import-sheet {
    width: 100%;
    background: var(--bg);
    border-radius: 24px 24px 0 0;
    padding: 12px 20px 32px;
    padding-bottom: max(32px, calc(env(safe-area-inset-bottom) + 20px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}
#import-sheet.open { transform: translateY(0); }
#import-sheet h2 { font-size: calc(18px * var(--scale)); font-weight: 700; color: var(--text); margin-bottom: 6px; }

.import-help {
    font-size: calc(13px * var(--scale));
    color: var(--text-3);
    line-height: 1.5;
    margin-bottom: 14px;
}

#import-preview {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 14px;
}

.import-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.import-row:last-child { border-bottom: none; }
.import-row-error { background: var(--danger-tint); }

.import-text { font-size: calc(15px * var(--scale)); font-weight: 500; color: var(--text); }
.import-meta { font-size: calc(12px * var(--scale)); color: var(--text-3); }
.import-error-msg { font-size: calc(13px * var(--scale)); color: var(--danger); }
.import-row-dupe { background: rgba(245,166,35,0.18); }
.import-dupe-badge {
    display: inline-block;
    font-size: calc(10px * var(--scale));
    font-weight: 700;
    background: var(--warning);
    color: white;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.import-footer { display: flex; gap: 10px; }
.import-cancel-btn {
    flex: 1;
    padding: calc(14px * var(--scale));
    background: var(--bg-2);
    border: none;
    border-radius: 12px;
    font-size: calc(16px * var(--scale));
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
}
#import-confirm-btn {
    flex: 2;
    padding: calc(14px * var(--scale));
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: calc(16px * var(--scale));
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
#import-confirm-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Paywall Modal ── */
#paywall-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    backdrop-filter: blur(4px);
}
#paywall-overlay.hidden { display: none; }

#paywall-sheet {
    width: 100%;
    background: var(--bg);
    border-radius: 28px 28px 0 0;
    padding: 12px 28px 40px;
    padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 28px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    text-align: center;
}
#paywall-sheet.open { transform: translateY(0); }

.paywall-icon { font-size: calc(48px * var(--scale)); margin: 12px 0 8px; }
.paywall-title { font-size: calc(22px * var(--scale)); font-weight: 700; color: var(--text); margin-bottom: 10px; }
.paywall-sub { font-size: calc(15px * var(--scale)); color: var(--text-3); line-height: 1.5; margin-bottom: 24px; }
.paywall-sub strong { color: var(--text); }

.paywall-price {
    font-size: calc(42px * var(--scale));
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 20px;
    line-height: 1;
}
.paywall-price span { font-size: calc(18px * var(--scale)); font-weight: 500; color: var(--text-3); }

#pay-btn {
    width: 100%;
    padding: calc(16px * var(--scale));
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white;
    border: none;
    border-radius: 14px;
    font-size: calc(17px * var(--scale));
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 12px;
}

.paywall-cancel-btn {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: calc(15px * var(--scale));
    cursor: pointer;
    padding: 8px;
    width: 100%;
}

/* ── Settings Page ── */
#settings-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-2);
    z-index: 110;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
#settings-overlay.hidden { display: none; }
#settings-overlay.open { transform: translateX(0); }

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 40px;
    -webkit-overflow-scrolling: touch;
}

.settings-section {
    margin-bottom: 28px;
}
.settings-section-title {
    font-size: calc(11px * var(--scale));
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    padding: 0 4px 8px;
}
.settings-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(14px * var(--scale)) 16px;
    border-bottom: 1px solid var(--border);
    font-size: calc(15px * var(--scale));
    color: var(--text);
    cursor: pointer;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-weight: 500;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .check {
    color: var(--primary);
    font-size: calc(18px * var(--scale));
    font-weight: 700;
    opacity: 0;
}
.settings-row.selected .check { opacity: 1; }
.settings-row .label { flex: 1; }

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(14px * var(--scale)) 16px;
    font-size: calc(15px * var(--scale));
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.settings-toggle-row:last-child { border-bottom: none; }

/* iOS-style toggle switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 30px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-3);
    border-radius: 30px;
    transition: background 0.2s;
    cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 26px;
    height: 26px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.settings-info {
    font-size: calc(12px * var(--scale));
    color: var(--text-3);
    padding: 8px 16px 0;
    line-height: 1.5;
}

.time-select {
    background: var(--bg-2);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: calc(14px * var(--scale));
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    text-align: right;
}

/* ── Toast (update available) ── */
.toast {
    position: fixed;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: calc(100vw - 32px);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast-text {
    font-size: calc(14px * var(--scale));
    color: var(--text);
    font-weight: 500;
}
.toast-actions { display: flex; gap: 8px; }
.toast-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: calc(13px * var(--scale));
    font-weight: 600;
    cursor: pointer;
}
.toast-btn.secondary {
    background: var(--bg-2);
    color: var(--text);
}
