:root {
    color-scheme: light;
    --bg: #f6f5f1;
    --surface: #ffffff;
    --surface-muted: #eeece6;
    --surface-hover: #e5e2da;
    --border: rgba(24, 30, 25, 0.09);
    --border-strong: rgba(24, 30, 25, 0.18);
    --text: #161b17;
    --text-muted: #5a635b;
    --accent: #155941;
    --accent-hover: #0f4431;
    --accent-soft: rgba(21, 89, 65, 0.10);
    --accent-fg: #ffffff;
    --danger: #b42318;
    --danger-soft: rgba(180, 35, 24, 0.10);
    --warn: #9a4a06;
    --warn-soft: rgba(154, 74, 6, 0.12);
    --shadow-sm: 0 1px 2px rgba(16, 24, 18, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(16, 24, 18, 0.06), 0 2px 4px -2px rgba(16, 24, 18, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(16, 24, 18, 0.12), 0 8px 10px -6px rgba(16, 24, 18, 0.08);
    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;
    --z-base: 1;
    --z-sticky: 10;
    --z-header: 20;
    --z-toast: 30;
    --z-dialog: 40;
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f1210;
        --surface: #171b18;
        --surface-muted: #212723;
        --surface-hover: #2a312c;
        --border: rgba(240, 244, 241, 0.09);
        --border-strong: rgba(240, 244, 241, 0.18);
        --text: #f1f3f0;
        --text-muted: #9aa39b;
        --accent: #35b486;
        --accent-hover: #47c597;
        --accent-soft: rgba(53, 180, 134, 0.16);
        --accent-fg: #062116;
        --danger: #f06a60;
        --danger-soft: rgba(240, 106, 96, 0.16);
        --warn: #f59e0b;
        --warn-soft: rgba(245, 158, 11, 0.16);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
        --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.42);
        --shadow-lg: 0 24px 36px -8px rgba(0, 0, 0, 0.65);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1210;
    --surface: #171b18;
    --surface-muted: #212723;
    --surface-hover: #2a312c;
    --border: rgba(240, 244, 241, 0.09);
    --border-strong: rgba(240, 244, 241, 0.18);
    --text: #f1f3f0;
    --text-muted: #9aa39b;
    --accent: #35b486;
    --accent-hover: #47c597;
    --accent-soft: rgba(53, 180, 134, 0.16);
    --accent-fg: #062116;
    --danger: #f06a60;
    --danger-soft: rgba(240, 106, 96, 0.16);
    --warn: #f59e0b;
    --warn-soft: rgba(245, 158, 11, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.42);
    --shadow-lg: 0 24px 36px -8px rgba(0, 0, 0, 0.65);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    line-height: 1.2;
    margin-block: 0 0.5em;
    text-wrap: balance;
    font-weight: 700;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.15rem, 2.2vw, 1.35rem); }
h3 { font-size: 1.02rem; }

p, li, dd, figcaption {
    text-wrap: pretty;
    margin-block: 0 0.75rem;
}
p:last-child { margin-bottom: 0; }

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

img, video { display: block; max-width: 100%; }

.tabular, td, dd, time, progress, .pill-count, .stat-value {
    font-variant-numeric: tabular-nums;
}

