/* ═══════════════════════════════════════════════════════════════════════════
   Brainstorm — Design System
   Accent: Teal  |  Dark-first  |  Remix Icons
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ───────────────────────────────────────────────────────────────── */
:root {
    --accent:        #0d9488;
    --accent-hover:  #0f766e;
    --accent-subtle: rgba(13, 148, 136, 0.12);
    --danger:        #ef4444;
    --danger-hover:  #dc2626;
    --danger-subtle: rgba(239, 68, 68, 0.12);
    --warning:       #f59e0b;

    --bg:            #f6f8fa;
    --surface:       #ffffff;
    --card:          #ffffff;
    --border:        #d0d7de;
    --border-subtle: #eaeef2;
    --text:          #1c2128;
    --text-muted:    #57606a;
    --text-on-accent:#ffffff;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --transition: 150ms ease;
    --transition-slow: 250ms ease;

    --navbar-height: 56px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent:        #2dd4bf;
        --accent-hover:  #5eead4;
        --accent-subtle: rgba(45, 212, 191, 0.12);
        --danger:        #f87171;
        --danger-hover:  #fca5a5;
        --danger-subtle: rgba(248, 113, 113, 0.12);

        --bg:            #0d1117;
        --surface:       #161b22;
        --card:          #1c2128;
        --border:        #30363d;
        --border-subtle: #21262d;
        --text:          #e6edf3;
        --text-muted:    #8b949e;
        --text-on-accent:#0d1117;

        --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
        --shadow-md: 0 4px 12px rgba(0,0,0,.4);
        --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    }
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Page layout ──────────────────────────────────────────────────────────── */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
    animation: page-fade-in 200ms ease both;
}

@keyframes page-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: var(--navbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.top-bar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.top-bar-brand::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}
.top-bar-brand:hover { text-decoration: none; color: var(--accent); }

/* ── Nav user area ────────────────────────────────────────────────────────── */
.nav-user-area { position: relative; }

.nav-avatar-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.3rem 0.75rem 0.3rem 0.3rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition);
}
.nav-avatar-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text-on-accent);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-email-label {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-caret {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: transform var(--transition);
}

.nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 400;
    overflow: hidden;
    animation: dropdown-in 150ms ease both;
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.nav-dropdown-header {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    color: var(--text);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 400;
    text-decoration: none;
    transition: background var(--transition);
}
.nav-dropdown-item:hover { background: var(--accent-subtle); color: var(--accent); text-decoration: none; }
.nav-dropdown-item i { font-size: 1rem; }

.nav-dropdown-logout { color: var(--danger); }
.nav-dropdown-logout:hover { background: var(--danger-subtle); color: var(--danger-hover); }

.nav-dropdown form { margin: 0; padding: 0; border: none; }
.nav-dropdown form .nav-dropdown-item { width: 100%; text-align: left; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--accent);
    color: var(--text-on-accent);
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-md); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}
.btn-secondary:hover:not(:disabled) { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-subtle); border-color: var(--danger); }

.btn-small { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.btn-icon {
    padding: 0.35rem;
    width: 32px;
    height: 32px;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.2rem; }

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}
.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}
.search-input {
    padding-left: 2.25rem !important;
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.page-header a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: color var(--transition);
}
.page-header a:hover { color: var(--text); text-decoration: none; }

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Ensure <a> styled as btn-secondary matches button sizing */
a.btn-secondary, a.btn-primary {
    text-decoration: none;
    line-height: 1.4;
}

/* ── Home header ──────────────────────────────────────────────────────────── */
.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
}
.home-header h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.4px; }

/* ── Section titles ───────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.5px; margin: 0 0 1.5rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 0 0 1rem; }

/* ── Cards (shared base) ──────────────────────────────────────────────────── */
.project-card, .note-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-slow), box-shadow var(--transition-slow), border-color var(--transition-slow);
}
.project-card:hover, .note-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

/* ── Project gallery ──────────────────────────────────────────────────────── */
.project-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.project-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
}

.project-card-body {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    display: block;
}
.project-card-body:hover { text-decoration: none; color: inherit; }
.project-card-body h3 {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.project-card-body p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-footer {
    display: flex;
    flex-shrink: 0;
    gap: 0.25rem;
    align-items: flex-start;
}
.project-card-footer form { margin: 0; padding: 0; border: none; }

/* ── Notes headline ───────────────────────────────────────────────────────── */
.notes-headline {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}
.notes-headline h1 { margin: 0; }
.notes-project-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Note gallery ─────────────────────────────────────────────────────────── */
.note-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}
@media (max-width: 1200px) { .note-gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px)  { .note-gallery { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .note-gallery { grid-template-columns: 1fr; } }

.note-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0.9rem 1rem;
}

