/* Adam QBank (student): "Midnight" theme.
   Night = the .dark-mode class on <html> and <body>. Day = no class.
   The first paint follows the saved choice, or the device setting when none was saved (see the script in <head>).
   This file is loaded after every other style sheet, so it only needs to override. */

@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: local('Inter Regular'), local('Inter-Regular'), url('fonts/inter-regular.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: local('Inter Medium'), local('Inter-Medium'), url('fonts/inter-medium.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: local('Inter SemiBold'), local('Inter-SemiBold'), url('fonts/inter-semibold.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: local('Inter Bold'), local('Inter-Bold'), url('fonts/inter-bold.woff') format('woff'); }

/* ---------------------------------------------------------------- Day (ivory) */
/* Day mode is ivory, not white: a warm cream page with soft-ivory cards. Every text/background pair below keeps WCAG AA
   (>= 4.5:1 for normal text) - see docs/README-STUDENT.md "Midnight design". */
:root {
    color-scheme: light;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Tahoma, Arial, sans-serif;

    --bg: #f3eddd;
    --panel: #fdfaf2;
    --surface: #fdfaf2;
    --raised: #f1eada;
    --surface-hover: #ece4d1;
    --surface-strong: #e6dcc5;
    --tile: #efe8d6;
    --track: #e3dac3;
    --card-bg: var(--panel);

    --border: #dfd5bd;
    --border-strong: #c4b58f;
    --border-glow: transparent;

    --text: #0c1630;
    --text2: #34415e;
    --text-muted: #4e5d7e;

    --primary: #1d5fd1;
    --primary-light: #3b7be8;
    --primary-dark: #164caa;
    --primary-rgb: 29, 95, 209;
    --primary-soft: rgba(29, 95, 209, .10);
    --primary-glow: rgba(29, 95, 209, .16);
    --on-primary: #ffffff;
    --accent: #1d5fd1;
    --accent-light: #3b7be8;
    --accent-glow: rgba(29, 95, 209, .16);

    --success: #0b6d49;
    --success-soft: #e1f1e6;
    --success-glow: transparent;
    --danger: #b9293a;
    --danger-soft: #fbe9e6;
    --danger-glow: transparent;
    --warning: #8a5300;
    --warning-soft: #fbefd3;
    --warning-glow: transparent;

    --shadow: 0 1px 2px rgba(74, 58, 22, .05), 0 8px 24px rgba(74, 58, 22, .07);
    --shadow-lg: 0 18px 50px rgba(74, 58, 22, .20);
    --glow-primary: none;
    --glow-accent: none;
    --glass-rgb: 253, 250, 242;
    --overlay: rgba(32, 26, 12, .5);

    --radius: 22px;
    --radius-sm: 14px;
    --radius-lg: 24px;
    --radius-xl: 28px;

    --ui-icon-accent: var(--primary);
    --ui-icon-soft: var(--primary-soft);
    --ui-icon-outline: var(--border);
    --nav-height: 86px;
}

/* ---------------------------------------------------------------- Night */
.dark-mode {
    color-scheme: dark;

    --bg: #0a1020;
    --panel: #121b30;
    --surface: #121b30;
    --raised: #16213b;
    --surface-hover: #1a2644;
    --surface-strong: #1d2a47;
    --tile: #1d2a47;
    --track: #243252;

    --border: #243252;
    --border-strong: #34456f;

    --text: #e9effa;
    --text2: #c9d6ec;
    --text-muted: #9daecb;

    --primary: #6cb8ff;
    --primary-light: #9bd0ff;
    --primary-dark: #4a9ce8;
    --primary-rgb: 108, 184, 255;
    --primary-soft: rgba(108, 184, 255, .14);
    --primary-glow: rgba(108, 184, 255, .18);
    --on-primary: #06111f;
    --accent: #6cb8ff;
    --accent-light: #9bd0ff;
    --accent-glow: rgba(108, 184, 255, .18);

    --success: #5fd3a1;
    --success-soft: rgba(95, 211, 161, .12);
    --danger: #ff8a8a;
    --danger-soft: rgba(255, 138, 138, .10);
    --warning: #f5c46b;
    --warning-soft: rgba(245, 196, 107, .12);

    --shadow: none;
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
    --glass-rgb: 18, 27, 48;
    --overlay: rgba(4, 8, 20, .68);
}

/* ---------------------------------------------------------------- Page */
html { background: var(--bg); }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-feature-settings: 'cv11', 'ss03';
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
}
body::before, body::after { display: none; }
.main-content { padding-top: 14px; }

/* ---------------------------------------------------------------- Header */
.app-header {
    background: var(--bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 0;
    box-shadow: none;
    padding: calc(14px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 8px max(20px, env(safe-area-inset-left, 0px));
}
.header-inner { flex-wrap: nowrap; gap: 10px; }
.brand-block { flex: 1 1 auto; min-width: 0; }
.logo { gap: 12px; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.brand-icon { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--raised); }
.brand-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; white-space: nowrap; line-height: 1.25; }
.brand-name small { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: 0; color: var(--primary); overflow: hidden; text-overflow: ellipsis; }
.edition-label { color: var(--primary); }
.brand-prefix { display: none; color: var(--text-muted); font-weight: 500; }
@media (min-width: 560px) { .brand-prefix { display: inline; } }
/* Still announced to screen readers; the visible space goes to the specialty name instead. */
.offline-badge { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.app-header .header-actions { gap: 8px; flex: 0 0 auto; margin-inline-start: 0; }
.app-header .header-actions .btn-icon {
    width: 42px; min-width: 42px; height: 42px; min-height: 42px; border-radius: 14px;
    background: var(--panel); border: 1px solid var(--border); color: var(--text2); box-shadow: none;
}
.app-header .header-actions .btn-icon:hover { background: var(--raised); color: var(--primary); border-color: var(--border-strong); }
.app-header .header-actions .btn-icon > .ui-icon { width: 20px; height: 20px; }
@media (max-width: 374px) {
    .app-header .header-actions { flex: 0 0 auto; padding-top: 0; border-top: 0; justify-content: flex-end; }
    .brand-block { flex-basis: auto; }
    .brand-icon { width: 36px; height: 36px; }
    .app-header .header-actions .btn-icon { width: 40px; min-width: 40px; height: 40px; min-height: 40px; }
}

/* ---------------------------------------------------------------- Cards */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card-header { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); gap: 10px; align-items: center; }
.card-header > .ui-icon { border-radius: 10px; }
.card h2, .card h3 { letter-spacing: -.01em; }
.stat-card {
    background: var(--raised);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 10px 12px 12px;
    text-align: start;
    min-width: 0;
}
.stat-value { color: var(--text); font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-muted); font-size: .72rem; font-weight: 500; margin-top: 2px; overflow-wrap: normal; word-break: normal; }
.card.text-center .stat-value { color: var(--primary); }
.card.text-center > div[style*="font-size:4rem"] { color: var(--primary); }
.empty-state { color: var(--text-muted); }

/* Accuracy ring on the dashboard */
.acc-hero { display: flex; align-items: center; gap: 18px; margin: 6px 0 18px; }
.acc-ring { position: relative; width: 96px; height: 96px; flex: none; }
.acc-ring svg { display: block; }
.acc-ring-track { fill: none; stroke: var(--track); stroke-width: 9; }
.acc-ring-fill { fill: none; stroke: var(--primary); stroke-width: 9; stroke-linecap: round; }
.acc-ring-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.acc-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.acc-label, .acc-sub { font-size: .8rem; color: var(--text-muted); }
.acc-main { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: anywhere; }
@media (max-width: 360px) { .acc-hero { gap: 12px; } .acc-ring, .acc-ring svg { width: 80px; height: 80px; } .acc-main { font-size: 1rem; } }

/* ---------------------------------------------------------------- Buttons */
.btn {
    border-radius: 14px;
    font-family: var(--font);
    font-weight: 600;
    letter-spacing: 0;
    background: var(--raised);
    border: 1px solid var(--border-strong);
    color: var(--text);
}
.btn:hover { background: var(--surface-hover); }
.btn-primary, .btn-accent,
.dark-mode .btn-primary, .dark-mode .btn-accent {
    background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700;
}
.btn-primary:hover, .btn-accent:hover,
.dark-mode .btn-primary:hover, .dark-mode .btn-accent:hover {
    background: var(--primary-light); border-color: var(--primary-light); color: var(--on-primary);
}
.dark-mode .btn-primary:hover, .dark-mode .btn-accent:hover { background: #8ac8ff; border-color: #8ac8ff; }
:root:not(.dark-mode) .btn-primary:hover, :root:not(.dark-mode) .btn-accent:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--text2); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--primary-soft); color: var(--text); }
.btn-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.btn-success:hover { background: var(--success-soft); filter: brightness(.97); }
.btn-danger:hover { background: var(--danger-soft); filter: brightness(.97); }
.btn-warning:hover { background: var(--warning-soft); filter: brightness(.97); }
.btn:disabled, button:disabled { opacity: .45; }

