/* Base styles and the standalone pages (sign-in, profile, errors); the app
   shell adds app.css. */

/* Inter (SIL OFL 1.1, fonts/inter/OFL.txt), self-hosted (SPEC §4.2). */
@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(../fonts/inter/inter-latin-wght-normal.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(../fonts/inter/inter-latin-ext-wght-normal.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; }

/* Lucide sprite icons: <svg class="icon"><use href="/assets/icons/lucide.svg#i-NAME"></use></svg> */
.icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text);
    background: var(--editor-bg);
}

a { color: var(--accent-text); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--sidebar-bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 32px 28px;
    background: var(--list-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
    overflow-wrap: anywhere;
}

.auth-wordmark {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-text);
}

.auth-card h1 { margin: 0 0 20px; font-size: 18px; font-weight: 600; }

/* The AI connector's consent page (§22): a little wider, with what the app may and may not do. */
.oauth-card { max-width: 460px; }

.oauth-points { margin: 0 0 20px; padding-left: 20px; }

.oauth-points li { margin: 0 0 8px; line-height: 1.45; }

.auth-action { margin: 20px 0 0; }

.auth-form { display: flex; flex-direction: column; gap: 6px; }

.auth-form label { font-weight: 500; }

.auth-form input,
.auth-form select {
    width: 100%;
    margin-bottom: 10px;
    padding: 9px 11px;
    font: inherit;
    color: var(--text);
    background: var(--editor-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.auth-form select:focus,
.auth-form input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgba(224, 58, 62, .25); }

.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn-primary, .btn-secondary {
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    border-radius: var(--radius-pill);
    cursor: pointer;
}

.btn-primary { color: #ffffff; background: var(--accent-fill); border: 1px solid var(--accent-fill); }

a.btn-primary, a.btn-secondary { display: inline-block; text-decoration: none; }

.btn-primary:hover { filter: brightness(.94); }

.btn-secondary { color: var(--text); background: transparent; border: 1px solid var(--border); }

.btn-secondary:hover { background: var(--list-selected); }

.btn-secondary:disabled { opacity: .45; cursor: default; background: transparent; }

.auth-form .btn-primary { margin-top: 6px; }

.auth-error {
    margin: 0 0 16px;
    padding: 10px 12px;
    color: var(--text);
    background: rgba(224, 58, 62, .12);
    border: 1px solid rgba(224, 58, 62, .45);
    border-radius: var(--radius);
}

.auth-error p { margin: 0; }

.auth-error p + p { margin-top: 6px; }

.auth-notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    color: var(--text);
    background: var(--list-selected);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* A destructive action (account deletion, admin Delete). */
.btn-danger {
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent-fill);
    border: 1px solid var(--accent-fill);
    border-radius: var(--radius-pill);
    cursor: pointer;
}

.btn-danger.btn-small { padding: 6px 12px; font-size: 13px; }

/* Profile → AI assistant (§22): the connected apps heading and the address to paste into the app. */
.profile-subheading { margin: 20px 0 8px; font-size: 15px; font-weight: 600; }

.profile-code {
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--text);
    overflow-wrap: anywhere;
    background: var(--list-selected);
    border-radius: 4px;
}

.btn-danger:hover { filter: brightness(1.08); }

.btn-danger:disabled { opacity: .45; cursor: default; filter: none; }

.auth-hint { margin: -2px 0 10px; color: var(--text-muted); font-size: 13px; }

.auth-secondary { margin-top: 16px; text-align: center; }

.btn-link {
    padding: 4px;
    font: inherit;
    color: var(--text-muted);
    background: none;
    border: 0;
    text-decoration: underline;
    cursor: pointer;
}

.btn-link:hover { color: var(--text); }

.auth-form .code-input { font-size: 20px; letter-spacing: .3em; text-align: center; }

/* The QR code keeps a white quiet zone in dark mode so phones can read it. */
.totp-qr {
    display: block;
    width: 220px;
    max-width: 100%;
    height: auto;
    margin: 4px auto 12px;
    padding: 8px;
    background: #ffffff;
    border-radius: var(--radius);
}

.totp-manual { color: var(--text-muted); text-align: center; }

.totp-secret {
    display: inline-block;
    margin-top: 4px;
    font-size: 15px;
    color: var(--text);
    letter-spacing: .05em;
    word-spacing: .3em;
    user-select: all;
}

.auth-form .auth-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 2px 0 8px;
    font-weight: 400;
    cursor: pointer;
}

.auth-form .auth-check input {
    width: auto;
    margin: 3px 0 0;
    accent-color: var(--accent);
}

