:root {
    color-scheme: dark;
    --bg: #0b0f10;
    --bg-deep: #070a0b;
    --panel: rgba(20, 27, 28, 0.92);
    --panel-solid: #141b1c;
    --panel-raised: #1a2324;
    --panel-soft: #101617;
    --line: #2b393a;
    --line-soft: rgba(95, 183, 168, 0.16);
    --ink: #e9e3d4;
    --ink-soft: #c6c0b2;
    --muted: #869591;
    --muted-2: #61706c;
    --gold: #d8ab62;
    --gold-soft: rgba(216, 171, 98, 0.15);
    --teal: #62b9aa;
    --teal-soft: rgba(98, 185, 170, 0.12);
    --red: #d87968;
    --red-soft: rgba(216, 121, 104, 0.14);
    --blue: #7ba7c9;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
    --sans: "Noto Sans SC", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% -10%, rgba(216, 171, 98, 0.12), transparent 34rem),
        radial-gradient(circle at 92% 8%, rgba(98, 185, 170, 0.09), transparent 30rem),
        radial-gradient(circle at 50% 120%, rgba(40, 68, 67, 0.35), transparent 48rem),
        var(--bg-deep);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
    background-size: 42px 42px, 42px 42px;
    mask-image: radial-gradient(circle at 50% 20%, black, transparent 75%);
    z-index: 0;
}

.grain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 20px 18px;
    gap: 14px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 58px;
    padding: 0 4px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    text-decoration: none;
    color: var(--ink);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(216, 171, 98, 0.48);
    border-radius: 50%;
    color: var(--gold);
    font-family: var(--serif);
    font-size: 23px;
    line-height: 1;
    background:
        radial-gradient(circle at 50% 38%, rgba(216, 171, 98, 0.18), transparent 64%),
        var(--panel-soft);
    box-shadow: 0 0 0 4px rgba(216, 171, 98, 0.04);
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.eyebrow {
    margin: 0;
    color: var(--gold);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.16em;
    line-height: 1.4;
    text-transform: uppercase;
}

.brand-title {
    font-family: var(--serif);
    font-size: 21px;
    letter-spacing: 0.12em;
    line-height: 1.15;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.04em;
}

.connection {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 10px rgba(98, 185, 170, 0.8);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(16, 22, 23, 0.72);
    white-space: nowrap;
}

.status-pill.is-live {
    color: var(--teal);
    border-color: rgba(98, 185, 170, 0.38);
    background: var(--teal-soft);
}

.status-pill.is-idle {
    color: var(--muted);
}

.status-pill.is-off {
    color: var(--red);
    border-color: rgba(216, 121, 104, 0.35);
    background: var(--red-soft);
}

.version {
    color: var(--muted-2);
}

.nav-link {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.05em;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--gold);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink-soft);
    background: transparent;
    font-family: var(--mono);
    font-size: 13px;
    transition: 140ms ease;
}

.icon-btn:hover {
    color: var(--gold);
    border-color: rgba(216, 171, 98, 0.55);
    background: var(--gold-soft);
}

/* ---------------------------------------------------------------- layout */

