/* ── core.css ── Variables, resets, base layout, shared components, overlays, book reader, responsive ── */

:root {
    --bg: #efe7db;
    --bg-deep: #d7c2ab;
    --surface: rgba(255, 251, 246, 0.9);
    --surface-strong: #fffdf8;
    --text: #241812;
    --muted: #6e5449;
    --line: rgba(95, 70, 56, 0.12);
    --accent: #b34e2e;
    --accent-soft: rgba(179, 78, 46, 0.12);
    --accent-dark: #6d2612;
    --success: #2f7659;
    --warning: #8f6a15;
    --danger: #983434;
    --shadow: 0 24px 70px rgba(73, 42, 25, 0.14);
    --radius: 24px;
    --radius-sm: 16px;
    --content-width: 1240px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
    background:
        radial-gradient(circle at top left, rgba(179, 78, 46, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(121, 93, 61, 0.18), transparent 24%),
        linear-gradient(180deg, #f7efe5, var(--bg));
    min-height: 100vh;
}

body.route-home .page-frame {
    width: min(calc(100% - 22px), 1180px);
}

body.route-dashboard .page-frame {
    width: min(calc(100% - 22px), 1180px);
}

body.route-home .main-shell,
body.route-dashboard .main-shell {
    gap: 18px;
}

body.has-overlay-modal {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img,
video {
    max-width: 100%;
    display: block;
    border-radius: var(--radius-sm);
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.page-frame {
    width: min(calc(100% - 32px), var(--content-width));
    margin: 0 auto;
    padding: 20px 0 36px;
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 18px 22px;
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 4px);
    background: rgba(255, 248, 239, 0.82);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
}

.brandmark {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.brand-badge {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    color: #fff8f0;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 18px;
    flex-shrink: 0;
}

.brand-copy {
    display: grid;
}

.brand-copy strong {
    font-size: 1.05rem;
}

.brand-copy small {
    color: var(--muted);
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-link,
.admin-menu-link,
.user-pill,
.feature-card,
.team-list-link {
    transition: 160ms ease;
}

.nav-link {
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--muted);
}

.nav-link:hover,
.nav-link.is-active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.72);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-user-group {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.topbar-growth-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 18px;
    border: 1px solid rgba(95, 70, 56, 0.1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(249, 242, 233, 0.66));
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.topbar-growth-btn:hover {
    border-color: var(--accent-soft);
    background: rgba(255, 255, 255, 0.85);
}

.topbar-growth-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

.topbar-growth-copy {
    display: grid;
    gap: 1px;
    text-align: center;
}

.topbar-growth-copy strong {
    font-size: 0.72rem;
    font-weight: 700;
}

.topbar-growth-copy small {
    font-size: 0.6rem;
    color: var(--muted);
}

.user-status-pill {
    min-width: 228px;
    padding: 8px 10px;
    border: 1px solid rgba(95, 70, 56, 0.1);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(249, 242, 233, 0.66));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.68),
        0 8px 18px rgba(104, 72, 47, 0.05);
}

.user-status-avatar {
    flex-shrink: 0;
}

.user-status-pill .avatar-sm {
    width: 34px;
    height: 34px;
}

.user-status-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.user-status-head,
.user-status-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-status-head strong {
    font-size: 0.92rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status-level {
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(160, 116, 61, 0.24);
    background: rgba(176, 112, 49, 0.08);
    color: #8b5c2d;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.user-status-bar {
    position: relative;
    overflow: hidden;
    height: 6px;
    border-radius: 999px;
    background: rgba(107, 79, 57, 0.12);
    box-shadow: inset 0 1px 1px rgba(73, 46, 23, 0.06);
}

.user-status-bar-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8f5d31 0%, #c48b4a 52%, #efd28a 100%);
    box-shadow: 0 0 8px rgba(239, 199, 109, 0.16);
}

.user-status-meta {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.user-status-flag {
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(84, 145, 112, 0.12);
    color: #4f7a62;
}

.desktop-nav a[href*="page=growth"],
.mobile-tabbar a[href*="page=growth"] {
    display: none;
}

.main-shell {
    display: grid;
    gap: 24px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 22px;
    padding: 34px;
    border-radius: 32px;
    background:
        linear-gradient(135deg, rgba(130, 58, 29, 0.96), rgba(35, 18, 14, 0.92)),
        linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent);
    color: #fff7ee;
    box-shadow: var(--shadow);
}

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

.hero-copy {
    display: grid;
    gap: 16px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.card-overlay {
    padding: 16px 18px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 248, 240, 0.08);
    display: grid;
    gap: 6px;
}

.card-overlay p,
.card-overlay small {
    margin: 0;
    color: rgba(255, 245, 236, 0.82);
}

.hero-copy p {
    margin: 0;
    color: rgba(255, 245, 236, 0.82);
    line-height: 1.8;
}

.eyebrow {
    display: inline-flex;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-panel {
    background: rgba(255, 247, 236, 0.12);
    border-color: rgba(255, 255, 255, 0.12);
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.hero-metrics div,
.stat-card,
.fortune-card {
    padding: 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
}

.hero-metrics strong,
.stat-card strong {
    display: block;
    font-size: 1.7rem;
}

.fortune-card p,
.fortune-card small {
    margin: 0;
    line-height: 1.7;
}

.content-section {
    display: grid;
    gap: 18px;
}

.content-section.no-padding {
    padding: 0;
}

.section-heading {
    display: grid;
    gap: 6px;
}

.section-heading p,
.section-heading small {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.section-heading.compact {
    gap: 4px;
}

.card,
.feature-card,
.empty-state {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.card {
    padding: 22px;
}

.card-grid {
    display: grid;
    gap: 18px;
}

.card-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ops-kpi {
    gap: 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 247, 238, 0.92)),
        linear-gradient(135deg, rgba(179, 78, 46, 0.04), transparent);
}


/* ── Overlay Modals & Book Reader ── */

.overlay-modal {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: grid;
    place-items: center;
    padding: 20px;
}

.overlay-modal[hidden] {
    display: none;
}

.overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(19, 12, 9, 0.72);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.overlay-modal.is-open .overlay-backdrop {
    opacity: 1;
}

.overlay-panel {
    position: relative;
    z-index: 1;
    width: min(980px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    border-radius: 30px;
    border: 1px solid rgba(95, 70, 56, 0.16);
    background:
        linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(244, 234, 222, 0.98));
    box-shadow: 0 30px 80px rgba(25, 16, 12, 0.28);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.overlay-modal.is-open .overlay-panel {
    opacity: 1;
    transform: translateY(0);
}

.sheet-panel {
    display: grid;
    gap: 16px;
    width: min(560px, 100%);
    padding: 24px;
}

.portrait-overlay {
    padding: 16px;
}

.portrait-panel {
    width: min(380px, 100%);
    padding: 18px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(252, 246, 237, 0.98), rgba(243, 232, 217, 0.98));
}

.portrait-close,
.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border: 1px solid rgba(95, 70, 56, 0.14);
    border-radius: 14px;
    background: rgba(255, 251, 246, 0.92);
    color: transparent;
    font-size: 0;
    line-height: 1;
    box-shadow: 0 10px 24px rgba(44, 26, 18, 0.08);
    backdrop-filter: blur(10px);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.portrait-close::before,
.modal-close::before {
    content: "×";
    color: #876d5b;
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1;
}

.portrait-close:hover,
.modal-close:hover {
    transform: translateY(-1px);
    border-color: rgba(179, 78, 46, 0.24);
    background: rgba(255, 247, 239, 0.98);
    box-shadow: 0 14px 28px rgba(44, 26, 18, 0.12);
}

.portrait-close:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid rgba(179, 78, 46, 0.3);
    outline-offset: 2px;
}

.portrait-frame {
    position: relative;
    display: grid;
    gap: 16px;
    padding: 18px 18px 22px;
    border: 4px solid rgba(180, 132, 76, 0.8);
    border-radius: 14px;
    background:
        radial-gradient(circle at top left, rgba(196, 162, 114, 0.12), transparent 24%),
        linear-gradient(180deg, rgba(252, 247, 239, 0.98), rgba(244, 233, 218, 0.98));
}

.portrait-avatar-ring {
    width: 112px;
    height: 112px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(196, 162, 114, 0.9);
    background: rgba(255, 255, 255, 0.8);
}

.portrait-avatar-ring img,
.portrait-avatar-ring .avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.portrait-copy {
    display: grid;
    gap: 10px;
    text-align: center;
}

.portrait-copy h3 {
    margin: 0;
    font-size: 2rem;
}

.portrait-tags {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.portrait-quote {
    padding: 16px 14px;
    border: 1px solid rgba(95, 70, 56, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.46);
    color: var(--muted);
    line-height: 1.9;
}

.portrait-open-book {
    width: 100%;
}

.opened-book-panel {
    width: min(1020px, 100%);
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
}

.opened-book-reader {
    position: relative;
    display: grid;
    gap: 18px;
    min-height: 100%;
}

.opened-book-header {
    padding: 22px 22px 0;
}

.opened-book-header-copy {
    display: grid;
    gap: 8px;
    max-width: 52ch;
    padding: 16px 18px;
    border-radius: 20px;
    background: rgba(255, 251, 246, 0.78);
    border: 1px solid rgba(95, 70, 56, 0.08);
}

.opened-book-header-copy h3 {
    margin: 0;
    font-size: 1.24rem;
}

.opened-book-header-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.opened-book-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    display: flex;
    gap: 10px;
}

.book-tool-button {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(95, 70, 56, 0.14);
    border-radius: 14px;
    background: rgba(255, 251, 246, 0.92);
    color: #876d5b;
    font-size: 1.18rem;
    box-shadow: 0 10px 24px rgba(44, 26, 18, 0.08);
    backdrop-filter: blur(10px);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.book-tool-button:hover {
    transform: translateY(-1px);
    border-color: rgba(179, 78, 46, 0.24);
    background: rgba(255, 247, 239, 0.98);
    box-shadow: 0 14px 28px rgba(44, 26, 18, 0.12);
}

.opened-book-spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 620px;
    background:
        linear-gradient(180deg, rgba(252, 246, 237, 0.98), rgba(243, 232, 217, 0.98));
}

.opened-book-spread[hidden] {
    display: none;
}

.opened-book-page {
    display: grid;
    gap: 18px;
    padding: 34px 28px 20px;
}

.opened-book-page + .opened-book-page {
    border-left: 1px solid rgba(95, 70, 56, 0.12);
}

.opened-book-photo-frame {
    overflow: hidden;
    border: 1px solid rgba(95, 70, 56, 0.12);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.7);
    padding: 10px;
}

.opened-book-photo-frame img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

.opened-book-page-no {
    color: #8b7768;
}

.opened-book-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(95, 70, 56, 0.12);
}

.opened-book-title h3 {
    margin: 0;
    padding-left: 12px;
    border-left: 6px solid #9c2d2d;
    font-size: 2rem;
}

.opened-book-title span {
    color: #9b8876;
}

.opened-book-text {
    min-height: 320px;
    color: #5a473d;
    line-height: 2;
    font-size: 1.12rem;
}

.opened-book-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(95, 70, 56, 0.12);
    color: #c0b0a2;
}

