:root {
    color-scheme: light;
    --page: #f2f7fd;
    --card: #fcfdff;
    --field: #edf3fb;
    --text: #102438;
    --muted: #506681;
    --line: #cbd9e8;
    --accent: #185db0;
    --on-accent: #fff;
    --soft: #daeaff;
    --on-soft: #113b68;
    --error: #a22a3a;
    --error-bg: #ffe1e6;
    --motion: cubic-bezier(.22, 0, .16, 1);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) { color-scheme: dark; --page: #101923; --card: #182532; --field: #1f3040; --text: #edf5ff; --muted: #afc2d6; --line: #344b60; --accent: #9ccaff; --on-accent: #082743; --soft: #263e57; --on-soft: #dfedff; --error: #ffb2bc; --error-bg: #5b2b36; }
}
:root[data-theme=dark] { color-scheme: dark; --page: #101923; --card: #182532; --field: #1f3040; --text: #edf5ff; --muted: #afc2d6; --line: #344b60; --accent: #9ccaff; --on-accent: #082743; --soft: #263e57; --on-soft: #dfedff; --error: #ffb2bc; --error-bg: #5b2b36; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--text); font: 1rem/1.5 system-ui, sans-serif; }
body, .surface, .rich, .status { transition: background-color 240ms ease, color 240ms ease, border-color 240ms ease; }
:where(#login, #catalog, #editor):not([hidden]) { animation: section-enter 340ms var(--motion) both; }
@keyframes section-enter {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 2.65rem); line-height: 1.08; letter-spacing: -.045em; }
h2 { font-size: 1.18rem; }
.shell { max-width: 72rem; margin: auto; padding: 1.25rem clamp(.85rem, 4vw, 2.5rem) 3rem; }
.brand { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; min-height: 64px; margin-bottom: 1.65rem; }
.brand img { border-radius: 15px; }
.brand strong { font-size: 1.22rem; }
.theme { margin-inline-start: auto; display: flex; align-items: center; gap: .38rem; }
.theme select { width: auto; }
.surface, dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 25px; }
.box, .login { padding: clamp(1rem, 3vw, 1.5rem); }
.login { max-width: 28rem; margin: 9vh auto 0; }
.login form, .box, .writing, .assets, .items { display: grid; gap: .9rem; }
.login form { margin-top: 1.25rem; }
label, legend { font-size: .91rem; font-weight: 650; }
label:not(.theme) > :is(input:not([type=radio]),textarea) { display: block; margin-top: .3rem; }
input:not([type=radio]), textarea, select, .rich { width: 100%; font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 15px; padding: .65rem .8rem; }
textarea { resize: vertical; }
button { font: inherit; font-weight: 680; line-height: 1.2; padding: .68rem .95rem; min-height: 40px; cursor: pointer; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 999px; }
button { transition: background-color 220ms var(--motion), color 220ms var(--motion), transform 170ms var(--motion), filter 170ms ease, box-shadow 220ms var(--motion); }
button:hover { filter: brightness(.94); }
button:active:not(:disabled) { transform: scale(.96); }
button:disabled { cursor: wait; opacity: .55; }
button.secondary, .tools button { color: var(--on-soft); background: var(--soft); }
button.danger { background: var(--error-bg); color: var(--error); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.view-title, .heading, .actions { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.view-title, .heading { justify-content: space-between; }
.view-title { margin-block: .5rem 1.15rem; }
.editor { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; gap: 1rem; }
.choices { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 1.4rem; }
fieldset { border: 0; padding: 0; margin: 0; }
.segments {
    position: relative;
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-top: .28rem;
    padding: 3px;
    border-radius: 999px;
    background: var(--field);
    isolation: isolate;
}
.segments::before {
    position: absolute;
    content: "";
    inset-block: 3px;
    inset-inline-start: 3px;
    width: calc((100% - 6px) / 2);
    border-radius: inherit;
    background: var(--accent);
    z-index: -1;
    transition: transform 310ms var(--motion), background-color 220ms ease;
}
.segments:has(label:nth-child(2) > input:checked)::before { transform: translateX(100%); }
.segments label { display: grid; position: relative; }
.segments input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segments span {
    cursor: pointer;
    padding: .44rem .75rem;
    border-radius: 999px;
    text-align: center;
    white-space: nowrap;
    color: var(--muted);
    transition: color 245ms var(--motion), transform 160ms var(--motion);
}
.segments span:active { transform: scale(.96); }
.segments input:checked + span { color: var(--on-accent); }
.segments input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.choice-panel {
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    transition: grid-template-rows 310ms var(--motion), opacity 235ms ease, transform 285ms var(--motion);
}
.choice-content { min-height: 0; overflow: hidden; padding: 4px; margin: -4px; }
.choice-panel.is-collapsed { grid-template-rows: 0fr; opacity: 0; transform: translateX(-5px); pointer-events: none; }
.counter { background: var(--field); border-radius: 999px; padding: .38rem .65rem; }
.tools { display: flex; flex-wrap: wrap; gap: .3rem; }
.tools button { padding: .42rem .64rem; min-height: 35px; font-size: .9rem; }
.tools button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.tools button[aria-pressed="mixed"] { box-shadow: inset 0 0 0 1px var(--accent); }
.rich { min-height: 12rem; overflow-wrap: anywhere; font-weight: 400; white-space: pre-wrap; }
.rich h3, .rich .description-title { font-size: 1.22rem; font-weight: 750; }
.rich .description-bold { font-weight: 700; }
.rich .description-mono { font-family: monospace; }
.rich .description-serif { font-family: serif; }
.file-name { overflow-wrap: anywhere; padding: .55rem .8rem; border-radius: 13px; background: var(--field); font-size: .94rem; }
.photos { display: grid; gap: .65rem; }
.photos:empty { display: none; }
.photo { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: .65rem; border-radius: 15px; padding: .5rem; background: var(--field); }
.photo img { width: 64px; height: 64px; object-fit: cover; border-radius: 11px; }
.photo span { overflow-wrap: anywhere; }
.photo .actions button { min-height: 34px; font-size: .85rem; padding: .34rem .58rem; }
.counter, .item .meta span { color: var(--muted); font-size: .88rem; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; padding: .85rem 1rem; }
.item .meta { flex: 1 1 12rem; display: grid; min-width: 0; overflow-wrap: anywhere; }
.publish { display: grid; gap: .5rem; }
progress { width: 100%; accent-color: var(--accent); }
.status { padding: .7rem 1rem; margin-bottom: .9rem; background: var(--soft); color: var(--on-soft); border-radius: 14px; }
.status.error { color: var(--error); background: var(--error-bg); }
dialog { padding: 1.35rem; max-width: min(28rem, calc(100vw - 2rem)); }
dialog::backdrop { background: #101b2a88; }
dialog form { display: grid; gap: .7rem; }
@media (max-width: 52rem) { .editor { grid-template-columns: 1fr; } }
@media (max-width: 26rem) { .theme { font-size: 0; gap: 0; } .theme select { font-size: .88rem; } }
@media (prefers-reduced-motion: reduce) {
    :where(#login, #catalog, #editor):not([hidden]) { animation: none; }
    body, .surface, .rich, .status, button, .segments::before, .segments span, .choice-panel { transition: none; }
}
