:root {
    font-family: Segoe UI, Arial, sans-serif;
    color: #253b36;
    background: #f5f4ef;
    --green: #24594d;
    --muted: #78837a;
    --line: #dddeda;
    --paper: #fdfcf8
}

* {
    box-sizing: border-box
}

body {
    margin: 0
}

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

button {
    cursor: pointer;
    border: 0
}

button:disabled {
    opacity: .55;
    cursor: wait
}

h1,
h2,
h3,
.brand {
    font-family: Georgia, serif;
    font-weight: 400
}

h1 {
    font-size: 48px;
    line-height: 1.1;
    margin: 0 0 18px
}

h2 {
    font-size: 29px
}

h3 {
    font-size: 23px
}

p {
    margin-top: 0
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 254px;
    background: #153f36;
    color: #e9eee5;
    padding: 35px 25px;
    display: flex;
    flex-direction: column
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 25px;
    text-decoration: none
}

.brand-mark {
    font-size: 43px;
    color: #d3ba7d
}

.brand small {
    display: block;
    font: 8px Segoe UI;
    letter-spacing: 2px;
    margin-top: 8px;
    color: #aebfb1
}

.workspace-label {
    font-size: 10px;
    color: #a3b7a7;
    letter-spacing: 1.8px;
    margin: 57px 0 18px
}

.new-story {
    border: 1px solid #668073;
    color: #eef0e9;
    background: #ffffff07;
    padding: 13px;
    text-align: left;
    border-radius: 5px;
    width: 100%;
    font-size: 13px
}

#stories {
    overflow: auto;
    margin-top: 20px
}

.story-link {
    background: none;
    text-align: left;
    color: #b8cec2;
    width: 100%;
    padding: 13px 12px;
    border-radius: 5px;
    margin-bottom: 5px;
    font-size: 13px
}

.story-link.active {
    background: #ffffff12;
    color: #fff
}

.story-link small {
    display: block;
    font-size: 10px;
    opacity: .65;
    margin: 6px 0 0 20px
}

.sidebar-bottom {
    margin-top: auto
}

.sidebar-bottom p {
    font: italic 14px/1.6 Georgia;
    color: #9cb4a5;
    margin-top: 26px
}

.save-indicator {
    font-size: 10px;
    color: #acc3b2;
    margin-bottom: 20px
}

.save-indicator span {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #b8cf9f;
    border-radius: 50%;
    margin-right: 7px
}

.quiet {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 12px
}

main {
    margin-left: 254px
}

header {
    height: 86px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 48px;
    font-size: 12px;
    color: #78837a
}

header span {
    padding: 0 13px;
    color: #afb7ae
}

.credits-display {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 7px 12px 7px 8px;
    border: 1px solid #ccd5c8;
    border-radius: 999px;
    background: linear-gradient(135deg, #f1f6ed, #e5eee1);
    color: #344b3d;
    box-shadow: 0 2px 7px #24594d14;
}

.credits-display svg { display: block; flex-shrink: 0; }
.credits-divider { width: 1px; height: 19px; background: #bdcdbd; }
.credits-display strong { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .3px; }

#app {
    max-width: 1200px;
    margin: auto;
    padding: 22px 48px 70px
}

.eyebrow {
    font-size: 10px;
    letter-spacing: 2px;
    color: #8a906b;
    margin-bottom: 15px;
    font-weight: 600
}

.intro,
.hint {
    color: #788178;
    font-size: 13px;
    line-height: 1.7
}

.intro {
    max-width: 590px
}

.hero {
    display: grid;
    grid-template-columns: 1fr 270px;
    gap: 28px;
    align-items: center;
    margin-bottom: 38px
}

.landscape {
    height: 195px;
    position: relative;
    overflow: hidden;
    border: 1px solid #deded1;
    background: #e0e6d4;
    border-radius: 100px 100px 4px 4px
}

.sun {
    position: absolute;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: #d2b976;
    top: 28px;
    right: 53px
}

.mountain {
    position: absolute;
    inset: 55px -10px -5px;
    background: #aab7a0;
    clip-path: polygon(0 100%, 0 80%, 28% 12%, 51% 63%, 69% 28%, 100% 86%, 100% 100%)
}

.mountain.near {
    inset: 95px -10px -5px;
    background: #4f7864
}

.steps,
.tabs {
    display: flex;
    gap: 22px;
    margin: 30px 0 34px;
    border-bottom: 1px solid var(--line);
    font-size: 12px
}

.step,
.tab {
    padding: 0 0 16px;
    color: #93998e;
    background: none
}

.step.active,
.tab.active {
    color: var(--green);
    border-bottom: 2px solid var(--green)
}

.step b {
    background: #e5e8dc;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: 8px;
    font-size: 10px
}

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 29px;
    margin-bottom: 22px
}

