:root {
    color-scheme: dark;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --surface-glow: radial-gradient(circle at top right, rgba(255, 122, 0, 0.14), transparent 35%);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.32);
}

html[data-theme='dark'] {
    color-scheme: dark;
    --background: #0d0f14;
    --background-alt: #111217;
    --surface: #151821;
    --surface-raised: #1e2230;
    --border: #2b3142;
    --text-primary: #f4f4f5;
    --text-secondary: #b7bbc8;
    --muted: #7f8596;
    --primary: #ff7a00;
    --primary-hover: #ff9a2e;
    --accent: #ffd166;
    --danger: #e63946;
    --success: #4ade80;
    --redacted: #050505;
    --link: #83b9ff;
}

html[data-theme='light'] {
    color-scheme: light;
    --background: #f7f7f8;
    --background-alt: #fff4e8;
    --surface: #ffffff;
    --surface-raised: #fff4e8;
    --border: #e2e4ea;
    --text-primary: #181a20;
    --text-secondary: #4b5160;
    --muted: #777d8c;
    --primary: #e86d00;
    --primary-hover: #ff7a00;
    --accent: #f5b700;
    --danger: #c92a36;
    --success: #15803d;
    --redacted: #050505;
    --link: #0f5cc0;
    --shadow-lg: 0 24px 60px rgba(34, 36, 44, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    background:
        linear-gradient(180deg, rgba(230, 57, 70, 0.08), transparent 18%),
        linear-gradient(120deg, rgba(255, 122, 0, 0.08), transparent 24%),
        var(--background);
    color: var(--text-primary);
}

a {
    color: var(--link);
}

button,
input,
select,
textarea {
    font: inherit;
}

.site-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem clamp(1rem, 2vw, 2rem);
    border-bottom: 1px solid var(--border);
    background: rgba(13, 15, 20, 0.72);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 30;
}

html[data-theme='light'] .site-header {
    background: rgba(247, 247, 248, 0.76);
}

.site-logo {
    text-decoration: none;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 700;
    letter-spacing: 0.08em;
}

.site-logo span {
    background: linear-gradient(90deg, #e63946 0%, #ff7a00 45%, #ffd166 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex: 1;
}

.search-box {
    position: relative;
    max-width: 28rem;
    width: min(100%, 28rem);
}

.search-input,
.field,
.select-field,
.textarea-field {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.search-input:focus,
.field:focus,
.select-field:focus,
.textarea-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.18);
}

.search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.5rem);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.search-result {
    width: 100%;
    padding: 0.95rem 1rem;
    border: 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
}

.search-result:last-child {
    border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
    background: rgba(255, 122, 0, 0.1);
    outline: none;
}

.search-result.no-results {
    cursor: default;
    color: var(--muted);
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.icon-button {
    width: 2.9rem;
    height: 2.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--text-primary);
    position: relative;
}

.locale-button {
    font-weight: 700;
    letter-spacing: 0.06em;
}

.icon-sun,
.icon-moon,
.account-avatar {
    display: inline-block;
}

.icon-sun,
.icon-moon {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 999px;
    position: absolute;
    transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.icon-sun {
    background: linear-gradient(180deg, #ffe6a5 0%, var(--accent) 100%);
    box-shadow:
        0 0 0 0.16rem rgba(255, 209, 102, 0.28),
        0 0 0 0.42rem rgba(255, 209, 102, 0.1);
}

.icon-sun::before {
    content: '';
    position: absolute;
    inset: -0.25rem;
    border-radius: 999px;
    border: 1px dashed rgba(255, 209, 102, 0.68);
}

.icon-moon {
    border: 2px solid rgba(223, 230, 252, 0.95);
    background: rgba(170, 181, 214, 0.16);
    transform: translateY(0.05rem);
}

.icon-moon::before {
    content: '';
    position: absolute;
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 999px;
    right: -0.18rem;
    top: -0.1rem;
    background: var(--surface-raised);
}

html[data-theme='light'] .icon-moon {
    border-color: rgba(59, 66, 94, 0.72);
    background: rgba(127, 137, 173, 0.08);
}

html[data-theme='dark'] .icon-sun {
    opacity: 0;
    transform: scale(0.8);
}

html[data-theme='dark'] .icon-moon {
    opacity: 1;
}

html[data-theme='light'] .icon-sun {
    opacity: 1;
}

html[data-theme='light'] .icon-moon {
    opacity: 0;
    transform: scale(0.8);
}

.account-avatar {
    width: 1.25rem;
    height: 1.25rem;
    position: relative;
    filter: drop-shadow(0 0 0.1rem rgba(255, 122, 0, 0.2));
}

.account-avatar::before,
.account-avatar::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid currentColor;
}

.account-avatar::before {
    width: 0.48rem;
    height: 0.48rem;
    top: 0.01rem;
    border-radius: 999px;
    background: transparent;
}

.account-avatar::after {
    width: 1rem;
    height: 0.58rem;
    bottom: 0.03rem;
    border-top-left-radius: 0.8rem;
    border-top-right-radius: 0.8rem;
    border-bottom: 0;
}

.account-menu-wrap {
    position: relative;
}

.account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.6rem);
    width: min(20rem, 85vw);
    padding: 0.6rem;
    border-radius: 18px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.account-panel {
    display: grid;
    gap: 0.55rem;
}

