:root {
    color-scheme: light;
    --bg: #f3efe5;
    --bg-accent: #efe5d1;
    --panel: rgba(255, 252, 245, 0.92);
    --panel-strong: #fffdf8;
    --ink: #1d1c19;
    --muted: #665f56;
    --line: rgba(44, 36, 24, 0.12);
    --brand: #b04c21;
    --brand-deep: #7c2f10;
    --brand-soft: #f1d2c2;
    --success: #0f766e;
    --danger: #b42318;
    --shadow: 0 18px 50px rgba(65, 44, 17, 0.12);
    --radius: 24px;
    --radius-sm: 14px;
    --content: 1180px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171815;
    --bg-accent: #1d201a;
    --panel: rgba(26, 28, 24, 0.9);
    --panel-strong: #22251f;
    --ink: #f4efe4;
    --muted: #c1b7a8;
    --line: rgba(244, 239, 228, 0.12);
    --brand: #ef8452;
    --brand-deep: #ffb089;
    --brand-soft: rgba(239, 132, 82, 0.18);
    --success: #5fd0bf;
    --danger: #ff8e86;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(176, 76, 33, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 24%),
        linear-gradient(180deg, #f6f2e9 0%, var(--bg) 100%);
}

:root[data-theme="dark"] html,
:root[data-theme="dark"] body,
html[data-theme="dark"],
body[data-theme="dark"] {
    background:
        radial-gradient(circle at top left, rgba(239, 132, 82, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(95, 208, 191, 0.09), transparent 24%),
        linear-gradient(180deg, #141512 0%, var(--bg) 100%);
}

body {
    line-height: 1.5;
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    width: min(calc(100% - 32px), 1360px);
    margin: 0 auto;
    padding: 20px 0 48px;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 28px;
}

.sidebar {
    position: sticky;
    top: 20px;
    align-self: start;
    display: grid;
    gap: 16px;
    padding: 24px 18px 18px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    min-height: calc(100vh - 40px);
}

.sidebar-header {
    padding-bottom: 8px;
}

.brand {
    font-family: "IBM Plex Serif", Georgia, serif;
    font-size: 1.65rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: -0.03em;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
    align-items: start;
}

.nav-link,
.nav-button {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.44);
    color: var(--ink);
    padding: 12px 14px;
    border-radius: 16px;
    text-decoration: none;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.nav-link:hover,
.nav-button:hover,
.profile-panel:hover,
.social-login-button:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.nav-link.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.nav-button {
    cursor: pointer;
}

.profile-panel {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.62);
    border-radius: 20px;
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    text-decoration: none;
    margin-top: 6px;
}

.profile-panel.active {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 45%, transparent);
}

.profile-chip {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    overflow: hidden;
    flex: 0 0 auto;
}

.profile-chip.active {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 45%, transparent);
}

.profile-chip-avatar {
    width: 46px;
    height: 46px;
    object-fit: cover;
    display: block;
    border-radius: 999px;
}

.profile-chip-fallback {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--brand-deep);
    background: rgba(255, 255, 255, 0.6);
}

.profile-panel-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.profile-panel-text strong,
.profile-panel-text span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-panel-text span {
    color: var(--muted);
    font-size: 0.88rem;
}

.theme-switcher {
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
    font-size: 0.92rem;
}

:root[data-theme="dark"] .theme-switcher {
    background: rgba(255, 255, 255, 0.04);
}

.theme-select {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.68);
    color: var(--ink);
    min-width: 100%;
    outline: none;
    border-radius: 10px;
    padding: 8px 10px;
}

.page {
    display: grid;
    gap: 24px;
}

.page-content {
    padding-top: 4px;
    align-content: start;
}

.landing-heading {
    max-width: 760px;
}

.landing-grid {
    align-items: start;
}

.hero,
.page-heading,
.panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero,
.page-heading {
    padding: 32px;
}

.hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    align-items: stretch;
}

.hero-panel {
    padding: 24px;
    border-radius: calc(var(--radius) - 8px);
    background: linear-gradient(180deg, var(--panel-strong), rgba(255, 247, 240, 0.82));
    border: 1px solid var(--line);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.74rem;
    color: var(--brand-deep);
    margin: 0 0 12px;
    font-weight: 700;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.1;
}

