:root {
    color-scheme: light;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: #f3f5f8;
    color: #18263a;
    --brand: #123e70;
    --border: #dce3ed;
    --muted: #53657b;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, .button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem;
    padding: .55rem .9rem; border: 1px solid var(--border); border-radius: .45rem; color: var(--brand);
    background: white; cursor: pointer; text-decoration: none; font-weight: 600;
}
button:hover:not(:disabled), .button:hover { border-color: var(--brand); }
.primary { background: var(--brand); color: white; border-color: var(--brand); }
button:disabled { opacity: .52; cursor: default; }
input, select, textarea {
    min-width: 0; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: .45rem;
    background: white; color: inherit; width: 100%;
}
textarea { display: block; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus, button:focus-visible, summary:focus-visible, a:focus-visible {
    outline: 2px solid #2674c3; outline-offset: 2px;
}
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.35rem); line-height: 1.1; }
h2 { font-size: 1.2rem; }
.topbar {
    background: #122c49; color: white; min-height: 4.2rem; display: flex; padding: .75rem clamp(1rem, 3vw, 2.25rem);
    align-items: center; justify-content: space-between; gap: 1rem;
}
.wordmark { font-size: 1.5rem; font-weight: 750; letter-spacing: -.045em; }
.wordmark span { color: #52a7ed; }
.wordmark small { font-size: .9rem; font-weight: 500; letter-spacing: 0; margin-left: .7rem; }
.account, .inline { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.account { font-size: .9rem; }
.spread { justify-content: space-between; }
.inline > input { flex: 1 1 15rem; }
.inline > select { width: min(100%, 18rem); }
#app { display: grid; grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr); min-height: calc(100vh - 4.2rem); }
.sidebar { background: white; border-right: 1px solid var(--border); }
.sidebar-heading { padding: 1.35rem 1rem .8rem; display: grid; gap: .55rem; }
label, summary { font-weight: 650; }
.pages { padding: 0 .65rem 1rem; max-height: calc(100vh - 14rem); overflow: auto; }
.page-group { border-bottom: 1px solid var(--border); }
.page-group summary { padding: .72rem .55rem; color: var(--brand); }
.page-group summary:hover { background: #f1f5fa; border-radius: .4rem; }
.page-group summary::marker { color: var(--muted); }
.page-group[open] > .page-group-items { margin: 0 0 .45rem .45rem; padding-left: .45rem; border-left: 1px solid var(--border); }
.page {
    display: grid; width: 100%; text-align: left; justify-content: start; gap: .16rem;
    border-color: transparent; margin: .2rem 0; line-height: 1.3; overflow-wrap: anywhere;
}
.page[aria-current="true"] { background: #e8f1fb; border-color: #b5cfe9; }
.page small, .muted { color: var(--muted); font-size: .9rem; font-weight: 400; }
.workspace { width: min(100%, 73rem); padding: clamp(1rem, 4vw, 3rem); }
.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: end; margin-bottom: 1rem; }
#document-kind { color: var(--muted); margin-bottom: .4rem; }
.panel, .status {
    border: 1px solid var(--border); border-radius: .7rem;
    background: white; padding: 1.1rem; margin: .9rem 0; min-width: 0;
}
.status { background: #e8f1fb; }
.status.error { color: #912b27; background: #fff0ed; }
summary { cursor: pointer; }
form > *, details[open] > :not(summary), .actions { margin-top: .75rem; }
#fields, #history { display: grid; gap: .65rem; }
.field { display: grid; gap: .35rem; font-size: .95rem; }
.field[hidden] { display: none; }
.diff { border-bottom: 1px solid var(--border); padding: .75rem 0; }
.diff h3 { margin: 0 0 .5rem; font-size: 1rem; }
.diff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.diff-grid pre { margin: .3rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; font: inherit; }
.diff-grid > div { border-radius: .35rem; background: #f4f6fa; padding: .55rem; min-width: 0; }
.diff-grid > div:last-child { background: #eaf6ef; }
.version { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.version p { overflow-wrap: anywhere; margin: .35rem 0; }
.prompt-entry { white-space: pre-wrap; }
.login { width: min(90%, 26rem); margin: 13vh auto; padding: 2rem; border: 1px solid var(--border); border-radius: .9rem; background: white; display: grid; justify-items: start; gap: 1rem; }
dialog { width: min(92vw, 80rem); max-height: 92vh; border: 1px solid var(--border); border-radius: .7rem; padding: 1rem; color: inherit; }
dialog::backdrop { background: #142840a6; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
iframe { border: 1px solid var(--border); display: block; margin: .75rem auto 0; width: 100%; height: 70vh; }
.mobile-preview { width: min(100%, 390px); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .6rem; margin-top: .75rem; }
.media-grid img { width: 100%; height: 7rem; object-fit: contain; }
.media-grid strong { display: block; font-size: .9rem; overflow-wrap: anywhere; }
@media (max-width: 700px) {
    #app { display: block; }
    .sidebar { border: 0; border-bottom: 1px solid var(--border); }
    .pages { max-height: 12rem; }
    .account { gap: .25rem; }
    .account span, .wordmark small { display: none; }
    .diff-grid { grid-template-columns: 1fr; }
}