.note-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.note-card-body h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.note-card-actions {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    flex-shrink: 0;
    justify-content: flex-end;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-subtle);
}
.note-card-actions form { margin: 0; padding: 0; border: none; }
.note-card-actions .btn-icon { width: 38px; height: 38px; font-size: 1.1rem; }

/* ── Priority badges ──────────────────────────────────────────────────────── */
.priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    align-self: flex-start;
    background: var(--accent-subtle);
    color: var(--accent);
}

.priority-high   { background: var(--danger-subtle)  !important; color: var(--danger)  !important; }
.priority-medium { background: rgba(245,158,11,.12)   !important; color: var(--warning) !important; }
.priority-low    { background: var(--accent-subtle)   !important; color: var(--accent)  !important; }

/* ── Tag chips ────────────────────────────────────────────────────────────── */
.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: var(--radius-pill);
    padding: 0.15rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 500;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 0.7;
    margin-left: 0.1rem;
}
.tag-remove:hover { opacity: 1; transform: none; }

.tags-section {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.4rem;
}
.tags-label {
    font-size: 0.875rem;
    font-weight: 500;
    width: 100%;
    margin-bottom: 0.25rem;
    color: var(--text);
}
.tag-add-row { display: flex; gap: 0.5rem; width: 100%; margin-top: 0.25rem; }
.tag-add-row input { flex: 1; }
.tags-section form { margin: 0; padding: 0; border: none; display: contents; }

/* ── Dialogs / modals ─────────────────────────────────────────────────────── */
.dialog-backdrop, .modal-overlay {
    position: fixed;
    top: var(--navbar-height);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 500;
    animation: backdrop-in 200ms ease both;
    backdrop-filter: blur(2px);
    padding: 1rem;
    overflow-y: auto;
}

@keyframes backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dialog, .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - var(--navbar-height) - 2rem);
    overflow-y: auto;
    animation: modal-in 220ms cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
.dialog-sm { max-width: 380px; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-header, .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.dialog-header h2, .modal-header h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dialog-close, .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background var(--transition), color var(--transition);
    line-height: 1;
}
.dialog-close:hover, .modal-close:hover { background: var(--danger-subtle); color: var(--danger); transform: none; }

.dialog-body, .modal-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dialog-actions, .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Status-priority row ──────────────────────────────────────────────────── */
.status-priority-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Editor toolbar ───────────────────────────────────────────────────────── */
.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.editor-toolbar a.btn-small { text-decoration: none; }

/* ── Markdown preview ─────────────────────────────────────────────────────── */
.markdown-preview {
    min-height: 200px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    line-height: 1.75;
    overflow-y: auto;
    font-size: 0.9rem;
}
.markdown-preview h1,.markdown-preview h2,.markdown-preview h3 { margin-top: 1.25rem; }
.markdown-preview code { background: var(--accent-subtle); color: var(--accent); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.85em; }
.markdown-preview pre { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; }
.markdown-preview pre code { background: none; color: inherit; padding: 0; }

/* ── AI section ───────────────────────────────────────────────────────────── */
.ai-section {
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.ai-toggle { align-self: flex-start; }

.advanced-section {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}
.advanced-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0;
    transition: color 150ms ease;
}
.advanced-toggle:hover { color: var(--text); }
.advanced-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.ai-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.ai-control select { width: 100%; }
.ai-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.ai-row select { flex: 1; min-width: 120px; }

.ai-result {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--accent-subtle);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    line-height: 1.6;
    width: 100%;
}
.ai-result strong { display: block; margin-bottom: 0.35rem; color: var(--accent); }

.history-select {
    width: 100%;
    flex-basis: 100%;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-color: var(--border);
    background: var(--bg);
}

.loading-inline {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
}
.loading-inline::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth / login page ────────────────────────────────────────────────────── */
.login-page {
    /* Cancel out the padding that <main> adds so we fill the viewport exactly */
    margin: -2rem -2rem -4rem;
    min-height: calc(100vh - var(--navbar-height));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    background: var(--bg);
    padding: 2rem;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
}
.login-title::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    animation: modal-in 300ms cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
.auth-card h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.auth-card form { margin-bottom: 0; }
.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 0.25rem; }
.auth-card p.auth-subtitle {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
    font-size: 0.875rem;
}