.opened-book-pagination strong {
    color: #8c7867;
}

.book-nav-button {
    min-width: 116px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid rgba(95, 70, 56, 0.14);
    border-radius: 999px;
    background: rgba(255, 251, 247, 0.92);
    color: var(--text);
}

.book-nav-button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.opened-book-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 0 24px 24px;
}

.opened-book-dot {
    min-height: 34px;
    padding: 6px 14px;
    border: 1px solid rgba(95, 70, 56, 0.12);
    border-radius: 999px;
    background: rgba(255, 252, 248, 0.9);
    color: var(--muted);
}

.opened-book-dot.is-active {
    border-color: rgba(179, 78, 46, 0.24);
    background: rgba(179, 78, 46, 0.12);
    color: var(--accent-dark);
}

.book-panel {
    padding: 18px;
}

.book-spread {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(95, 70, 56, 0.12);
    background: #f6ecde;
}

.book-page {
    min-height: 440px;
    background:
        linear-gradient(180deg, rgba(252, 246, 237, 0.98), rgba(243, 232, 217, 0.98));
}

.book-page + .book-page {
    border-left: 1px solid rgba(95, 70, 56, 0.12);
}

.book-page-inner {
    display: grid;
    gap: 16px;
    height: 100%;
    padding: 28px 24px;
}