/* ---------------------------------------------------------------- Forms */
input, select, textarea {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
input:focus, select:focus, textarea:focus { background-color: var(--bg); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
label { color: var(--text2); font-weight: 600; }
select option { background: var(--panel); color: var(--text); }
select { background-position: right 14px center; background-repeat: no-repeat; padding-right: 38px; }

/* ---------------------------------------------------------------- Badges, progress */
.badge { border-radius: 999px; padding: 4px 11px; font-weight: 600; border: 1px solid transparent; }
.badge-primary, .badge-accent, .badge-group, .book-chip { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.progress-bar { height: 4px; border-radius: 4px; background: var(--track); }
.progress-fill { border-radius: 4px; background: var(--primary); }
.card > .progress-bar { margin-top: 12px; }

/* ---------------------------------------------------------------- Questions */
.question-block { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.question-block::before { display: none; }
.question-text { color: var(--text); font-weight: 600; letter-spacing: -.005em; line-height: 1.6; }
@media (max-width: 600px) { .question-text { line-height: 1.6; } }
.option-btn {
    background: var(--raised);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    font-family: var(--font);
    font-weight: 500;
}
.option-btn:hover { background: var(--surface-hover); }
.option-label { width: 32px; height: 32px; border-radius: 10px; border: 0; background: var(--tile); color: var(--text2); font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.option-btn.selected { color: var(--text); background: var(--primary-soft); border: 1.5px solid var(--primary); }
.option-btn.correct { color: var(--text); background: var(--success-soft); border: 1.5px solid var(--success); }
.option-btn.wrong { color: var(--text); background: var(--danger-soft); border: 1.5px solid var(--danger); }
.option-btn.selected .option-label { background: var(--primary); color: var(--on-primary); }
.option-btn.correct .option-label { background: var(--success); color: #06180f; }
.option-btn.wrong .option-label { background: var(--danger); color: #2a0a0a; }
:root:not(.dark-mode) .option-btn.correct .option-label, :root:not(.dark-mode) .option-btn.wrong .option-label { color: #fff; }
.option-btn:disabled:hover { background: var(--raised); border-color: var(--border); }
.option-btn.correct:disabled:hover { background: var(--success-soft); border-color: var(--success); }
.option-btn.wrong:disabled:hover { background: var(--danger-soft); border-color: var(--danger); }
.option-btn.selected:disabled:hover:not(.correct):not(.wrong) { background: var(--primary-soft); border-color: var(--primary); }
.option-btn.correct .answer-status, .option-btn.correct span[style*="float:right"] { color: var(--success); }
.option-btn.wrong .answer-status, .option-btn.wrong span[style*="float:right"] { color: var(--danger); }
.explanation-box { background: var(--raised); border: 1px solid var(--border); border-left: 1px solid var(--border); border-radius: 18px; color: var(--text); }
.explanation-box > strong:first-child { font-weight: 700; color: var(--primary); }
.question-reference { background: var(--raised); border: 1px solid var(--border); border-radius: 14px; color: var(--text2); }
.question-image { background: var(--raised); border-color: var(--border); border-radius: 16px; }
.question-image-open { background: var(--raised); }

/* ---------------------------------------------------------------- Exam */
.timer-display {
    display: inline-block; font-size: 1rem; font-weight: 700; letter-spacing: 0; text-shadow: none; text-align: center;
    padding: 4px 12px; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); color: var(--text);
    font-variant-numeric: tabular-nums; animation: none;
}
.timer-display.timer-warning { color: var(--warning); border-color: var(--warning); animation: none; }
.timer-display.timer-danger { color: var(--danger); border-color: var(--danger); animation: none; }

.exam-qtimer { margin-top: 12px; padding: 10px 14px 12px; border-radius: 16px; background: var(--raised); border: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; }
.exam-qtimer-label { display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.exam-qtimer-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.exam-qtimer-track { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--track); overflow: hidden; }
.exam-qtimer-bar { height: 100%; border-radius: 6px; background: var(--primary); transition: width 1s linear; }
.exam-qtimer[data-state="warn"] { border-color: var(--warning); }
.exam-qtimer[data-state="warn"] .exam-qtimer-value { color: var(--warning); }
.exam-qtimer[data-state="warn"] .exam-qtimer-bar { background: var(--warning); }
.exam-qtimer[data-state="danger"] { border-color: var(--danger); }
.exam-qtimer[data-state="danger"] .exam-qtimer-value { color: var(--danger); }
.exam-qtimer[data-state="danger"] .exam-qtimer-bar { background: var(--danger); }

.exam-qtime { min-width: 0; margin: 16px 0 0; padding: 14px 14px 12px; border: 1px solid var(--border); border-radius: 18px; background: var(--raised); }
.exam-qtime legend { padding: 0 8px; font-size: .9rem; font-weight: 700; color: var(--text); }
.exam-qtime-optional { margin-inline-start: 6px; font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.exam-qtime-row { display: flex; align-items: flex-end; gap: 10px; }
.exam-qtime-field { flex: 1 1 0; min-width: 0; }
.exam-qtime-field label { display: block; margin-bottom: 4px; font-size: .78rem; color: var(--text-muted); }
.exam-qtime-field input { width: 100%; min-height: 52px; text-align: center; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.exam-qtime-field input::-webkit-outer-spin-button, .exam-qtime-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.exam-qtime-sep { padding-bottom: 12px; font-size: 1.5rem; font-weight: 700; color: var(--text-muted); }
.exam-qtime-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.exam-qtime-chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--panel); color: var(--text2); font: 600 .85rem/1 var(--font); cursor: pointer; }
.exam-qtime-chip:hover { background: var(--surface-hover); }
.exam-qtime-chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.exam-qtime-hint { margin: 10px 0 0; font-size: .8rem; line-height: 1.55; color: var(--text-muted); }
.exam-qtime[data-state="on"] { border-color: var(--primary); }
.exam-qtime[data-state="error"] { border-color: var(--danger); }
.exam-qtime[data-state="error"] .exam-qtime-hint { color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .exam-qtimer-bar { transition: none; } }

/* ---------------------------------------------------------------- Navigation: floating pill */
.bottom-nav {
    left: 50%; right: auto; width: min(560px, calc(100% - 28px)); transform: translateX(-50%);
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    height: 68px; padding: 6px; gap: 4px; box-sizing: border-box;
    background: var(--panel); backdrop-filter: none; -webkit-backdrop-filter: none;
    border: 1px solid var(--border); border-radius: 24px;
    box-shadow: var(--shadow-lg);
}
.nav-item { border-radius: 18px; color: var(--text-muted); font: 600 .7rem/1.2 var(--font); gap: 4px; padding: 0; }
.nav-item:hover { color: var(--text); background: var(--raised); }
.nav-item.active, .nav-item.active:hover { color: var(--primary); background: var(--primary-soft); }
.nav-item.active::after { display: none; }
@media (max-width: 374px) { .nav-item { font-size: .62rem; } .bottom-nav { width: calc(100% - 20px); } }
@media (min-width: 700px) { .bottom-nav { padding-inline: 6px; } }
@media (max-height: 500px) and (orientation: landscape) {
    :root { --nav-height: 70px; }
    .bottom-nav { height: 54px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}
.floating-reclassify-btn { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px); }

/* ---------------------------------------------------------------- Free trial / subscription card */
body #entSubBar {
    align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin: 4px 20px 6px; padding: 12px 14px 14px; border-radius: 18px;
    background: var(--raised); color: var(--text); border: 1px solid var(--border);
    font-size: .85rem; line-height: 1.4; box-sizing: border-box;
}
@media (min-width: 700px) { body #entSubBar { max-width: calc(var(--max-width) - 40px); margin-inline: auto; } }
#entSubBar .ent-sub-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 160px; }
#entSubBar .ent-sub-title { font-size: .9rem; font-weight: 700; color: var(--text); }
#entSubBar .ent-sub-text { font-size: .8rem; color: var(--text-muted); overflow-wrap: anywhere; }
#entSubBar .ent-sub-btn { min-height: 38px; border-radius: 12px; padding: 0 16px; }
#entSubBar .ent-sub-meter { flex: 1 1 100%; height: 4px; border-radius: 4px; background: var(--track); overflow: hidden; }
#entSubBar .ent-sub-meter > span { display: block; height: 100%; border-radius: 4px; background: var(--primary); }

/* ---------------------------------------------------------------- Dialogs, toasts, lists */
#modalOverlay { background: var(--overlay); }
#modalContent { background: var(--panel); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); }
#toastContainer > div { background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
dialog { background: var(--panel); color: var(--text); }
dialog::backdrop { background: var(--overlay); }
.subject-card, .book-card, .tree-node { background: var(--panel); border-color: var(--border); border-radius: 16px; }
.subject-card.selected, .book-card.selected { background: var(--primary-soft); border-color: var(--primary); }
hr { border-color: var(--border); }
::selection { background: var(--primary-soft); }
a { color: var(--primary); }
.card a[href^="mailto:"] { font-size: .85rem; white-space: nowrap; }

/* ---------------------------------------------------------------- Delete account dialog + Android app (Play) touches */
html { overscroll-behavior-y: contain; } /* a pull-down must not reload the app in the middle of an exam */

.ent-del-overlay {
    position: fixed; inset: 0; z-index: 100001;
    display: flex; align-items: center; justify-content: center;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
    background: var(--overlay);
}
.ent-del-box {
    width: 100%; max-width: 400px; max-height: 92vh; overflow: auto;
    padding: 20px; border-radius: var(--radius); background: var(--panel); color: var(--text);
    border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
}
.ent-del-box h3 { margin: 0 0 8px; font-size: 1.15rem; }
.ent-del-box p { margin: 0 0 10px; font-size: .88rem; line-height: 1.5; color: var(--text2); }
.ent-del-box ul { margin: 0 0 12px; padding-inline-start: 1.2rem; font-size: .86rem; line-height: 1.5; color: var(--text2); }
.ent-del-box li { margin: 3px 0; }
.ent-del-box .ent-del-warn { color: var(--danger); font-weight: 600; }
.ent-del-box label { display: block; margin: 12px 0 6px; font-size: .82rem; font-weight: 600; color: var(--text2); }
.ent-del-box input[type="password"] { width: 100%; }
.ent-del-box .ent-del-check { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 4px; font-weight: 500; cursor: pointer; }
.ent-del-box .ent-del-check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; }
.ent-del-msg { min-height: 1.3em; margin: 10px 0 0; font-size: .85rem; line-height: 1.4; color: var(--danger); }
.ent-del-msg.info { color: var(--text2); }
.ent-del-actions { display: flex; gap: 10px; margin-top: 14px; }
.ent-del-actions .btn { flex: 1; min-height: 46px; }
.ent-del-actions .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-delete-account { color: var(--danger); border-color: var(--danger); }
.about-links a { font-weight: 600; padding: 8px 0; }

/* ---------------------------------------------------------------- Mobile number dialog (contact-phone.js) */
.ent-phone-box input[type="tel"] { width: 100%; font-size: 1.05rem; letter-spacing: .02em; }
.ent-phone-box .ent-del-check span { font-size: .86rem; line-height: 1.45; }

/* ---------------------------------------------------------------- Feature tour (feature-tour.js) */
html.ent-tour-open { scroll-behavior: auto; }
.ent-tour { position: fixed; inset: 0; z-index: 100003; opacity: 0; transition: opacity .2s ease; }
.ent-tour.show { opacity: 1; }
.ent-tour-shade { position: absolute; inset: 0; background: transparent; cursor: default; touch-action: none; }
.ent-tour.ent-tour-center .ent-tour-shade { background: var(--tour-dim); }
.ent-tour-ring {
    position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none;
    border: 2px solid var(--primary-light); border-radius: 14px;
    box-shadow: 0 0 0 4px var(--tour-halo), 0 0 0 200vmax var(--tour-dim);
    transition: left .28s ease, top .28s ease, width .28s ease, height .28s ease, border-radius .28s ease, opacity .2s ease;
}
.ent-tour-card {
    position: fixed; left: 0; top: 0; box-sizing: border-box; max-height: calc(100vh - 24px); overflow: visible;
    padding: 16px 16px 14px; border-radius: 18px;
    background: var(--panel); color: var(--text); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    transition: left .28s ease, top .28s ease;
}
.ent-tour-arrow {
    position: absolute; width: 14px; height: 14px; margin-left: -7px; background: var(--panel);
    border: 1px solid var(--border-strong); transform: rotate(45deg);
}
.ent-tour-arrow.up { top: -8px; border-right: 0; border-bottom: 0; }
.ent-tour-arrow.down { bottom: -8px; border-left: 0; border-top: 0; }
.ent-tour-count { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); margin: 0 0 4px; }
.ent-tour-title { margin: 0 0 6px; font-size: 1.08rem; line-height: 1.3; color: var(--text); }
.ent-tour-text { margin: 0 0 12px; font-size: .9rem; line-height: 1.55; color: var(--text2); }
.ent-tour-dots { display: flex; gap: 5px; margin: 0 0 12px; flex-wrap: wrap; }
.ent-tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--track); transition: width .2s ease, background .2s ease; }
.ent-tour-dots span.on { width: 18px; border-radius: 4px; background: var(--primary); }
.ent-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ent-tour-buttons { display: flex; gap: 8px; margin-inline-start: auto; }
.ent-tour-buttons .btn { min-height: 42px; padding: 8px 16px; margin: 0; }
.ent-tour-skip {
    min-height: 42px; padding: 8px 4px; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: .88rem; font-weight: 600; color: var(--text-muted);
}
.ent-tour-skip:hover, .ent-tour-skip:focus-visible { color: var(--text); text-decoration: underline; }
.ent-tour-card button:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.ent-tour-nudge { animation: ent-tour-nudge .32s ease; }
@keyframes ent-tour-nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 65% { transform: translateX(4px); } }
.ent-tour-still, .ent-tour-still .ent-tour-ring, .ent-tour-still .ent-tour-card, .ent-tour-still .ent-tour-dots span { transition: none !important; }
:root { --tour-dim: rgba(8, 14, 30, .62); --tour-halo: rgba(59, 123, 232, .28); }
.dark-mode { --tour-dim: rgba(2, 5, 14, .72); --tour-halo: rgba(110, 160, 255, .30); }
.ent-tour-card [hidden] { display: none !important; }

/* ---------------------------------------------------------------- Activation code dialog (subscription.js) */
#entSubModal { background: var(--overlay) !important; z-index: 100001 !important; }
#entSubModal .ent-sub-box { background: var(--panel) !important; border: 1px solid var(--border-strong); border-radius: var(--radius) !important; padding: 20px !important; box-shadow: var(--shadow-lg) !important; }
#entSubModal h3 { font-size: 1.15rem !important; color: var(--text); }
#entSubModal p { color: var(--text2) !important; }
#entSubModal .ent-plan { background: var(--raised); border-color: var(--border) !important; min-height: 50px; }
#entSubModal .ent-plan:has(input:checked) { border-color: var(--primary) !important; box-shadow: 0 0 0 2px var(--primary-soft); }
#entSubModal .ent-plan b { color: var(--text); font-weight: 700; }
#entSubModal .ent-sub-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
#entSubModal .ent-sub-stack .btn { min-height: 46px; margin: 0; }
#entSubModal .ent-sub-note { font-size: .78rem !important; color: var(--text-muted) !important; margin: 10px 0 0 !important; }
#entSubModal .ent-sub-warn { color: var(--danger) !important; font-weight: 600; }
#entSubModal .ent-sub-msg { min-height: 1.3em; margin: 8px 0 0; font-size: .85rem; line-height: 1.4; color: var(--danger); }
#entSubModal .ent-sub-msg.info { color: var(--text2); }
#entSubModal .ent-code-input { width: 100%; font-size: 1.25rem; letter-spacing: .12em; text-align: center; text-transform: uppercase; font-weight: 700; }

/* ---------------------------------------------------------------- "Install the app" (install-prompt.js) */
/* Dashboard card: above the bottom menu, never over it. */
.ent-install {
    position: fixed; z-index: 900; box-sizing: border-box;
    left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(var(--nav-height, 72px) + env(safe-area-inset-bottom, 0px) + 12px);
    max-width: 480px; margin-inline: auto;
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 14px 8px; border-radius: 18px;
    background: var(--panel); color: var(--text); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    animation: ent-install-in .34s cubic-bezier(.2, .8, .2, 1);
}
.ent-install.no-anim { animation: none; }
.ent-install[hidden] { display: none !important; }
.ent-install-icon { flex: none; display: block; width: 48px; height: 48px; border-radius: 12px; }
.ent-install-body { flex: 1 1 auto; min-width: 0; }
.ent-install-title { margin: 1px 0 3px; font-size: 1rem; font-weight: 700; line-height: 1.3; color: var(--text); }
.ent-install-text { margin: 0 0 6px; font-size: .86rem; line-height: 1.45; color: var(--text2); }
.ent-install-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.ent-install-go {
    min-height: 44px; padding: 8px 18px; border: 0; border-radius: 12px; cursor: pointer;
    background: var(--primary); color: var(--on-primary); font: inherit; font-size: .92rem; font-weight: 700;
}
.ent-install-go:hover { background: var(--primary-light); }
:root:not(.dark-mode) .ent-install-go:hover { background: var(--primary-dark, var(--primary)); }
.ent-install-later {
    min-height: 44px; padding: 8px 12px; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: .88rem; font-weight: 600; color: var(--text-muted);
}
.ent-install-later:hover, .ent-install-later:focus-visible { color: var(--text); text-decoration: underline; }
.ent-install button:focus-visible, .ent-auth-install button:focus-visible, .ent-install-sheet button:focus-visible {
    outline: 2px solid var(--primary-light); outline-offset: 2px;
}
.ent-install.is-done { align-items: center; padding: 14px 16px; }
.ent-install-done-icon {
    flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    background: var(--success); color: var(--panel);
}
.ent-install-done-text { font-size: .92rem; line-height: 1.45; color: var(--text); }
.ent-install-done-text b { font-weight: 700; }
@media (min-width: 900px) {
    .ent-install { left: auto; right: max(24px, calc((100% - 1040px) / 2)); width: 400px; margin: 0; }
}
@keyframes ent-install-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

html.ent-install-shown body {
    padding-bottom: calc(var(--nav-height, 72px) + env(safe-area-inset-bottom, 0px) + 36px + var(--ent-install-h, 140px));
}

/* Login screen: a quiet row under the form. */
.ent-auth-install { margin: 22px 0 0; text-align: left; }
.ent-auth-install[hidden] { display: none !important; }
.ent-auth-install-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px;
    border: 1px solid var(--border-strong); border-radius: 16px; background: var(--panel);
}
.ent-auth-install-icon {
    flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
}
.ent-auth-install-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ent-auth-install-text b { font-size: .92rem; line-height: 1.3; color: var(--text); }
.ent-auth-install-text small { font-size: .78rem; line-height: 1.4; color: var(--text-muted); }
.ent-auth-install-go {
    flex: none; min-height: 44px; padding: 8px 14px; border-radius: 12px; cursor: pointer; white-space: nowrap;
    border: 1px solid var(--primary); background: transparent; color: var(--primary);
    font: inherit; font-size: .86rem; font-weight: 700;
}
.ent-auth-install-go:hover { background: var(--primary-soft); }
.ent-auth-install-row.is-done { padding: 12px 14px; }

/* Steps sheet: bottom sheet on phones, centred dialog on wide screens. */
.ent-install-sheet {
    position: fixed; inset: 0; z-index: 100003; box-sizing: border-box;
    display: flex; align-items: flex-end; justify-content: center;
    padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    background: var(--overlay, rgba(5, 20, 36, .55)); overscroll-behavior: contain;
    animation: ent-install-fade .2s ease;
}
.ent-install-sheet-box {
    box-sizing: border-box; width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto;
    padding: 20px 18px 16px; border-radius: 22px; text-align: left;
    background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    animation: ent-install-in .3s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 640px) { .ent-install-sheet { align-items: center; } }
.ent-install-sheet-head { display: flex; gap: 14px; align-items: center; margin: 0 0 16px; }
.ent-install-sheet-head img { flex: none; width: 52px; height: 52px; border-radius: 14px; }
.ent-install-sheet h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; color: var(--text); }
.ent-install-sheet-head p { margin: 3px 0 0; font-size: .86rem; line-height: 1.45; color: var(--text2); }
.ent-install-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: ent-install-step; }
.ent-install-steps li {
    display: flex; gap: 14px; align-items: center; padding: 12px 14px 12px 12px; border-radius: 16px;
    background: var(--raised); border: 1px solid var(--border); counter-increment: ent-install-step;
}
.ent-install-step-icon {
    flex: none; position: relative; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
}
.ent-install-step-icon::after {
    content: counter(ent-install-step); position: absolute; top: -6px; left: -6px;
    width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary); font-size: .72rem; font-weight: 700; line-height: 1;
    box-shadow: 0 0 0 2px var(--raised);
}
.ent-install-step-text { font-size: .92rem; line-height: 1.5; color: var(--text); }
.ent-install-step-text b { font-weight: 700; }
.ent-install-note {
    margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; border-inline-start: 3px solid var(--primary);
    background: var(--primary-soft); font-size: .84rem; line-height: 1.5; color: var(--text2);
}
.ent-install-sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin: 16px 0 0; }
.ent-install-sheet-actions .btn { margin: 0; min-height: 44px; padding: 8px 20px; width: auto; }
@keyframes ent-install-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .ent-install, .ent-install-sheet, .ent-install-sheet-box { animation: none; }
}
