:root {
    --bg: #120e0c;
    --panel: #1c1613;
    --panel-2: #271f1b;
    --line: #3c3029;
    --gold: #e0c17a;
    --gold-ink: #2a2112;
    --burgundy: #9a303c;
    --paper: #f3ead7;
    --paper-edge: #e4d5b8;
    --ink: #22170f;
    --muted: #8d7d70;
    --ok: #c8e6d2;
    --danger: #c4554d;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: #f3ead7;
    font-family: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

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

button { cursor: pointer; }

.top {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 64px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
    background: #181310;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 180px; }

.mark {
    width: 28px;
    height: 28px;
    background:
        linear-gradient(var(--burgundy), var(--burgundy)) top / 100% 10px no-repeat,
        linear-gradient(var(--gold), var(--gold)) center / 3px 16px no-repeat;
}

.name {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0.04em;
    line-height: 1;
}

.tag, .fine, .save-state {
    margin: 2px 0 0;
    color: var(--muted);
    font-family: "Segoe UI", sans-serif;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.save-state { margin: 0; flex: 1; }

.top-actions, .actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: #f6efe2;
    border-radius: 999px;
    padding: 8px 14px;
    font-family: "Segoe UI", sans-serif;
    font-size: 14px;
}

.btn:hover { border-color: var(--gold); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.gold {
    background: var(--gold);
    color: var(--gold-ink);
    border-color: var(--gold);
    font-weight: 650;
}

.btn.ghost { background: transparent; }

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

.btn.tiny { padding: 5px 10px; font-size: 13px; }

.banner {
    margin: 0;
    padding: 10px 18px;
    background: #3a2a18;
    color: var(--gold);
    font-family: "Segoe UI", sans-serif;
    font-size: 14px;
}

.banner button {
    margin-left: 10px;
    background: transparent;
    color: var(--gold);
    border: 0;
    text-decoration: underline;
}

.layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr) 320px;
    height: calc(100vh - 65px);
}

.panel {
    overflow: auto;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 16px;
}

.assistant { border-right: 0; border-left: 1px solid var(--line); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel h2,
.subhead {
    margin: 18px 0 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-family: "Segoe UI", sans-serif;
}

.panel h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-family: "Segoe UI", sans-serif;
}

.drop {
    margin-top: 14px;
    padding: 14px;
    border: 1px dashed #6d5a48;
    border-radius: 12px;
    text-align: center;
    background: #211a16;
}

.drop.over { border-color: var(--gold); background: #2a2218; }

.drop p { margin: 0 0 8px; font-size: 14px; }

.drop .btn { margin: 3px; }

.library { list-style: none; margin: 14px 0 0; padding: 0; }

.library li { margin: 0 0 6px; }

.library button.item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 10px;
    color: #f3ead7;
}

.library button.item strong { display: block; font-weight: 600; }

.library button.item span {
    display: block;
    color: var(--muted);
    font-family: "Segoe UI", sans-serif;
    font-size: 12px;
    margin-top: 2px;
}

.library button.item.active,
.library button.item:hover { border-color: var(--line); background: #241c18; }

.library .row { display: flex; gap: 4px; align-items: stretch; }

.library .del {
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    padding: 0 8px;
}

.library .del:hover { color: #ffd0cc; }

.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-family: "Segoe UI", sans-serif; font-size: 13px; color: var(--muted); }

.field input, .field select, .field textarea, #paste-text {
    width: 100%;
    background: #120e0c;
    color: #f6efe2;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
}

.field textarea { resize: vertical; min-height: 96px; line-height: 1.4; }

.split { display: grid; grid-template-columns: 1fr 90px; gap: 8px; }

.actions { margin-top: 14px; }

.actions .btn { width: 100%; }

.status {
    min-height: 1.3em;
    margin: 12px 0 0;
    font-family: "Segoe UI", sans-serif;
    font-size: 13px;
    color: var(--gold);
}

.models-note { margin-top: 16px; line-height: 1.45; }

.paper-wrap {
    overflow: auto;
    padding: 28px 18px 70px;
    background:
        radial-gradient(ellipse at top, #2a211c 0%, transparent 55%),
        #16110e;
}

.script {
    max-width: 760px;
    margin: 0 auto;
    background: var(--paper);
    color: var(--ink);
    color-scheme: light;
    padding: 42px 46px 70px;
    box-shadow: var(--shadow);
    min-height: calc(100vh - 140px);
}

.script.film { background: #f7f6f2; }

.script.film .scene-title { text-align: left; letter-spacing: 0.04em; }

.script.film .setting,
.script.film .line-prose textarea,
.script.film .line-replique textarea { text-align: left; }

.script.film .line-prose textarea { font-style: normal; }

.page-count {
    text-align: center;
    margin: 6px 0 0;
    font-family: "Segoe UI", sans-serif;
    font-size: 13px;
    color: #6d5c4e;
}

.script select.doc-kind {
    width: auto;
    margin: 10px auto 0;
    display: block;
    font-family: "Segoe UI", sans-serif;
    font-size: 13px;
    color: #6d5c4e;
}

.script input, .script textarea, .script select {
    background: transparent;
    color: var(--ink);
    border: 0;
    border-radius: 0;
    width: 100%;
}

.script input:focus, .script textarea:focus, .script select:focus {
    outline: none;
    background: rgba(154, 48, 60, 0.06);
}

.cover {
    display: block;
    width: min(100%, 420px);
    margin: 0 auto 18px;
    border-radius: 2px;
}

.title-input {
    text-align: center;
    font-size: 34px;
    line-height: 1.15;
    padding: 4px 8px;
}

.meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.meta-row input, .notes {
    text-align: center;
    font-style: italic;
    font-size: 16px;
}

.notes { margin-top: 8px; min-height: 32px; }

.rule {
    width: 34%;
    height: 2px;
    margin: 16px auto 18px;
    background: var(--burgundy);
    border: 0;
}

.cast-head, .act-title, .scene-title {
    text-align: center;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 13px;
}

.cast { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 18px; }

.person {
    min-width: 140px;
    max-width: 220px;
    padding: 6px 8px 8px;
    background: rgba(255, 255, 255, 0.35);
    border-top: 2px solid var(--burgundy);
}

.person input:first-child { font-weight: 700; text-align: center; letter-spacing: 0.04em; }

.person input:last-of-type { font-style: italic; font-size: 14px; text-align: center; color: #5c4d42; }

.person .tools, .line .tools, .scene-tools, .act-tools { display: flex; justify-content: center; gap: 4px; }

.script .tools button, .script .scene-tools button, .script .act-tools button, .script .text-btn {
    font-family: "Segoe UI", sans-serif;
    font-size: 12px;
    border: 1px solid #d9cbb3;
    background: transparent;
    color: #6d5c4e;
    border-radius: 999px;
    padding: 2px 8px;
}

.act { margin-top: 28px; }

.act-title { font-size: 18px; letter-spacing: 0.18em; font-weight: 700; }

.scene {
    margin-top: 18px;
    padding: 8px 8px 12px;
    border-left: 3px solid transparent;
}

.scene.active { border-left-color: var(--burgundy); }

.scene-title { font-weight: 700; }

.setting { text-align: center; font-style: italic; color: #5c4d42; min-height: 28px; }

.line { margin-top: 10px; }

.line-replique textarea { text-align: center; }

.who {
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.line-didascalie textarea, .line-prose textarea { font-style: italic; color: #4e4036; }

.line-didascalie textarea { text-align: center; }

.line .tools, .person .tools { opacity: 0; margin-top: 2px; }

.line:hover .tools, .line:focus-within .tools,
.person:hover .tools, .person:focus-within .tools,
.scene:hover .scene-tools, .act:hover .act-tools { opacity: 1; }

.script select.kind {
    width: auto;
    font-family: "Segoe UI", sans-serif;
    font-size: 12px;
    color: #6d5c4e;
    margin: 0 auto;
    display: block;
}

.source {
    margin-top: 28px;
    color: #5c4d42;
    font-family: "Segoe UI", sans-serif;
    font-size: 13px;
}

.source pre {
    white-space: pre-wrap;
    max-height: 240px;
    overflow: auto;
    background: rgba(255, 255, 255, 0.35);
    padding: 10px;
    font-size: 12px;
}

.text-btn { display: block; margin: 10px auto 0; }

dialog {
    border: 0;
    border-radius: 14px;
    padding: 0;
    background: var(--panel);
    color: #f3ead7;
    width: min(640px, calc(100vw - 24px));
    box-shadow: var(--shadow);
}

dialog form { padding: 18px; }

dialog h2 { margin: 0 0 8px; font-size: 22px; }

#paste-text { min-height: 220px; }

dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

body.busy .btn:disabled { }

@media (hover: none) {
    .line .tools, .person .tools, .scene-tools, .act-tools { opacity: 1; }
}

@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; height: auto; }
    .panel, .assistant { border: 0; border-top: 1px solid var(--line); }
    .script { padding: 28px 16px 48px; }
    .title-input { font-size: 28px; }
    .top { flex-wrap: wrap; }
}