.book-page-cover {
    background:
        radial-gradient(circle at top right, rgba(179, 78, 46, 0.12), transparent 24%),
        linear-gradient(180deg, rgba(247, 238, 227, 0.98), rgba(234, 221, 205, 0.98));
}

.book-page-cover-frame {
    display: grid;
    place-items: center;
    aspect-ratio: 3 / 4;
    border-radius: 22px;
    overflow: hidden;
    background: rgba(88, 55, 39, 0.1);
}

.book-page-cover-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.book-page-avatar {
    display: grid;
    place-items: center;
    height: 100%;
}

.book-page-avatar .avatar {
    width: 120px;
    height: 120px;
}

.book-page-meta {
    display: grid;
    gap: 6px;
}

.book-page-meta h3 {
    margin: 0;
    font-size: 1.3rem;
}

.book-page-meta p,
.book-page-meta small {
    margin: 0;
    color: var(--muted);
    line-height: 1.8;
}

.book-text-body {
    line-height: 1.9;
    color: var(--muted);
}

.book-panel-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 14px;
}

/* ── Shared Components (buttons, badges, forms, avatars, etc.) ── */

.ops-kpi span {
    color: var(--muted);
    font-size: 0.9rem;
}

.ops-kpi strong {
    font-size: 2rem;
}