.layout {
    display: grid;
    grid-template-columns: minmax(240px, 286px) minmax(380px, 1fr) minmax(270px, 324px);
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.panel,
.console {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 16%),
        var(--panel);
    box-shadow: var(--shadow);
    min-height: 0;
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-heading,
.console-head,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.panel-heading,
.console-head {
    padding: 16px 17px 13px;
    border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.console-head h2,
.section-head h2,
.modal-head h2 {
    margin: 2px 0 0;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.panel-actions {
    display: flex;
    gap: 5px;
}

.mini-btn,
.text-btn {
    padding: 0;
    border: 0;
    color: var(--gold);
    background: transparent;
    font-size: 11px;
    letter-spacing: 0.04em;
}

.mini-btn {
    padding: 4px 7px;
    border: 1px solid rgba(216, 171, 98, 0.28);
    border-radius: 5px;
}

.mini-btn:hover,
.text-btn:hover {
    background: var(--gold-soft);
}

.text-btn {
    color: var(--teal);
    font-family: var(--mono);
    font-size: 10px;
}

/* ------------------------------------------------------------- character */

.character-panel {
    overflow-y: auto;
}

.character-view {
    padding: 16px 17px 20px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 30px 16px;
    text-align: center;
    color: var(--muted);
}

.empty-sigil {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-bottom: 13px;
    border: 1px dashed rgba(216, 171, 98, 0.4);
    border-radius: 50%;
    color: var(--gold);
    font-family: var(--serif);
    font-size: 25px;
}

.empty-state p {
    margin: 3px 0;
}

.empty-state .muted {
    max-width: 205px;
    color: var(--muted-2);
    font-size: 11px;
}

.character-head {
    padding-bottom: 13px;
    border-bottom: 1px solid var(--line-soft);
}

.char-name {
    margin: 0;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 23px;
    letter-spacing: 0.08em;
    line-height: 1.2;
}

.char-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
    margin-top: 7px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.char-meta .occupation {
    color: var(--gold);
}

.vitals {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 16px;
}

.vital-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.08em;
}

.vital-line b {
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
}

.bar {
    height: 5px;
    overflow: hidden;
    border-radius: 99px;
    background: #0a0f0f;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--teal), #8dd2c5);
    transition: width 350ms ease;
}

.bar-fill.hp {
    background: linear-gradient(90deg, #b8554a, var(--red));
}

.bar-fill.mp {
    background: linear-gradient(90deg, #4f7892, var(--blue));
}

.bar-fill.san {
    background: linear-gradient(90deg, #8c6e3e, var(--gold));
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 16px;
}

.stat {
    padding: 8px 5px;
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    background: rgba(8, 12, 12, 0.34);
    text-align: center;
}

.stat-key {
    display: block;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.08em;
}

.stat-value {
    display: block;
    margin-top: 1px;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 16px;
}

.derived-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    margin-top: 10px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
}

.derived-row b {
    color: var(--ink-soft);
    font-weight: 500;
}

.skill-block {
    margin-top: 15px;
}

.skill-block-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 7px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
}

.skill-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 265px;
    overflow-y: auto;
    padding-right: 4px;
}

.skill-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--ink-soft);
    font-size: 12px;
}

.skill-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.018);
}

.skill-row .skill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.skill-row .skill-value {
    color: var(--gold);
    font-family: var(--mono);
    font-size: 11px;
}

.skill-empty {
    padding: 8px 6px;
    color: var(--muted-2);
    font-size: 11px;
}

/* --------------------------------------------------------------- console */

.console {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.console-head {
    align-items: center;
}

.console-indicators {
    display: flex;
    gap: 6px;
}

.indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.06em;
}

.indicator .dot {
    width: 4px;
    height: 4px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 13px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 22px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: min(88%, 780px);
    animation: rise 180ms ease both;
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message.bot,
.message.system,
.message.error {
    align-self: flex-start;
}

.message-meta {
    margin-bottom: 4px;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.message-body {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 3px 10px 10px 10px;
    color: var(--ink-soft);
    background: var(--panel-soft);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message.user .message-body {
    border-color: rgba(216, 171, 98, 0.35);
    border-radius: 10px 3px 10px 10px;
    color: #1a1712;
    background: linear-gradient(135deg, #d8ab62, #c7954e);
    font-weight: 500;
}

.message.bot .message-body {
    border-left: 2px solid var(--teal);
    background: linear-gradient(180deg, rgba(98, 185, 170, 0.055), transparent), var(--panel-soft);
}

.message.system {
    align-self: center;
    max-width: 80%;
    text-align: center;
}

.message.system .message-body {
    padding: 5px 10px;
    border-color: transparent;
    border-radius: 99px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
    font-family: var(--mono);
    font-size: 9px;
}

.message.error .message-body {
    border-color: rgba(216, 121, 104, 0.38);
    border-left: 2px solid var(--red);
    color: #e5b7ad;
    background: var(--red-soft);
}

.message .dice-line {
    color: var(--gold);
    font-family: var(--mono);
}

.typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 3px 10px 10px 10px;
    background: var(--panel-soft);
}

.typing i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--teal);
    animation: blink 1.1s infinite ease-in-out;
}

.typing i:nth-child(2) {
    animation-delay: 0.14s;
}

.typing i:nth-child(3) {
    animation-delay: 0.28s;
}

.quick-commands {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 20px 10px;
}

.chip {
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 99px;
    color: var(--muted);
    background: transparent;
    font-family: var(--mono);
    font-size: 9px;
    transition: 130ms ease;
}

.chip:hover {
    color: var(--gold);
    border-color: rgba(216, 171, 98, 0.4);
    background: var(--gold-soft);
}

.command-bar {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 20px;
    padding: 8px 9px 8px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(7, 11, 11, 0.72);
    transition: 150ms ease;
}

.command-bar:focus-within {
    border-color: rgba(216, 171, 98, 0.55);
    box-shadow: 0 0 0 3px rgba(216, 171, 98, 0.07);
}

.prompt-mark {
    color: var(--gold);
    font-family: var(--mono);
    font-size: 20px;
    line-height: 1;
}

.command-bar input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-family: var(--mono);
    font-size: 13px;
}