/* Top Navigation & Mobile Tab Bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.topbar-inner, main {
    width: min(100% - 2rem, 72rem);
    margin-inline: auto;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 4rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-right: auto;
    color: var(--text);
    font-weight: 780;
    font-size: 1.15rem;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.65rem;
    background: var(--accent-soft);
    color: var(--accent);
}
.brand span { color: var(--accent); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.93rem;
    text-decoration: none;
}
.nav-link:hover {
    color: var(--text);
    background: var(--surface-muted);
    text-decoration: none;
}
.nav-link[aria-current="page"] {
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.35rem;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}
.icon-btn:hover {
    color: var(--text);
    background: var(--surface-muted);
}

[data-theme="dark"] .theme-icon-dark,
:root:not([data-theme="dark"]) .theme-icon-light {
    display: none;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
    :root:not([data-theme="light"]) .theme-icon-light { display: block; }
}

.mobile-bar {
    display: none;
}

@media (max-width: 720px) {
    .topbar .nav-links { display: none; }
    body.has-mobile-bar {
        padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
    }
    .mobile-bar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: var(--z-header);
        display: flex;
        justify-content: space-around;
        align-items: center;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
    }
    .mobile-bar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        padding: 0.3rem 0.9rem;
        border-radius: var(--radius-md);
        color: var(--text-muted);
        font-size: 0.74rem;
        font-weight: 600;
        text-decoration: none;
        position: relative;
    }
    .mobile-bar a[aria-current="page"] {
        color: var(--accent);
        background: var(--accent-soft);
    }
}

main {
    flex: 1;
    padding-block: clamp(1.25rem, 3vw, 2.25rem) 3rem;
}

/* Badges & Pills */
.pill-count {
    display: inline-grid;
    place-items: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding-inline: 0.38rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}
.pill-muted {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 650;
    background: var(--surface-muted);
    color: var(--text-muted);
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    font-size: 0.84rem;
    font-weight: 650;
    margin-bottom: 0.45rem;
}

/* Buttons */
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--accent-fg);
    font: inherit;
    font-size: 0.93rem;
    font-weight: 650;
    padding: 0.6rem 1rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 140ms ease-out, opacity 140ms ease-out;
}
button:hover, .button:hover {
    background: var(--accent-hover);
    text-decoration: none;
}
button:active, .button:active {
    transform: scale(0.98);
}
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.quiet {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.quiet:hover {
    background: var(--surface-muted);
}

.ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.ghost:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.danger-btn {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: transparent;
}
.danger-btn:hover {
    background: var(--danger);
    color: #ffffff;
}

.btn-sm {
    padding: 0.4rem 0.72rem;
    font-size: 0.85rem;
    border-radius: 0.65rem;
}

/* Forms & Inputs */
.field {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

label {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 400;
}
textarea { resize: vertical; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrap input { padding-right: 2.75rem; }
.input-toggle {
    position: absolute;
    right: 0.35rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
}
.input-toggle:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-weight: 500;
    cursor: pointer;
}
.choice input {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.2rem;
    accent-color: var(--accent);
    flex: none;
}

.hint {
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 400;
    margin: 0;
}

/* Layout Helpers & Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1.1rem, 3vw, 1.65rem);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.narrow {
    max-width: 29rem;
    margin-inline: auto;
}

.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: 0.65rem; }

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}
.row-between {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { margin-bottom: 0.2rem; }
.page-subtitle {
    color: var(--text-muted);
    margin: 0;
}

/* Notices & Alerts */
.notice {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
}
.notice ul {
    margin: 0;
    padding-left: 1.15rem;
}
.notice.error {
    border-left-color: var(--danger);
    background: var(--danger-soft);
}

/* Landing Hero & Feature Bento */
.hero-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: clamp(1.5rem, 5vw, 3.5rem);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}
.hero-title {
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.1;
    margin-bottom: 0.75rem;
}
.hero-lead {
    font-size: 1.08rem;
    color: var(--text-muted);
    max-width: 34rem;
    margin-bottom: 1.5rem;
}
.hero-preview {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem;
    display: grid;
    gap: 0.85rem;
}
.mock-group-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.mock-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
}
.mock-tile {
    aspect-ratio: 1;
    border-radius: 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--accent);
}
.mock-tile.tall {
    background: var(--accent-soft);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
}
.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    box-shadow: var(--shadow-sm);
}
.feature-icon {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 0.85rem;
}
.feature-card h2 { font-size: 1.08rem; margin-bottom: 0.35rem; }
.feature-card p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }

@media (max-width: 820px) {
    .hero-layout { grid-template-columns: 1fr; }
}