/* Idle-timeout warning (SPEC §6.5) */
.idle-dialog {
    width: min(400px, calc(100vw - 32px));
    padding: 24px;
    color: var(--text);
    background: var(--list-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

.idle-dialog::backdrop { background: rgba(0, 0, 0, .5); }

.idle-dialog h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }

.idle-dialog p { margin: 0; }

.idle-dialog form { margin: 0; }

/* Confirmations in the app shell (delete notebook, P3.6) */
.confirm-dialog .auth-actions { justify-content: flex-end; margin-top: 20px; }

.confirm-error { margin-top: 12px; font-size: 13px; color: var(--accent-text); }

.confirm-error[hidden] { display: none; }

.move-choices { margin: 0; padding: 0; border: 0; }

#move-options { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }

.move-choice, .orphan-list label { display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer; }

.move-choice input, .orphan-list input { accent-color: var(--accent); }

.move-choice:has(input:disabled) { opacity: .5; cursor: default; }

.orphan-list { margin: 12px 0 0; padding: 0; list-style: none; }

.orphan-list[hidden] { display: none; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Profile page (P2.11); moves into the app shell's settings in Phase 3. */
.profile-page { background: var(--sidebar-bg); }

.profile {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    overflow-wrap: anywhere;
}

.profile-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.profile-header a { color: #ffffff; }

.profile > h1 { margin: 8px 0 16px; font-size: 22px; font-weight: 600; color: #ffffff; }

.profile-section {
    margin-bottom: 16px;
    padding: 24px;
    background: var(--list-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.profile-section h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }

.profile-section > p { margin: 0 0 12px; }

.profile-section .auth-form { margin-top: 4px; }

/* A checkbox with its label on one line (email notifications, §11.2). */
.auth-form .profile-check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; cursor: pointer; }

.auth-form .profile-check input { width: auto; margin: 3px 0 0; padding: 0; accent-color: var(--accent); box-shadow: none; }

.profile-avatar-row { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }

.profile-avatar-forms { flex: 1; min-width: 0; }

.profile-avatar-forms form { margin: 0; }

.profile-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }

.profile-inline input[type="file"] { flex: 1 1 200px; min-width: 0; font: inherit; color: var(--text); }

.avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #ffffff;
    font-weight: 600;
    background: var(--accent-fill);
    border-radius: 50%;
    object-fit: cover;
}

.avatar-lg { width: 72px; height: 72px; font-size: 26px; }

.profile-list { margin: 0 0 12px; padding: 0; list-style: none; }

.profile-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.profile-list li:last-child { border-bottom: 1px solid var(--border); }

.profile-list form { flex: none; margin: 0; }

.profile-list .auth-hint { margin: 2px 0 0; }

.profile-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    background: var(--list-selected);
    border-radius: var(--radius-pill);
}

.btn-small { padding: 6px 12px; font-size: 13px; }

.profile-signout { text-align: center; }

/* Admin → Fonts (P4.4): a sample line in each font, and its buttons in a row. */
.font-sample { margin: 4px 0 0; font-size: 18px; }

.font-actions { display: flex; flex: none; flex-wrap: wrap; gap: 6px; }

.profile-signout .btn-link { color: #ffffff; }

@media (max-width: 480px) {
    .profile-section { padding: 18px 16px; }
    .profile-list li { flex-direction: column; align-items: flex-start; }
}

/* Profile → Export my notes: the recent exports under the form (§13.2). */
.profile-subhead { margin: 18px 0 6px; font-size: 14px; font-weight: 600; }

/* Restoring a backup (SPEC §13.5): the warning before everything is replaced. */
.restore-panel { margin-top: 20px; }
.restore-step { margin: 0 0 12px; }
.restore-step progress { width: 100%; max-width: 420px; accent-color: var(--accent); }
.restore-warning {
    margin: 0 0 16px;
    padding: 12px 14px;
    color: var(--text);
    background: rgba(224, 58, 62, .16);
    border: 2px solid rgba(224, 58, 62, .8);
    border-radius: var(--radius);
}
.restore-warning p { margin: 0; }
.restore-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.restore-retry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.restore-retry .auth-hint { margin: 0; }

/* Terms of Service and Privacy Policy pages (§14.10). */
.legal-page .profile { max-width: 820px; }

.legal-document { overflow-wrap: anywhere; }

.legal-document p { margin: 0 0 .75em; }

.legal-document li > p { margin: 0 0 .35em; }

.legal-scroll { max-height: 50vh; overflow-y: auto; margin: 12px 0; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--editor-bg); }

.legal-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.legal-changed { margin: 8px 0; padding: 8px 12px; border-left: 4px solid var(--accent); background: var(--list-selected); border-radius: var(--radius); }

.legal-changed p { margin: 0; }

.legal-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }

.legal-check input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent-fill); }

.legal-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 16px 0; }

.legal-actions form { margin: 0; }

.legal-versions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.legal-other { margin: 16px 0; }

/* Text straight on the dark page background, outside the white sections. */
.legal-page .profile > p:not(.auth-error):not(.auth-notice), .legal-page .profile > nav { color: var(--sidebar-muted); }

.legal-page .profile > p a, .legal-page .profile > nav a { color: var(--sidebar-text); }

.legal-page .profile > .legal-actions .btn-secondary, .legal-page .profile > form.legal-actions .btn-secondary { color: var(--sidebar-text); border-color: var(--sidebar-muted); }

.legal-page .profile > .legal-actions .btn-secondary:hover, .legal-page .profile > form.legal-actions .btn-secondary:hover { background: var(--sidebar-hover); }

.auth-legal { margin: 20px 0 0; font-size: 13px; text-align: center; color: var(--text-muted); }

.auth-legal a { color: var(--text-muted); }

/* Maintenance mode is on (§23 #128): a reminder on every signed-in page, out of the way of the layout. */
.maintenance-banner { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 1000; max-width: calc(100vw - 32px); margin: 0; padding: 8px 14px; border-radius: var(--radius); background: var(--accent-fill); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 2px 10px rgb(0 0 0 / 25%); text-align: center; }

.maintenance-banner a { color: #fff; text-decoration: underline; }

/* On a phone, above the bottom bar and beside the new-note button rather than over them. */
@media (max-width: 767px) {
    .maintenance-banner { left: 16px; right: 88px; bottom: 76px; transform: none; max-width: none; }
}