.command-bar input::placeholder {
    color: var(--muted-2);
}

.send-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border: 1px solid rgba(216, 171, 98, 0.5);
    border-radius: 5px;
    color: #17130e;
    background: var(--gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    transition: 130ms ease;
}

.send-btn:hover {
    background: #e4bb79;
}

.send-btn:disabled {
    cursor: wait;
    opacity: 0.55;
}

.console-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 13px;
    padding: 8px 22px 12px;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.04em;
}

/* ------------------------------------------------------------- right panel */

.right-panel {
    overflow-y: auto;
}

.side-section {
    flex-shrink: 0;
    padding: 15px 16px;
    border-bottom: 1px solid var(--line-soft);
}

.side-section:last-child {
    border-bottom: 0;
}

.side-section.grow {
    min-height: 150px;
}

.section-head {
    align-items: center;
    margin-bottom: 10px;
}

.section-head h2 {
    font-size: 14px;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.06em;
}

.tag.live {
    color: var(--teal);
    border-color: rgba(98, 185, 170, 0.35);
}

.tag.off {
    color: var(--red);
    border-color: rgba(216, 121, 104, 0.35);
}

.journal-card {
    padding: 10px 11px;
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    background: rgba(8, 12, 12, 0.32);
}

.journal-empty {
    color: var(--muted-2);
    font-size: 11px;
    line-height: 1.6;
}

.journal-session {
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: 15px;
    letter-spacing: 0.05em;
}

.journal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    margin-top: 5px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
}

.journal-file {
    margin-top: 6px;
    overflow: hidden;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.button-row {
    display: flex;
    gap: 6px;
    margin-top: 9px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid rgba(216, 171, 98, 0.5);
    border-radius: 5px;
    color: #17130e;
    background: var(--gold);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    transition: 130ms ease;
}

.button:hover {
    background: #e4bb79;
}

.button.ghost {
    color: var(--ink-soft);
    border-color: var(--line);
    background: transparent;
}

.button.ghost:hover {
    border-color: rgba(216, 171, 98, 0.4);
    color: var(--gold);
    background: var(--gold-soft);
}

.button.small {
    flex: 1;
    padding: 6px 9px;
    font-size: 10px;
}

.button[aria-disabled="true"] {
    pointer-events: none;
    opacity: 0.36;
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 235px;
    overflow-y: auto;
    padding-right: 3px;
}

.event-item {
    display: grid;
    grid-template-columns: 21px minmax(0, 1fr);
    gap: 7px;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.028);
}

.event-icon {
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--gold);
    font-family: var(--mono);
    font-size: 9px;
}

.event-main {
    min-width: 0;
}

.event-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    color: var(--ink-soft);
    font-size: 10px;
}

.event-time {
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 8px;
    white-space: nowrap;
}

.event-text {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 1px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.library-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 175px;
    overflow-y: auto;
}

.library-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    padding: 5px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.025);
}

.library-info {
    min-width: 0;
}

