:root {
    color-scheme: light;
    --bg: #eef3f7;
    --surface: #ffffff;
    --surface-soft: #f8fbfc;
    --text: #17212b;
    --muted: #607080;
    --line: #d6e0e8;
    --primary: #116466;
    --primary-dark: #0b4d4e;
    --accent: #315ac7;
    --gold: #c98214;
    --danger: #b42318;
    --ok-bg: #ddf4e7;
    --ok-text: #14532d;
    --err-bg: #fee4e2;
    --err-text: #7a271a;
    --radius: 8px;
    --shadow: 0 12px 34px rgba(23, 33, 43, 0.08);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111827;
    --surface: #182231;
    --surface-soft: #202d3f;
    --text: #edf3f8;
    --muted: #a9b7c6;
    --line: #344256;
    --primary: #42b8aa;
    --primary-dark: #329789;
    --accent: #83a2ff;
    --gold: #f3b64b;
    --danger: #ff8b7f;
    --ok-bg: #143627;
    --ok-text: #b9f3ce;
    --err-bg: #431d1a;
    --err-text: #ffd0cb;
    --shadow: 0 16px 38px rgba(0, 0, 0, 0.26);
}

* {
    box-sizing: border-box;
}

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(17, 100, 102, 0.18), transparent 32rem),
        linear-gradient(180deg, #f7fafc 0%, var(--bg) 100%);
    color: var(--text);
}

:root[data-theme="dark"] html,
html[data-theme="dark"] {
    background:
        radial-gradient(circle at top left, rgba(66, 184, 170, 0.14), transparent 32rem),
        linear-gradient(180deg, #0d1420 0%, var(--bg) 100%);
}

body {
    margin: 0;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

:root[data-theme="dark"] .topbar {
    background: rgba(24, 34, 49, 0.9);
}

.brand {
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0;
}

.brand span {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-right: 7px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.92rem;
}

.theme-toggle {
    min-height: 30px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 750;
    cursor: pointer;
}

.page {
    width: min(100%, 860px);
    margin: 0 auto;
    padding: 18px 14px 40px;
}

.auth-panel,
.week-hero,
.dashboard-hero,
.metric-card,
.quick-panel,
.empty-state,
.note-card,
.note-form,
.sync-panel,
.share-panel,
.shared-note,
.ai-panel,
.profile-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-panel {
    margin-top: 44px;
    padding: 24px;
}

.auth-panel.compact {
    margin-top: 14px;
}

.auth-panel h1,
.week-hero h1,
.section-head h1 {
    margin: 0;
    line-height: 1.08;
}

.auth-panel p {
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-size: 0.94rem;
    font-weight: 650;
}

:root[data-theme="dark"] label {
    color: #d5dee8;
}

input,
button {
    font: inherit;
}

input[type="email"],
input[type="text"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="file"],
select,
input:not([type]) {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
}

:root[data-theme="dark"] input[type="email"],
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="search"],
:root[data-theme="dark"] input[type="url"],
:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] input[type="file"],
:root[data-theme="dark"] select,
:root[data-theme="dark"] input:not([type]) {
    background: #111827;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 42px;
    background-image:
        linear-gradient(45deg, transparent 50%, #607080 50%),
        linear-gradient(135deg, #607080 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 19px,
        calc(100% - 13px) 19px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    line-height: 1.3;
}

select option {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1rem;
    color: var(--text);
}

input:focus,
select:focus,
.editor:focus {
    outline: 3px solid rgba(36, 87, 197, 0.18);
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 750;
    cursor: pointer;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 8px 18px rgba(17, 100, 102, 0.18);
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: var(--surface-soft);
    color: var(--text);
    border-color: var(--line);
}

.btn.danger {
    background: #fff;
    color: var(--danger);
    border-color: #f0b8b2;
}

:root[data-theme="dark"] .btn.danger {
    background: var(--surface-soft);
}

.flash {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 650;
}

.flash.success {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.flash.error {
    background: var(--err-bg);
    color: var(--err-text);
}

.profile-reminder {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid rgba(201, 130, 20, 0.38);
    border-radius: var(--radius);
    background: rgba(201, 130, 20, 0.12);
}

.profile-reminder p {
    margin: 4px 0 0;
    color: var(--muted);
}

.week-hero {
    position: relative;
    overflow: hidden;
    padding: 22px;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(17, 100, 102, 0.96), rgba(49, 90, 199, 0.92)),
        linear-gradient(90deg, #116466, #315ac7);
}

.week-hero::after {
    content: "";
    position: absolute;
    right: -36px;
    bottom: -52px;
    width: 170px;
    height: 170px;
    border: 24px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
}

.week-hero > * {
    position: relative;
    z-index: 1;
}

.week-hero .eyebrow,
.week-hero .subtle {
    color: rgba(255, 255, 255, 0.78);
}

.week-hero .btn.secondary {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.32);
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(232, 245, 242, 0.96));
}

.dashboard-hero h1 {
    margin: 0;
}

.dashboard-hero p:not(.eyebrow) {
    margin: 8px 0 0;
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 14px 0;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.metric-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    color: var(--text);
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 850;
    line-height: 1.1;
}

.metric-label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 750;
}