.section-head,
.story-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 15px;
    margin-bottom: 23px
}

.tag {
    font-size: 9px;
    letter-spacing: 1px;
    color: #8b937c;
    border: 1px solid #e1e3d8;
    border-radius: 4px;
    padding: 6px 8px
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 9px
}

label small {
    color: #929a8e;
    font-weight: 400;
    margin-left: 6px
}

input,
textarea,
select {
    width: 100%;
    background: #fffefb;
    color: #293f36;
    border: 1px solid #d9ddd2;
    border-radius: 5px;
    padding: 12px 13px;
    font-size: 13px
}

textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.7
}

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

.full {
    grid-column: 1/-1
}

.genre-options {
    display: flex;
    gap: 9px;
    flex-wrap: wrap
}

.genre,
.secondary {
    background: transparent;
    border: 1px solid #ccd5c8;
    border-radius: 5px;
    padding: 11px 17px;
    color: var(--green);
    font-size: 12px
}

.genre.selected {
    background: #eaf0e5
}

.field {
    margin-bottom: 20px
}

.lore-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 26px
}

.lore-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px
}

.lore-tab {
    background: transparent;
    text-align: left;
    padding: 12px;
    color: #7d877a
}

.lore-tab.selected {
    background: #eaf0e5;
    color: var(--green)
}

.footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 28px
}

.primary {
    background: var(--green);
    color: #fffdf0;
    border-radius: 5px;
    padding: 13px 23px;
    font-size: 12px
}

.dashed {
    border: 1px dashed #b8c6b5;
    border-radius: 5px;
    width: 100%;
    background: transparent;
    padding: 14px;
    color: #54725c
}

.field-heading {
    display: flex;
    justify-content: space-between
}

.remove {
    background: none;
    color: #8d9288;
    font-size: 20px
}

.story-heading h1 {
    font-size: 39px;
    margin-bottom: 8px
}

.play-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 22px
}

.chat {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden
}

.chat-head {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    font-size: 12px
}

.messages {
    height: 410px;
    overflow: auto;
    padding: 25px
}

.message {
    margin-bottom: 26px
}

.speaker {
    font-size: 9px;
    letter-spacing: 1.5px;
    color: #5e7f66;
    margin-bottom: 10px
}

.prose {
    font: 17px/1.8 Georgia;
    overflow-wrap: anywhere
}

.prose p {
    margin: 0 0 16px
}

.prose p:last-child {
    margin-bottom: 0
}

.prose h1,
.prose h2,
.prose h3 {
    font-size: 22px;
    margin: 22px 0 8px
}

.prose blockquote {
    margin: 14px 0;
    padding: 4px 15px;
    border-left: 3px solid #b8c8ad;
    color: #5c6e62;
    font-style: italic
}

.prose ul,
.prose ol {
    margin: 10px 0 16px;
    padding-left: 24px
}

.prose code,
.format-bar code {
    background: #e8ece2;
    border-radius: 3px;
    padding: 1px 4px;
    font: 11px Consolas, monospace
}

.prose a {
    color: #28634f
}

.message.user {
    background: #eef0e8;
    border-radius: 5px;
    padding: 17px
}

.message.user .prose {
    font: 13px/1.7 Segoe UI
}

.composer {
    padding: 18px;
    border-top: 1px solid var(--line);
    background: #f9f9f3
}

.format-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #d9ddd2;
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    background: #f0f3ea;
    padding: 5px 7px
}

.format-bar button {
    width: 27px;
    height: 26px;
    background: transparent;
    border-radius: 3px;
    color: #466a59
}

.format-bar span {
    font-size: 10px;
    color: #788477;
    margin-left: 6px
}

.rich-editor {
    min-height: 94px;
    border: 1px solid #d9ddd2;
    border-radius: 0 0 5px 5px;
    background: #fffefb;
    padding: 12px 13px;
    font-size: 13px;
    line-height: 1.7;
    outline: none
}