h1 {
    font-family: "IBM Plex Serif", Georgia, serif;
    font-size: clamp(2rem, 4vw, 3.75rem);
    letter-spacing: -0.04em;
}

h2 {
    font-size: 1.15rem;
}

.lede,
.muted {
    color: var(--muted);
}

.lede {
    max-width: 64ch;
    margin-top: 16px;
}

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

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

.panel {
    padding: 24px;
}

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

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

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

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--muted);
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    outline: none;
}

.field input:focus,
.field textarea:focus,
.theme-select:focus {
    border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.field textarea {
    min-height: 110px;
    resize: vertical;
}

.button-row,
.section-header,
.card-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.social-login-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.social-login-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
}

.social-logo {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.primary-button,
.secondary-button,
.ghost-button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-button {
    background: linear-gradient(135deg, var(--brand), var(--brand-deep));
    color: #fff;
}

.secondary-button {
    background: var(--brand-soft);
    color: var(--brand-deep);
}

.ghost-button {
    background: transparent;
    color: var(--brand-deep);
    border: 1px solid var(--line);
}

:root[data-theme="dark"] .nav-link,
:root[data-theme="dark"] .nav-button,
:root[data-theme="dark"] .profile-chip,
:root[data-theme="dark"] .social-login-button,
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .data-item,
:root[data-theme="dark"] .site-card,
:root[data-theme="dark"] .user-card,
:root[data-theme="dark"] .schema-item,
:root[data-theme="dark"] .status,
:root[data-theme="dark"] .callout,
:root[data-theme="dark"] .empty-state {
    background: rgba(255, 255, 255, 0.04);
}

.status,
.callout {
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
}

.status.error {
    border-color: rgba(180, 35, 24, 0.25);
    color: var(--danger);
    background: rgba(180, 35, 24, 0.06);
}

.status.success {
    border-color: rgba(15, 118, 110, 0.22);
    color: var(--success);
    background: rgba(15, 118, 110, 0.07);
}

.metric-grid,
.data-grid,
.card-grid {
    display: grid;
    gap: 14px;
}

.metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.metric {
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

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

.metric-value {
    margin-top: 6px;
    font-size: 1.3rem;
    font-weight: 700;
}

.data-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.data-item {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.66);
}

.data-item .label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.site-card,
.user-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.72);
}

.site-card h3,
.user-card h3 {
    margin-bottom: 8px;
}

.inline-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pill {
    background: rgba(176, 76, 33, 0.08);
    color: var(--brand-deep);
    border: 1px solid rgba(176, 76, 33, 0.14);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
}

.avatar {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--brand-soft), rgba(15, 118, 110, 0.12));
    border: 1px solid rgba(255, 255, 255, 0.7);
}

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

.identity-top {
    display: flex;
    gap: 18px;
    align-items: center;
}

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

.identity-name {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.empty-state {
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.42);
}

.mono {
    font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
    font-size: 0.92rem;
}

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

.schema-item {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.66);
}

.avatar-large {
    width: 112px;
    height: 112px;
    border-radius: 30px;
}

.hidden {
    display: none !important;
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 10, 6, 0.6);
    backdrop-filter: blur(10px);
}

.modal-panel {
    position: relative;
    width: min(100%, 920px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 24px;
}

/* Native dialog modal styles */
.modal {
    border: none;
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 0;
    max-width: min(100%, 520px);
    width: 90%;
}

.modal::backdrop {
    background: rgba(12, 10, 6, 0.6);
    backdrop-filter: blur(10px);
}

.modal-content {
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.modal-close:hover {
    background: var(--bg-accent);
    color: var(--ink);
}

.avatar-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    gap: 22px;
    align-items: start;
}

.avatar-stage-wrap {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 28px;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(176, 76, 33, 0.1), rgba(15, 118, 110, 0.12)),
        rgba(255, 255, 255, 0.55);
    border: 1px solid var(--line);
}

.avatar-editor-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

.avatar-editor-canvas.dragging {
    cursor: grabbing;
}

.avatar-crop-guide {
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
    border: 2px solid rgba(255, 255, 255, 0.95);
    pointer-events: none;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        min-height: 0;
    }

    .hero,
    .two-up,
    .field-grid,
    .avatar-editor-layout {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 24px;
    }
}