.library-name {
    display: block;
    overflow: hidden;
    color: var(--ink-soft);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-meta {
    display: block;
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 8px;
}

.library-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.library-empty {
    padding: 4px;
    color: var(--muted-2);
    font-size: 10px;
}

/* ------------------------------------------------------------------ modal */

.modal {
    width: min(500px, calc(100vw - 28px));
    padding: 0;
    border: 1px solid rgba(216, 171, 98, 0.28);
    border-radius: 11px;
    color: var(--ink);
    background: var(--panel-solid);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.modal::backdrop {
    background: rgba(3, 6, 6, 0.74);
    backdrop-filter: blur(4px);
}

.modal-card {
    padding: 20px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.modal-head h2 {
    font-size: 22px;
}

.modal-lede {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
}

.field > span,
.check-field {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.04em;
}

.field > span b {
    color: var(--gold);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 105px;
    gap: 10px;
}

.field input {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    outline: 0;
    color: var(--ink);
    background: var(--panel-soft);
    font-family: var(--mono);
    font-size: 12px;
}

.field input:focus {
    border-color: rgba(216, 171, 98, 0.55);
    box-shadow: 0 0 0 3px rgba(216, 171, 98, 0.07);
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.segmented label {
    display: block;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-soft);
    transition: 130ms ease;
}

.segmented b {
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 500;
}

.segmented small {
    color: var(--muted-2);
    font-family: var(--mono);
    font-size: 8px;
}

.segmented input:checked + span {
    border-color: rgba(216, 171, 98, 0.55);
    background: var(--gold-soft);
}

.segmented input:checked + span b {
    color: var(--gold);
}

.check-field {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin: 4px 0 3px;
    line-height: 1.5;
}

.check-field input {
    margin-top: 2px;
    accent-color: var(--gold);
}

.check-field code {
    color: var(--gold);
    font-family: var(--mono);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 145px;
    padding: 16px;
    border: 1px dashed rgba(216, 171, 98, 0.38);
    border-radius: 7px;
    color: var(--muted);
    background: rgba(8, 12, 12, 0.28);
    cursor: pointer;
    text-align: center;
    transition: 130ms ease;
}

.drop-zone.dragging,
.drop-zone:hover {
    border-color: rgba(216, 171, 98, 0.65);
    background: var(--gold-soft);
}

.drop-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.drop-icon {
    color: var(--gold);
    font-family: var(--mono);
    font-size: 26px;
    line-height: 1;
}

.drop-zone b {
    margin-top: 7px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 500;
}

.drop-zone small {
    color: var(--muted-2);
    font-size: 9px;
}

.file-name {
    margin-top: 7px;
    color: var(--teal);
    font-family: var(--mono);
    font-size: 9px;
}

/* ------------------------------------------------------------------ toast */

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 18px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-width: min(360px, calc(100vw - 40px));
}

.toast {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-left: 2px solid var(--teal);
    border-radius: 5px;
    color: var(--ink-soft);
    background: var(--panel-solid);
    box-shadow: var(--shadow);
    font-size: 11px;
    animation: slide-in 180ms ease both;
}

.toast.error {
    border-left-color: var(--red);
    color: #e5b7ad;
}

.toast.success {
    border-left-color: var(--teal);
}

.noscript,
.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 30px;
    text-align: center;
}

.not-found h1 {
    margin: 8px 0;
    color: var(--gold);
    font-family: var(--serif);
    font-size: 74px;
    font-weight: 500;
}

.not-found p {
    margin: 4px 0 18px;
    color: var(--muted);
}

/* --------------------------------------------------------------- scrollbar */

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 99px;
    background: rgba(134, 149, 145, 0.28);
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(216, 171, 98, 0.4);
    background-clip: padding-box;
}

/* --------------------------------------------------------------- animation */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0%,
    70%,
    100% {
        opacity: 0.28;
        transform: translateY(0);
    }
    35% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
    .layout {
        grid-template-columns: minmax(220px, 250px) minmax(340px, 1fr) minmax(240px, 285px);
    }

    .topbar-right .connection {
        display: none;
    }
}

@media (max-width: 980px) {
    body {
        overflow: auto;
    }

    .app-shell {
        height: auto;
        min-height: 100%;
        padding: 12px;
    }

    .layout {
        grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
        grid-template-rows: minmax(560px, 68vh) auto;
        min-height: 0;
    }

    .right-panel {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .side-section {
        border-right: 1px solid var(--line-soft);
    }

    .side-section:nth-child(2n) {
        border-right: 0;
    }

    .side-section.grow {
        min-height: 0;
    }
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
    }

    .topbar-right {
        gap: 7px;
    }

    .topbar-right .version,
    .topbar-right .status-pill {
        display: none;
    }

    .layout {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .character-panel {
        max-height: 360px;
    }

    .console {
        min-height: 64vh;
    }

    .right-panel {
        display: flex;
        flex-direction: column;
    }

    .side-section {
        border-right: 0;
    }

    .messages {
        padding: 16px;
    }

    .quick-commands {
        padding: 0 14px 9px;
    }

    .command-bar {
        margin: 0 14px;
    }

    .console-hint {
        padding: 8px 16px 11px;
    }

    .message {
        max-width: 94%;
    }

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