.account-title {
    margin: 0;
    font-weight: 700;
}

.account-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.menu-button {
    width: 100%;
    text-align: left;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.85rem 0.9rem;
    border-radius: 12px;
    cursor: pointer;
}

.site-main {
    width: min(1200px, calc(100vw - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
    flex: 1;
}

.hero-panel {
    display: block;
}

.hero-copy,
.panel,
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.hero-copy::before,
.panel::before,
.modal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--surface-glow);
    pointer-events: none;
}

.hero-copy,
.wiki-main,
.wiki-side {
    padding: clamp(1.4rem, 2.4vw, 2rem);
}

.eyebrow,
.card-label {
    margin: 0 0 0.65rem;
    color: var(--accent);
    letter-spacing: 0.18em;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.hero-copy h1,
.wiki-toolbar h1 {
    margin: 0;
    font-family: var(--font-display);
    line-height: 1.04;
    letter-spacing: -0.03em;
}

.hero-copy h1 {
    font-size: clamp(2.6rem, 6vw, 4.8rem);
    max-width: 14ch;
}

.hero-text,
.site-footer,
.wiki-main p,
.wiki-side p,
.wiki-meta-value {
    color: var(--text-secondary);
    line-height: 1.7;
}

.hero-list {
    margin: 1.1rem 0 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.hero-list li + li {
    margin-top: 0.4rem;
}

.hero-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
    padding: 0.9rem 1.15rem;
}

.primary-button {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.secondary-button,
.ghost-button {
    background: transparent;
    color: var(--text-primary);
}

.danger-button {
    background: rgba(230, 57, 70, 0.14);
    color: var(--danger);
    border-color: rgba(230, 57, 70, 0.32);
}

.wiki-view {
    display: grid;
    gap: 1rem;
}

.wiki-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.wiki-toolbar h1 {
    font-size: clamp(2rem, 4vw, 3.4rem);
}

.wiki-loading {
    display: grid;
    place-items: center;
    gap: 0.8rem;
    min-height: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
}

.loader {
    width: 3rem;
    height: 3rem;
    border: 3px solid rgba(255, 122, 0, 0.2);
    border-top-color: var(--primary);
    border-radius: 999px;
    animation: spin 0.9s linear infinite;
}

.wiki-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.85fr);
    gap: 1rem;
    align-items: start;
}

.wiki-main h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin: 2rem 0 0.8rem;
}

.wiki-main h2:first-child {
    margin-top: 0;
}

.wiki-main ul,
.wiki-main ol {
    padding-left: 1.35rem;
    color: var(--text-secondary);
}

.wiki-main li + li,
.wiki-side .side-card + .side-card {
    margin-top: 0.55rem;
}

.wiki-main img,
.inline-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem 0;
}

.image-rounded {
    border-radius: 1rem;
}

.image-circle {
    border-radius: 999px;
    aspect-ratio: 1;
    object-fit: cover;
}

.side-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem;
}

html[data-theme='light'] .side-card {
    background: rgba(255, 122, 0, 0.04);
}

.wiki-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}

.wiki-meta-row:last-child {
    border-bottom: 0;
}

.wiki-meta-key {
    color: var(--muted);
}

.wiki-meta-value {
    margin: 0;
    text-align: right;
    color: var(--text-primary);
}

.redacted {
    display: inline;
    color: var(--text-primary);
    background: var(--redacted);
    border-radius: 0.2rem;
    padding: 0 0.08rem;
    letter-spacing: 0.04em;
}

.note-text,
.field-hint,
.field-error {
    margin: 0;
    font-size: 0.92rem;
}

.field-error {
    color: var(--danger);
}

.note-text,
.field-hint {
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 15, 0.62);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 40;
}

.modal {
    width: min(100%, 34rem);
    padding: 1.3rem;
}

.modal-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-primary);
    cursor: pointer;
}

.modal-content {
    position: relative;
    z-index: 1;
}

.modal-content h2 {
    margin-top: 0;
    font-family: var(--font-display);
}

.stack-form {
    display: grid;
    gap: 0.9rem;
}

.field-group {
    display: grid;
    gap: 0.4rem;
}

.textarea-field {
    min-height: 9rem;
    resize: vertical;
}

.toast-wrap {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    gap: 0.6rem;
    z-index: 45;
}

.toast {
    min-width: 16rem;
    max-width: 24rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    box-shadow: var(--shadow-lg);
}

.toast.success {
    border-color: rgba(74, 222, 128, 0.25);
}

.toast.error {
    border-color: rgba(230, 57, 70, 0.28);
}

.site-footer {
    padding: 1rem 1.4rem 2rem;
    text-align: center;
}

[hidden] {
    display: none !important;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .site-header,
    .wiki-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions,
    .search-box {
        width: 100%;
        max-width: none;
    }

    .wiki-layout {
        grid-template-columns: 1fr;
    }
    article:first-child {
        order: 2;
    }
}

@media (max-width: 640px) {
    .site-main {
        width: min(100vw - 1rem, 100%);
        padding-top: 1.15rem;
    }

    .hero-copy h1,
    .wiki-toolbar h1 {
        max-width: none;
    }

    .hero-actions,
    .form-actions {
        flex-direction: column;
    }
}