.ops-kpi small {
    color: var(--muted);
}

.feature-card {
    display: grid;
    gap: 8px;
    padding: 22px;
}

.feature-card:hover,
.team-list-link:hover,
.admin-menu-link:hover {
    transform: translateY(-3px);
}

.feature-card strong,
.list-card strong {
    font-size: 1.04rem;
}

.feature-card span,
.list-card p,
.member-card p,
.media-card h3,
.book-content,
.status-banner span {
    color: var(--muted);
    line-height: 1.7;
}

.list-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(96, 67, 47, 0.08);
}

.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack-gap {
    display: grid;
    gap: 16px;
}

.button-row,
.meta-row,
.member-head,
.profile-head,
.user-pill,
.inline-form,
.site-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.meta-row {
    justify-content: space-between;
    flex-wrap: wrap;
}

.button-row {
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    font-weight: 700;
}

.button.primary {
    color: #fff7ef;
    background: linear-gradient(140deg, var(--accent), var(--accent-dark));
}

.button.ghost {
    color: var(--text);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(96, 67, 47, 0.12);
}

.button.danger {
    color: #fff8f5;
    background: linear-gradient(145deg, #b64646, #832424);
}

.button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.button.is-loading {
    pointer-events: none;
    opacity: 0.65;
    position: relative;
}

.button.is-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 6px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.text-link {
    color: var(--accent-dark);
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(42, 28, 21, 0.08);
    color: var(--muted);
    font-size: 0.82rem;
}

.badge.accent {
    color: #fff8ef;
    background: linear-gradient(140deg, var(--accent), var(--accent-dark));
}

.badge.soft-success {
    color: #1f8a63;
    background: rgba(47, 118, 89, 0.12);
}

.badge.soft-blue {
    color: #456ccf;
    background: rgba(69, 108, 207, 0.12);
}

.flash {
    padding: 14px 18px;
    border-radius: 18px;
    border: 1px solid transparent;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.flash.flash-out {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.flash.success {
    background: rgba(44, 123, 87, 0.12);
    border-color: rgba(44, 123, 87, 0.22);
}

.flash.warning {
    background: rgba(138, 111, 20, 0.12);
    border-color: rgba(138, 111, 20, 0.2);
}

.flash.error {
    background: rgba(159, 47, 47, 0.12);
    border-color: rgba(159, 47, 47, 0.2);
}

.search-form,
.auth-panel,
.admin-user-card {
    display: grid;
    gap: 16px;
}

.admin-user-search-wrap {
    padding: 14px 18px;
}

.admin-user-dropdown {
    z-index: 9999;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 360px;
    overflow-y: auto;
}

.admin-user-dropdown[hidden] {
    display: none;
}

.admin-user-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.12s;
}

.admin-user-dropdown-item:hover {
    background: rgba(179, 78, 46, 0.06);
}

.admin-user-dropdown-item + .admin-user-dropdown-item {
    border-top: 1px solid var(--line);
}

.admin-user-dropdown-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-user-dropdown-name strong {
    font-size: 0.9rem;
}

.admin-user-dropdown-name small {
    font-size: 0.76rem;
    color: var(--muted);
}

.admin-user-dropdown-tags {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-user-list-shell {
    padding: 14px;
}

.admin-user-row {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.4fr) auto;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(96, 67, 47, 0.08);
    background: rgba(255, 255, 255, 0.58);
}

.admin-user-row + .admin-user-row {
    margin-top: 2px;
}

.admin-user-row-main,
.admin-user-row-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user-row-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.admin-user-row-copy strong {
    font-size: 1rem;
}

.admin-user-row-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.admin-user-row-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-user-modal {
    z-index: 240;
}

.admin-user-edit-sheet {
    width: min(760px, calc(100vw - 32px));
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

label span {
    font-size: 0.92rem;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid rgba(96, 67, 47, 0.14);
    border-radius: 16px;
    background: var(--surface-strong);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent, #b08c5a);
    box-shadow: 0 0 0 3px rgba(176, 140, 90, 0.15);
}

.input-error {
    border-color: var(--danger, #e05252) !important;
    box-shadow: 0 0 0 3px rgba(224, 82, 82, 0.12) !important;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.checkbox-field {
    grid-auto-flow: column;
    justify-content: start;
    gap: 10px;
    align-items: center;
    color: var(--text);
}

.checkbox-field input {
    width: 18px;
    height: 18px;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full-span {
    grid-column: 1 / -1;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(96, 67, 47, 0.08);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 700;
}

.member-card {
    display: grid;
    gap: 14px;
}

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

.member-head h3,
.media-card h3,
.auth-panel h1 {
    margin: 0;
}

.avatar {
    overflow: hidden;
    flex: 0 0 auto;
    border-radius: 20px;
    background: linear-gradient(145deg, var(--accent), var(--accent-dark));
    color: #fff7ef;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 14px;
}

.avatar-md {
    width: 56px;
    height: 56px;
}

.avatar-lg {
    width: 92px;
    height: 92px;
    border-radius: 26px;
    font-size: 1.8rem;
}

.book-cover {
    max-height: 380px;
    object-fit: cover;
}

.book-content {
    padding: 20px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.52);
}

.auth-shell {
    min-height: 70vh;
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(100%, 560px);
    padding: 32px;
}

.auth-toast {
    padding: 10px 16px;
    border-radius: 12px;
    background: rgba(199, 84, 80, 0.14);
    border: 1px solid rgba(199, 84, 80, 0.28);
    color: var(--danger, #ff7d7d);
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
}

.auth-notice {
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(90, 160, 255, 0.10);
    border: 1px solid rgba(90, 160, 255, 0.25);
    color: #8bbfff;
    font-size: 0.84rem;
    line-height: 1.5;
    margin-bottom: 4px;
}

.auth-notice code {
    font-family: monospace;
    background: rgba(90, 160, 255, 0.18);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

.survey-force-modal {
    z-index: 300;
}

.survey-panel {
    width: min(420px, 100%);
}

.survey-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.survey-fieldset legend {
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 8px;
    color: var(--text);
}

.survey-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.survey-option-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid rgba(96, 67, 47, 0.14);
    border-radius: 12px;
    background: var(--surface-strong);
    cursor: pointer;
    font-size: 0.88rem;
    transition: border-color 0.2s, background 0.2s;
}

.survey-option-label:has(input:checked) {
    border-color: var(--accent, #b08c5a);
    background: rgba(176, 140, 90, 0.1);
}

.survey-option-label input {
    width: auto;
    margin: 0;
}

.survey-fieldset textarea {
    min-height: 60px;
}

.survey-unfilled-details {
    margin-top: 8px;
}

.survey-unfilled-summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted, #888);
    padding: 6px 0;
}

.survey-unfilled-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.survey-actions-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.survey-q-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.survey-q-type {
    width: 80px !important;
    flex-shrink: 0;
    padding: 5px 8px !important;
    font-size: 0.82rem;
}

.survey-q-row input {
    flex: 1;
    padding: 5px 8px !important;
    font-size: 0.84rem;
}

.survey-q-row .button {
    flex-shrink: 0;
    padding: 4px 8px;
}

.dashboard-hero {
    padding: 28px;
}

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

.stat-card {
    background: rgba(255, 255, 255, 0.6);
}

.status-banner {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 18px;
}

.status-banner.open {
    background: rgba(44, 123, 87, 0.1);
}

.status-banner.closed {
    background: rgba(159, 47, 47, 0.1);
}

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

.member-inline {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.team-list-link {
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.48);
    border: 1px solid rgba(96, 67, 47, 0.08);
}

.team-list-link.is-active {
    border-color: rgba(182, 70, 42, 0.35);
    background: rgba(182, 70, 42, 0.08);
}


/* ── General Responsive ── */

@media (max-width: 1080px) {
    .hero,
    .admin-shell,
    .two-column,
    .dashboard-team-shell,
    .profile-card-grid,
    .dashboard-rule-grid,
    .dashboard-redeem-grid,
    .dashboard-double-grid,
    .dashboard-admin-links,
    .book-editor-shell,
    .card-grid-4,
    .card-grid-3,
    .stats-grid,
    .portal-grid,
    .wander-grid,
    .member-kpis {
        grid-template-columns: 1fr;
    }

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

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

    .user-status-pill {
        min-width: min(100%, 300px);
    }

    .admin-sidebar {
        position: static;
    }

    .home-video-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-team-sidebar {
        border-left: 0;
        border-top: 1px solid rgba(97, 99, 144, 0.12);
    }
}

@media (max-width: 780px) {
    .page-frame {
        width: min(calc(100% - 20px), var(--content-width));
    }

    body.route-home .page-frame,
    body.route-dashboard .page-frame {
        width: min(calc(100% - 14px), 680px);
    }

    .hero,
    .wander-hero,
    .card,
    .member-center-card,
    .auth-panel {
        padding: 20px;
    }

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

    .hero-metrics,
    .wander-grid,
    .member-kpis {
        grid-template-columns: 1fr;
    }

    .desktop-nav,
    .topbar-actions,
    .button-row,
    .meta-row,
    .profile-head,
    .member-center-head,
    .member-center-user,
    .member-name-row,
    .wander-actions {
        align-items: stretch;
    }

    .member-edit-link {
        width: 100%;
    }

    .portal-grid .feature-card {
        min-height: 112px;
    }

    .admin-video-cover-grid,
    .book-editor-spread,
    .opened-book-spread {
        grid-template-columns: 1fr;
    }

    .admin-video-card-head {
        align-items: stretch;
    }

    .home-video-stage,
    .home-module-card,
    .sheet-panel,
    .book-panel,
    .dashboard-sheet {
        padding: 18px;
    }

    .dashboard-sheet-compact {
        width: min(100vw - 16px, 720px);
        padding: 16px;
    }

    .dashboard-team-sheet {
        width: min(100vw - 12px, 1120px);
        max-height: calc(100vh - 12px);
        padding: 0;
    }

    .dashboard-team-head,
    .dashboard-team-sidehead,
    .dashboard-team-panel,
    .dashboard-team-list {
        padding-left: 18px;
        padding-right: 18px;
    }

    .home-module-grid {
        grid-template-columns: 1fr;
    }

    .home-shelf-bar {
        align-items: stretch;
    }

    .home-shelf-search-inline {
        min-width: 100%;
    }

    .home-video-meta,
    .home-module-meta,
    .book-panel-footer {
        align-items: stretch;
    }

    .book-spread {
        grid-template-columns: 1fr;
    }

    .profile-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .book-corridor {
        padding: 24px 6px 10px;
    }

    .book-corridor-track {
        gap: 14px;
    }

    .corridor-book {
        width: 142px;
        flex-basis: 142px;
    }

    .corridor-book-shell {
        height: 188px;
    }

    .opened-book-spread {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .opened-book-pagination {
        gap: 10px;
        flex-wrap: wrap;
    }

    .book-editor-preview {
        position: static;
    }

    .book-editor-modal {
        max-height: calc(100vh - 16px);
    }

    .book-editor-summary-grid {
        grid-template-columns: 1fr;
    }

    .book-editor-workspace {
        overflow: visible;
    }

    .book-editor-pane-head {
        flex-direction: column;
    }

    .book-editor-tabbar {
        justify-content: flex-start;
    }

    .book-editor-pane-badges {
        justify-content: flex-start;
    }

    .book-editor-spread {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .book-editor-side {
        padding: 20px 18px;
    }

    .book-editor-side + .book-editor-side {
        border-left: 0;
        border-top: 1px solid rgba(95, 70, 56, 0.12);
    }

    .book-editor-meta-grid {
        grid-template-columns: 1fr;
    }

    .book-editor-image-empty {
        min-height: 220px;
    }

    .book-editor-form-stack {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .opened-book-page + .opened-book-page {
        border-left: 0;
        border-top: 1px solid rgba(95, 70, 56, 0.12);
    }

    .dashboard-stat-row {
        grid-template-columns: 1fr;
    }

    .dashboard-team-member-row {
        grid-template-columns: auto auto 1fr;
    }

    .admin-team-card-head,
    .admin-team-card-footer {
        align-items: stretch;
    }

    .admin-team-card-actions {
        justify-content: flex-start;
    }

    .admin-team-card-actions .button,
    .admin-team-card-actions .inline-form {
        width: 100%;
    }

    .admin-team-card-actions .inline-form .button {
        width: 100%;
    }

    .admin-user-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .admin-user-row-actions,
    .admin-user-row-actions .inline-form,
    .admin-user-row-actions .button {
        width: 100%;
    }

    .book-page + .book-page {
        border-left: 0;
        border-top: 1px solid rgba(95, 70, 56, 0.12);
    }

    .desktop-nav {
        display: none;
    }

    .mobile-tabbar {
        display: grid;
    }

    .user-pill,
    .button,
    .nav-link {
        justify-content: center;
    }

    .user-status-head,
    .user-status-meta {
        justify-content: space-between;
    }

    table {
        min-width: 100%;
    }
}

/* User-facing reader polish */
.portrait-panel {
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.opened-book-panel {
    max-height: calc(100vh - 20px);
}

.opened-book-reader {
    max-height: calc(100vh - 20px);
    overflow: auto;
}

@media (max-width: 780px) {
    .portrait-overlay,
    .book-overlay {
        padding: 10px;
    }

    .portrait-panel {
        width: min(100vw - 12px, 420px);
        padding: 14px;
        border-radius: 20px;
    }

    .portrait-frame {
        gap: 14px;
        padding: 16px 14px 18px;
    }

    .portrait-copy {
        gap: 8px;
    }

    .portrait-copy h3 {
        font-size: 1.5rem;
    }

    .portrait-avatar-ring {
        width: 88px;
        height: 88px;
    }

    .portrait-quote {
        padding: 12px;
        font-size: 0.95rem;
        line-height: 1.8;
    }

    .opened-book-panel {
        width: min(100vw - 10px, 1020px);
        border-radius: 20px;
    }

    .opened-book-reader {
        gap: 12px;
    }

    .opened-book-header {
        padding: 16px 16px 0;
    }

    .opened-book-header-copy {
        gap: 6px;
        padding: 14px 14px 12px;
        border-radius: 18px;
    }

    .opened-book-header-copy h3 {
        font-size: 1.08rem;
    }

    .opened-book-toolbar {
        top: 12px;
        right: 12px;
        gap: 8px;
    }

    .book-tool-button {
        width: 38px;
        height: 38px;
    }

    .opened-book-page {
        gap: 14px;
        padding: 24px 16px 14px;
    }

    .opened-book-photo-frame {
        padding: 8px;
    }

    .opened-book-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding-bottom: 12px;
    }

    .opened-book-title h3 {
        padding-left: 10px;
        border-left-width: 5px;
        font-size: 1.45rem;
    }

    .opened-book-text {
        min-height: auto;
        font-size: 1rem;
        line-height: 1.85;
    }

    .opened-book-pagination {
        gap: 10px;
        padding: 14px 16px 0;
    }

    .book-nav-button {
        flex: 1 1 0;
        min-width: 0;
    }

    .opened-book-dots {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 16px 18px;
        scrollbar-width: thin;
    }

    .opened-book-dot {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 520px) {
    .portrait-panel {
        width: min(100vw - 8px, 380px);
        padding: 12px;
    }

    .portrait-frame {
        padding: 14px 12px 16px;
    }

    .opened-book-page {
        padding: 20px 12px 12px;
    }

    .opened-book-title h3 {
        font-size: 1.28rem;
    }

    .opened-book-pagination {
        justify-content: stretch;
    }

    .opened-book-pagination strong {
        width: 100%;
        text-align: center;
    }

    .book-nav-button {
        min-height: 40px;
        padding: 0 12px;
    }

    .opened-book-dots {
        gap: 8px;
        padding: 0 12px 14px;
    }

    .opened-book-dot {
        min-height: 32px;
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    .opened-book-header {
        padding: 14px 12px 0;
    }

    .opened-book-header-copy {
        padding: 12px;
    }
}