/* Auth Switcher */
.seg-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--surface-muted);
    border-radius: var(--radius-md);
    margin-bottom: 1.35rem;
}
.seg-control a {
    text-align: center;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius-md) - 0.2rem);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 650;
    text-decoration: none;
}
.seg-control a[aria-current="page"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* Avatars & Avatar Stacks */
.avatar {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 720;
    font-size: 0.95rem;
    border: 2px solid var(--surface);
}
.avatar-xs { width: 1.65rem; height: 1.65rem; font-size: 0.72rem; border-width: 1.5px; }
.avatar-sm { width: 2rem; height: 2rem; font-size: 0.8rem; }
.avatar-lg { width: 5.25rem; height: 5.25rem; font-size: 1.75rem; }

.avatar-stack {
    display: inline-flex;
    align-items: center;
}
.avatar-stack > * + * {
    margin-left: -0.55rem;
}
.avatar-more {
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 0.74rem;
}

/* Copyable ID / Link Chip */
.id-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.45rem 0.35rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.id-chip strong { color: var(--text); }

.copy-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.copy-box input {
    border: 0;
    background: transparent;
    padding: 0.35rem 0.5rem;
    font-size: 0.88rem;
}

/* Group & Album Visual Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
    gap: 1.1rem;
}

.visual-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    text-decoration: none;
    transition: transform 160ms ease-out;
}
.visual-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    text-decoration: none;
}

.visual-cover {
    position: relative;
    aspect-ratio: 16 / 10;
    background: var(--surface-muted);
    overflow: hidden;
    display: grid;
    place-items: center;
}
.visual-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.visual-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.visual-body {
    padding: 1rem 1.15rem;
    display: grid;
    gap: 0.55rem;
    flex: 1;
}
.visual-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.visual-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.album-card {
    position: relative;
    min-width: 0;
}
.album-card .visual-card {
    height: 100%;
}
.album-delete {
    position: absolute;
    inset: auto 0.6rem 0.65rem auto;
}
.album-delete button {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.album-delete button:hover {
    background: var(--danger);
    color: #ffffff;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: clamp(2rem, 5vw, 3.25rem) 1.25rem;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    display: grid;
    justify-items: center;
    gap: 0.6rem;
}
.empty-icon {
    display: inline-grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 0.25rem;
}
.empty-state h3 { margin: 0; font-size: 1.1rem; }
.empty-state p { color: var(--text-muted); max-width: 26rem; margin: 0 0 0.5rem; }

/* Group Header & Section Switcher */
.group-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: clamp(0.95rem, 2.5vw, 1.4rem) clamp(1rem, 3vw, 1.6rem);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.85rem;
}
.group-hero h1 {
    font-size: clamp(1.45rem, 3.5vw, 2.05rem);
    margin-bottom: 0.15rem;
}
.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

.section-nav {
    position: sticky;
    top: 4.1rem;
    z-index: var(--z-sticky);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
    padding: 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.95rem;
}
.section-btn {
    min-width: 0;
    background: transparent;
    color: var(--text-muted);
    border: 0;
    border-radius: calc(var(--radius-lg) - 0.3rem);
    padding: 0.5rem 0.5rem;
    font-size: 0.86rem;
    font-weight: 650;
    gap: 0.35rem;
}
.section-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.section-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
}
.section-btn[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}
@media (max-width: 480px) {
    .section-btn svg { display: none; }
}

/* Upload Composer & Dropzone */
.upload-composer {
    margin-bottom: 1.1rem;
}

.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: opacity 150ms ease-out;
}
.dropzone:hover,
.dropzone.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.dropzone-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.dropzone-icon {
    display: inline-grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.65rem;
    background: var(--accent-soft);
    color: var(--accent);
    flex: none;
}
.dropzone-title {
    font-weight: 650;
    font-size: 0.92rem;
    color: var(--text);
    display: block;
}
.dropzone-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
}
@media (max-width: 560px) {
    .dropzone-cta { display: none; }
}

.upload-Tray {
    margin-top: 0.65rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: grid;
    gap: 0.85rem;
}