.auth-error {
    color: var(--danger);
    font-size: 0.875rem;
    padding: 0.6rem 0.8rem;
    background: var(--danger-subtle);
    border-radius: var(--radius-sm);
    margin: 0;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ── Onboarding / setup ───────────────────────────────────────────────────── */
.onboarding {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    max-width: 480px;
    margin: 0 auto;
}

/* ── Settings page ────────────────────────────────────────────────────────── */
.admin-page { max-width: 720px; }
.admin-page section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.admin-page section h2 { margin-top: 0; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.75rem; }

.profile-form { margin-bottom: 0; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

.api-keys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.api-keys-grid form { margin-bottom: 0; gap: 0.5rem; }

.success-msg {
    color: var(--accent);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.success-msg::before { content: '\u2713'; font-weight: 700; }

/* ── Templates ────────────────────────────────────────────────────────────── */
.template-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.template-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}
.template-row:hover { border-color: var(--accent); }
.template-row-name { flex: 1; font-size: 0.9rem; font-weight: 500; }
.template-edit-form { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.5rem 0 0; padding: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.template-edit-form input, .template-edit-form textarea { padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: inherit; width: 100%; font-size: 0.875rem; font-family: inherit; }

/* ── Trash ────────────────────────────────────────────────────────────────── */
.section-hint { font-size: 0.8rem; color: var(--text-muted); margin: -0.5rem 0 1rem; }
.trash-list { display: flex; flex-direction: column; gap: 0.5rem; }
.trash-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.trash-item-info { flex: 1; min-width: 0; }
.trash-item-title { display: block; font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-item-expires { font-size: 0.75rem; color: var(--text-muted); }
.trash-item-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ── Focus textarea ───────────────────────────────────────────────────────── */
.focus-textarea { font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.875rem; line-height: 1.7; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
    font-size: 0.9rem;
    grid-column: 1 / -1;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading {
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.dialog label { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0; }
.dialog-close { font-weight: normal; }
.dialog-actions { gap: 0.75rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    main { padding: 1rem 1rem 3rem; }
    .modal { max-height: 100dvh; border-radius: 0; max-width: 100%; }
    .status-priority-row { grid-template-columns: 1fr; }
    .api-keys-grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .home-header h1 { font-size: 1.25rem; }
    .nav-email-label { display: none; }
}

/* ── Save OK feedback ─────────────────────────────────────────────────────── */
.save-ok {
    color: #22c55e;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ── Guest Access section ─────────────────────────────────────────────────── */
.guest-project-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.guest-project-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.guest-project-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.guest-invite-form {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.guest-invite-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.guest-invite-row label {
    flex: 1;
    margin-bottom: 0;
}

.guest-link-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
}

.guest-link-input {
    flex: 1;
    min-width: 0;
    font-family: monospace;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    outline: none;
    cursor: text;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.guest-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.guest-empty {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.guest-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    background: var(--bg);
    font-size: 0.875rem;
}

.guest-row.pending {
    opacity: 0.85;
}

.guest-row-icon {
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
}

.guest-row-name {
    font-weight: 500;
    flex: 0 0 auto;
    min-width: 80px;
}

.guest-row-badge {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.guest-row-badge.active { color: #22c55e; }
    color: var(--warning);
}

.guest-row-badge.pending {
    color: var(--warning, #d97706);
}

.guest-row-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-left: auto;
}

/* ── Invite page ──────────────────────────────────────────────────────────── */
.invite-warning {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    background: color-mix(in srgb, #d97706 12%, transparent);
    border: 1px solid color-mix(in srgb, #d97706 40%, transparent);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text);
    margin: 0.5rem 0;
}

.invite-warning i {
    color: #d97706;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.invite-warning p {
    margin: 0;
}

.invite-expires {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

.invite-status-card {
    text-align: center;
    gap: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.invite-status-icon {
    font-size: 2.5rem;
}

.invite-status-icon.warn  { color: #d97706; }
.invite-status-icon.danger { color: var(--danger); }

/* ── Toast notification ───────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(0.5rem);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 9999;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    opacity: 0;
    white-space: nowrap;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