.quick-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px;
}

.quick-action {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 750;
    text-align: center;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.subtle {
    color: var(--muted);
    font-size: 0.9rem;
}

.hero-actions,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 22px 0 12px;
}

.section-head h2,
.section-head h1 {
    margin: 0;
}

.empty-state {
    padding: 22px;
    text-align: center;
    color: var(--muted);
}

.note-list {
    display: grid;
    gap: 12px;
}

.note-card {
    padding: 16px;
    position: relative;
    overflow: hidden;
    border-left: 0;
}

.note-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--type-color, var(--primary));
}

.type-scripture { --type-color: #116466; --type-bg: #e8f5f2; }
.type-talk { --type-color: #315ac7; --type-bg: #eef4ff; }
.type-watchtower { --type-color: #8a4f12; --type-bg: #fff4e2; }
.type-meeting { --type-color: #7c3aed; --type-bg: #f4efff; }
.type-personal { --type-color: #047857; --type-bg: #e9f7ef; }
.type-other { --type-color: #475467; --type-bg: #f2f4f7; }

.note-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 10px;
}

.note-card h2 {
    margin: 0;
    font-size: 1.05rem;
}

.note-type {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 5px;
    color: var(--type-color, var(--primary));
    font-size: 0.75rem;
    font-weight: 850;
    text-transform: uppercase;
}

.note-type span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--type-bg, #eef4ff);
    color: var(--type-color, var(--primary));
    font-size: 0.8rem;
}

.note-title {
    display: inline-flex;
    margin: 6px 0 2px;
    padding: 5px 9px;
    border-radius: 7px;
    background: var(--type-bg, #eef4ff);
    color: var(--type-color, var(--primary));
    font-size: 0.96rem;
    font-weight: 850;
}

.favorite {
    color: var(--gold);
    font-size: 1.2rem;
}

.scripture {
    margin: 13px 0;
    padding: 12px 14px;
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: #eef4ff;
    color: #23335d;
    font-style: italic;
    line-height: 1.5;
}

.note-body {
    margin-top: 12px;
    line-height: 1.58;
}

.note-body p,
.note-body div {
    margin: 0 0 10px;
}

.note-body ul,
.note-body ol {
    padding-left: 22px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr minmax(170px, 220px) auto;
    gap: 8px;
    margin-bottom: 14px;
}

.note-form {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.sync-panel,
.share-panel,
.shared-note,
.ai-panel,
.profile-card {
    margin: 14px 0;
    padding: 16px;
}

.sync-panel form,
.share-panel {
    display: grid;
    gap: 12px;
}

.ai-output {
    min-height: 80px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
    line-height: 1.55;
    white-space: pre-wrap;
}

.admin-form-grid {
    grid-template-columns: minmax(160px, 0.35fr) 1fr auto;
    align-items: end;
}

.panel-title-row,
.row-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.row-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--danger);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.inline-action {
    display: inline-flex;
    margin: 0;
}

.admin-list {
    display: grid;
    gap: 10px;
}

.admin-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.admin-row span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.9rem;
}

.grid {
    display: grid;
    gap: 12px;
}

.grid.two {
    grid-template-columns: 1fr 1fr;
}

.editor-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

:root[data-theme="dark"] .editor-wrap {
    background: var(--surface);
}

.ai-controls {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(17, 100, 102, 0.08), rgba(248, 177, 149, 0.12));
}

.ai-controls label {
    margin: 0;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.toolbar button {
    min-width: 38px;
    min-height: 36px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font-weight: 750;
}

:root[data-theme="dark"] .toolbar button {
    background: #111827;
}

.editor {
    min-height: 190px;
    padding: 12px;
    line-height: 1.55;
    border: 0;
}

.scripture-preview {
    padding: 12px;
    border: 1px dashed #a9b8c8;
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--muted);
}

.scripture-preview blockquote {
    margin: 0;
    color: #23335d;
    line-height: 1.5;
}

.shared-by {
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.profile-card,
.shared-profile {
    display: flex;
    align-items: center;
    gap: 14px;
}

.profile-avatar,
.shared-profile img {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    object-fit: cover;
    background: var(--surface-soft);
}

.profile-card h2 {
    margin: 0;
}

.profile-card p,
.shared-profile span {
    display: block;
    margin: 4px 0 0;
    color: var(--muted);
}

.shared-profile {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.shared-profile img {
    width: 58px;
    height: 58px;
    border-radius: 14px;
}

.editor:empty::before {
    content: "Schrijf hier je geestelijke puntje...";
    color: #98a2b3;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
}

.check-row input {
    width: 18px;
    height: 18px;
}

@media (max-width: 560px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .topnav {
        width: 100%;
        justify-content: space-between;
    }

    .section-head {
        align-items: flex-start;
    }

    .grid.two {
        grid-template-columns: 1fr;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .admin-form-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-grid,
    .quick-panel,
    .admin-stats {
        grid-template-columns: 1fr;
    }

    .profile-reminder,
    .admin-row {
        align-items: stretch;
        flex-direction: column;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .actions .btn,
    .hero-actions .btn {
        flex: 1 1 130px;
    }
}