.rich-editor:focus {
    outline: 2px solid #91b1a0;
    border-color: transparent
}

.rich-editor:empty:before {
    content: attr(data-placeholder);
    color: #a1a79b
}

.rich-editor blockquote {
    margin: 6px 0;
    padding-left: 10px;
    border-left: 3px solid #a8c0a9
}

.composer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 11px;
    font-size: 10px;
    color: var(--muted)
}

.empty {
    text-align: center;
    padding: 55px 12px
}

.avatar {
    background: #e8ecdf;
    color: #5e7961;
    font: 26px Georgia;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin-bottom: 15px
}

.stat {
    border-bottom: 1px solid #eaebe1;
    padding: 10px 0;
    font-size: 12px;
    white-space: pre-wrap
}

.notice {
    padding: 12px 15px;
    background: #eeecdc;
    color: #80744e;
    font-size: 11px;
    line-height: 1.7;
    border-radius: 4px;
    margin-bottom: 20px
}

.memory {
    border-bottom: 1px solid var(--line);
    padding: 18px 0
}

.summary {
    white-space: pre-wrap;
    font: 16px/1.8 Georgia;
    color: #4c6255
}

.characters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px
}

.world-story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px
}

.world-story-tile {
    aspect-ratio: 1;
    min-height: 230px;
    margin: 0;
    display: flex;
    flex-direction: column;
    padding: 22px
}

.world-story-title {
    display: flex;
    align-items: start;
    gap: 8px
}

.world-story-title h3 {
    flex: 1;
    font-family: Segoe UI, Arial, sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
    margin: 0
}

.story-pencil {
    color: var(--green);
    font-size: 20px;
    line-height: 1
}

.world-story-open {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: start;
    justify-content: end;
    gap: 8px;
    padding: 12px 0 0;
    background: none;
    color: inherit;
    text-align: left;
    font-size: 14px
}

.world-story-open:hover,
.world-story-open:focus-visible {
    color: var(--green)
}

.error {
    color: #943d36;
    font-size: 13px;
    margin-top: 12px
}

#toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #183f36;
    color: white;
    padding: 13px 24px;
    border-radius: 7px;
    font-size: 13px;
    display: none;
    z-index: 4
}

dialog {
    width: 490px;
    max-width: 90vw;
    padding: 30px;
    border: 1px solid #d3d9ca;
    border-radius: 9px;
    background: var(--paper)
}

dialog::backdrop {
    background: #122e2866
}

.ai-settings-tabs {
    margin: 12px 0 24px;
    gap: 0;
    font-size: 14px
}

.ai-settings-tabs .tab {
    flex: 1;
    padding: 12px 16px
}

.ai-settings-panel[hidden] {
    display: none
}

pre {
    white-space: pre-wrap;
    background: #e9eddf;
    padding: 14px;
    font-size: 12px
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px
}

.busy {
    font-size: 12px;
    color: #6e805e;
    padding: 0 24px 15px
}

@media(max-width:1100px) {
    .sidebar {
        width: 218px;
        padding: 30px 20px
    }

    main {
        margin-left: 218px
    }

    #app {
        padding: 32px 28px
    }

    header {
        padding: 0 28px
    }

    .play-grid {
        grid-template-columns: 1fr
    }

    .play-side {
        display: none
    }
}

@media(max-width:750px) {
    .sidebar {
        position: relative;
        width: auto;
        padding: 17px 20px;
        display: block
    }

    .sidebar-bottom,
    .workspace-label,
    .brand small {
        display: none
    }

    .new-story {
        position: absolute;
        right: 20px;
        top: 20px;
        width: auto
    }

    #stories {
        display: flex;
        gap: 10px;
        max-height: 80px
    }

    .story-link {
        width: auto;
        min-width: 120px
    }

    main {
        margin-left: 0
    }

    header {
        height: 58px;
        padding: 0 20px
    }

    #app {
        padding: 30px 20px
    }

    .hero,
    .grid,
    .characters,
    .lore-layout {
        grid-template-columns: 1fr
    }

    .landscape {
        display: none
    }

    h1 {
        font-size: 39px
    }

    .lore-tabs {
        flex-direction: row;
        overflow: auto
    }

    .lore-tab {
        white-space: nowrap
    }

    .messages {
        height: 380px;
        padding: 18px
    }

    .format-bar span {
        display: none
    }
}