.preview-strip {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}
.preview-chip {
    position: relative;
    width: 4.5rem;
    height: 4.5rem;
    flex: none;
    border-radius: 0.65rem;
    overflow: hidden;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.preview-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.preview-remove {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border-radius: 50%;
    background: rgba(15, 18, 16, 0.78);
    color: #fff;
    font-size: 0.75rem;
}
.preview-remove:hover { background: var(--danger); }

.upload-meter {
    display: grid;
    gap: 0.4rem;
}
progress {
    width: 100%;
    height: 0.55rem;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-muted);
    accent-color: var(--accent);
}
progress::-webkit-progress-bar { background: var(--surface-muted); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* Photo & Video Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
    gap: 0.9rem;
}

.media-tile {
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform 160ms ease-out;
}
.media-tile:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.media-frame {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface-muted);
    overflow: hidden;
    display: block;
}
.media-frame img,
.media-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-badge {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.22rem 0.5rem;
    border-radius: 999px;
    background: rgba(15, 18, 16, 0.72);
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 650;
    pointer-events: none;
}

.media-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.media-author {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}
.media-author span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.media-meta time {
    font-size: 0.76rem;
    flex: none;
}

/* Pagination */
nav[role="navigation"] {
    margin-top: 1.25rem;
    display: flex;
    justify-content: center;
}
nav[role="navigation"] ul,
.pagination {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
}

/* Member List & Invites */
.member-list {
    display: grid;
    gap: 0.5rem;
}
.member-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}
.member-person {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}
.member-person a {
    color: var(--text);
    font-weight: 650;
}

/* Profile */
.profile-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: clamp(1.25rem, 3.5vw, 2rem);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}
.profile-banner h1 { margin-bottom: 0.2rem; }
.bio {
    white-space: pre-line;
    color: var(--text);
    margin-top: 0.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
    gap: 1rem;
    align-items: start;
}
.settings-grid .card { margin-bottom: 0; }

/* Admin Dashboard & Tables */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow-sm);
}
.kpi-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.stat-value {
    font-size: 1.55rem;
    font-weight: 760;
    line-height: 1.2;
}
.kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.status-pills {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
    gap: 0.65rem;
}
.status-pill {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    border: 1px solid var(--border);
}
.status-pill dt {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.status-pill dd {
    margin: 0.2rem 0 0;
    font-size: 1.15rem;
    font-weight: 720;
}
.status-pill small {
    display: block;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-muted);
}

.scroll { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th, td {
    text-align: left;
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th {
    font-size: 0.78rem;
    font-weight: 650;
    color: var(--text-muted);
}
tbody tr:last-child td { border-bottom: 0; }
td form { margin: 0; }
.warn { color: var(--danger); }

.search-input {
    max-width: 18rem;
}

/* Native Dialogs & Fullscreen Lightbox */
dialog.modal {
    width: min(100% - 2rem, 28rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: var(--text);
    padding: 1.4rem;
    box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop {
    background: rgba(10, 12, 11, 0.55);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

dialog.lightbox {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border: 0;
    border-radius: 0;
    background: #0b0d0c;
    color: #f3f5f3;
}
dialog.lightbox[open] {
    display: grid;
    grid-template-rows: auto 1fr auto;
}
dialog.lightbox::backdrop {
    background: #0b0d0c;
}
.lightbox-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.15rem;
}
.lightbox-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    padding-inline: clamp(0.5rem, 4vw, 4rem);
}
.lightbox-stage img,
.lightbox-stage video {
    max-width: 100%;
    max-height: calc(100dvh - 8.5rem);
    object-fit: contain;
    border-radius: var(--radius-sm);
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.24); }
.lightbox-nav:active { transform: translateY(-50%) scale(0.96); }
.lightbox-prev { left: 0.75rem; }
.lightbox-next { right: 0.75rem; }
.lightbox-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.15rem 1rem;
    color: rgba(243, 245, 243, 0.78);
    font-size: 0.88rem;
}
.lightbox .icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}
.lightbox .icon-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
