:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #172740;
  background: #f1f5fa;
  font-synthesis: none;
  --ink: #172740;
  --muted: #50627a;
  --primary: #1759c2;
  --primary-hover: #10479f;
  --line: #dce5f0;
  --surface: #fff;
  --surface-tint: #f4f8fe;
  --blue-tint: #eaf2ff;
  --danger: #a12732;
  --shadow: 0 14px 42px rgba(19, 49, 87, .07);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
p { margin: 0; line-height: 1.55; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: 1.18rem; font-weight: 700; }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled, input:disabled, textarea:disabled { cursor: default; }
:focus-visible { outline: 3px solid #2167db; outline-offset: 3px; }
.muted { color: var(--muted); font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip-link { position: fixed; z-index: 1; top: .7rem; left: .7rem; padding: .7rem 1rem; background: #fff; color: var(--primary); transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header-inner { max-width: 88rem; margin: auto; height: 4.25rem; padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand, .brand > span:last-child { display: flex; align-items: center; }
.brand { gap: .7rem; font-size: 1.1rem; font-weight: 760; letter-spacing: -.02em; white-space: nowrap; }
.brand-mark { width: 2.05rem; height: 2.05rem; background: #1557bd; border-radius: .62rem; display: grid; place-items: center; position: relative; flex: none; }
.brand-mark::after, .brand-mark::before { content: ""; position: absolute; border-radius: 1px; background: white; }
.brand-mark::after { width: 1rem; height: .25rem; }
.brand-mark::before { width: .25rem; height: 1rem; }
.brand-divider { height: 1.05rem; width: 1px; margin: 0 .72rem; background: #cbd7e6; }
.brand-subtitle { font-size: .875rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }

.button { min-height: 2.65rem; padding: .6rem .95rem; border: 1px solid transparent; border-radius: .65rem; font-size: .875rem; font-weight: 650; line-height: 1.2; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; white-space: nowrap; transition: background .15s ease, border-color .15s ease; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--primary-hover); }
.button-primary:disabled { background: #dce6f5; color: #576a85; }
.button-secondary { background: #fff; color: #164c9f; border-color: #c5d5ec; }
.button-secondary:hover:not(:disabled) { background: #f0f6ff; border-color: #91add6; }
.button-quiet { background: transparent; color: #3e526e; }
.button-quiet:hover:not(:disabled) { background: var(--surface-tint); }
.button-danger { color: var(--danger); background: #fff0f0; }
.button-danger:hover:not(:disabled) { background: #ffe0e0; }
.button:not(.button-primary):disabled { opacity: .65; }
.icon-plus, .icon-download { width: .95rem; height: .95rem; flex: none; position: relative; display: inline-block; }
.icon-plus::before, .icon-plus::after { content: ""; background: currentColor; position: absolute; border-radius: 1px; }
.icon-plus::before { width: .85rem; height: 2px; top: calc(50% - 1px); left: .05rem; }
.icon-plus::after { width: 2px; height: .85rem; left: calc(50% - 1px); top: .05rem; }
.icon-download { border-bottom: 2px solid currentColor; }
.icon-download::before { content: ""; width: 2px; height: .6rem; background: currentColor; display: block; margin: auto; }
.icon-download::after { content: ""; width: .39rem; height: .39rem; border: solid currentColor; border-width: 0 2px 2px 0; position: absolute; top: .23rem; left: .28rem; transform: rotate(45deg); }

label { display: block; font-size: .875rem; font-weight: 650; margin-bottom: .45rem; }
input:not([type="file"]), select, textarea { width: 100%; color: var(--ink); background: #fff; border: 1px solid #c7d4e4; padding: .67rem .8rem; border-radius: .65rem; outline-offset: 2px; }
input:not([type="file"]):disabled, textarea:disabled { background: #f6f8fb; color: #63738a; }
textarea { resize: vertical; line-height: 1.45; }
textarea::placeholder, input::placeholder { opacity: 1; color: #687991; }
select { appearance: none; padding-right: 2.4rem; background-image: linear-gradient(45deg, transparent 50%, #526985 50%), linear-gradient(135deg, #526985 50%, transparent 50%); background-position: right 1.05rem center, right .74rem center; background-size: 5px 5px; background-repeat: no-repeat; }
.form-error { color: var(--danger); font-size: .875rem; overflow-wrap: anywhere; }

.login-layout { width: min(61rem, calc(100% - 3rem)); margin: clamp(2.25rem, 8vh, 6rem) auto; display: grid; grid-template-columns: 1.15fr 1fr; border: 1px solid var(--line); border-radius: 1.45rem; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.login-cover { position: relative; min-height: 30rem; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: clamp(2rem, 4.8vw, 4.25rem); color: white; background: linear-gradient(145deg, #1b5bc4, #103471 70%); }
.login-cover-label { font-size: .875rem; color: #d7e6ff; font-weight: 650; margin-bottom: 1rem; }
.login-cover h1 { font-size: clamp(2.9rem, 5.4vw, 4.6rem); font-weight: 750; line-height: .99; letter-spacing: -.06em; }
.login-cover-copy { font-size: 1rem; margin-top: 1.3rem; max-width: 25ch; color: #dfecff; }
.cover-art { z-index: -1; position: absolute; pointer-events: none; width: 25rem; height: 25rem; top: -8.5rem; right: -6rem; transform: rotate(-30deg); }
.art-outline { border: 1px solid #81b1ff70; position: absolute; width: 100%; height: 100%; border-radius: 30%; }
.art-outline-first { inset: 0; }
.art-outline-second { inset: 1.9rem 0 0 -1.9rem; }
.art-outline-third { inset: 3.8rem 0 0 -3.8rem; }
.art-cross { position: absolute; top: 8rem; left: 7rem; width: 10.2rem; height: 10.2rem; background: #70a9ff34; border: 1px solid #a3c7ff67; border-radius: 2rem; transform: rotate(30deg); display: grid; place-items: center; }
.art-cross::before, .art-cross::after { content: ""; position: absolute; background: #a3c7ff48; border-radius: .25rem; }
.art-cross::before { width: 4.65rem; height: 1.3rem; }
.art-cross::after { width: 1.3rem; height: 4.65rem; }
.login-card { display: grid; align-content: center; padding: clamp(1.5rem, 5vw, 4rem); }
.login-card h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.login-card .muted { margin: .65rem 0 1.6rem; }
.login-card .form-error { margin-top: .65rem; }
.login-submit { width: 100%; margin-top: 1rem; min-height: 2.9rem; }

.workspace { max-width: 88rem; margin-inline: auto; padding: 2.15rem 2rem 2.75rem; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.workspace-heading h1 { font-size: clamp(1.95rem, 4vw, 2.78rem); font-weight: 750; line-height: 1.1; letter-spacing: -.055em; }
.workspace-heading p { margin-top: .55rem; color: var(--muted); }
.workspace-error { padding: .8rem 1rem; background: #fff1f1; border: 1px solid #f3d3d3; border-radius: .75rem; margin-bottom: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); min-width: 0; }
.source-panel { padding: .8rem; margin-bottom: 1.15rem; }
.drop-zone { display: flex; gap: 1.1rem; justify-content: space-between; align-items: center; background: #f7faff; border: 1px dashed #adc4e5; border-radius: .73rem; padding: .95rem 1rem; }
.drop-zone.is-dragging { background: #e5efff; border-color: #1e5cc1; }
.source-overview { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.source-overview .muted { margin-top: .25rem; }
.source-icon { width: 2.8rem; height: 2.8rem; display: grid; place-items: center; flex: none; border-radius: .75rem; background: #e5efff; color: #215eb8; }
.source-icon span { width: .98rem; height: 1.21rem; border: 1.5px solid currentColor; border-radius: .16rem; position: relative; }
.source-icon span::after { content: ""; width: .45rem; height: .24rem; position: absolute; border-block: 1px solid currentColor; top: .38rem; left: .18rem; }
.upload-progress { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.2rem; margin: .65rem .28rem 0; }
.upload-progress > div { min-width: 0; }
.file-name { font-size: .875rem; font-weight: 650; overflow-wrap: anywhere; }
.upload-progress progress { flex: 0 1 15rem; max-width: 40%; width: 15rem; height: .7rem; accent-color: var(--primary); border-radius: 1rem; }
.upload-error { margin: .7rem .3rem .15rem; }

.workspace-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.16fr); gap: 1.15rem; align-items: start; }
.panel-heading { padding: 1.12rem 1.25rem; display: flex; align-items: center; gap: .65rem 1rem; justify-content: space-between; min-height: 5.25rem; border-bottom: 1px solid var(--line); }
.panel-heading .muted { margin-top: .3rem; }
.chat-log { height: clamp(15.5rem, calc(100dvh - 29rem), 32rem); min-height: 15.5rem; padding: 1.25rem; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: .95rem; }
.chat-log:focus-visible, .draft-content:focus-visible { outline-offset: -3px; }
.chat-entry { max-width: 97%; align-self: flex-start; min-width: 0; border-radius: .9rem .9rem .9rem .18rem; padding: .72rem .88rem; color: var(--ink); background: var(--surface-tint); border: 1px solid #e4ecf8; }
.chat-entry-user { align-self: flex-end; background: var(--blue-tint); border-color: #d9e8ff; border-radius: .9rem .9rem .18rem .9rem; }
.chat-entry-label { color: #34547b; font-size: .8125rem; font-weight: 700; margin-bottom: .2rem; }
.chat-entry-copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-form { border-top: 1px solid var(--line); padding: 1rem 1.25rem 1.12rem; }
.chat-form textarea { display: block; min-height: 4.5rem; max-height: 15rem; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .75rem; }
.chat-form .form-error { margin-top: .65rem; }

.draft-content { padding: 1rem 1.25rem 1.25rem; min-height: clamp(25.9rem, calc(100dvh - 18.6rem), 42.4rem); max-height: clamp(25.9rem, calc(100dvh - 18.6rem), 42.4rem); overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; border-radius: 0 0 1rem 1rem; }
.draft-empty { display: grid; justify-items: center; align-content: center; min-height: 12rem; padding: 1.5rem 1.25rem; text-align: center; border: 1px dashed #c8d7eb; border-radius: .8rem; background: #fafcff; }
.draft-empty p { max-width: 40ch; margin-top: .5rem; }
.draft-empty .source-icon { margin-bottom: .95rem; }
.draft-empty h3 { font-size: 1rem; }
.issue { margin-bottom: .65rem; border: 1px solid #d3e1f2; background: #f3f8ff; border-radius: .65rem; color: #2b4a74; }
.issue-warn { color: #6c4b10; background: #fff9eb; border-color: #f1dfa9; }
.issue-conflict { color: #8d2634; background: #fff3f3; border-color: #f2ced2; }
.issue summary { padding: .62rem .82rem; font-size: .875rem; font-weight: 650; }
.issue ul { margin: 0; padding: 0 1rem .8rem 2.05rem; line-height: 1.45; font-size: .875rem; overflow-wrap: anywhere; }
.issue li + li { margin-top: .25rem; }
.fact-group { border: 1px solid var(--line); border-radius: .72rem; overflow: hidden; }
.fact-group + .fact-group { margin-top: .65rem; }
.fact-group > summary { padding: .72rem .88rem; font-size: .9375rem; font-weight: 680; background: #f5f8fd; overflow-wrap: anywhere; }
.fact-group[open] > summary { border-bottom: 1px solid var(--line); }
.group-count { color: var(--muted); font-size: .8125rem; font-weight: 550; margin-left: .5rem; white-space: nowrap; }
.fact-list { margin: 0; padding: 0 .87rem; list-style: none; }
.fact-row { padding: .8rem 0; }
.fact-row + .fact-row { border-top: 1px solid var(--line); }
.fact-row-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.fact-row-heading > div { min-width: 0; }
.fact-label { color: var(--muted); font-size: .875rem; font-weight: 620; }
.fact-value { margin-top: .18rem; line-height: 1.44; white-space: pre-wrap; overflow-wrap: anywhere; }
.edit-fact { min-height: 2.1rem; padding: .35rem .52rem; color: #1a59b0; }
.fact-evidence { color: var(--muted); margin-top: .35rem; font-size: .875rem; overflow-wrap: anywhere; }
.fact-evidence summary { width: fit-content; color: #365a87; padding: .2rem .12rem; }
.fact-evidence blockquote { color: #304967; margin: .35rem 0 0; border-left: 2px solid #8dadd9; padding: .38rem .65rem; background: #f6f9fe; white-space: pre-wrap; }
.fact-evidence p { margin-top: .25rem; font-size: .8125rem; }

dialog { max-height: calc(100dvh - 2rem); width: min(30rem, calc(100vw - 2rem)); overflow: auto; border: 1px solid #bdcde2; padding: 0; border-radius: 1rem; color: var(--ink); background: #fff; box-shadow: 0 18px 70px rgba(10, 36, 75, .2); }
dialog::backdrop { background: rgba(19, 40, 71, .46); }
.dialog-form { padding: 1.4rem; }
.dialog-form h2 { margin-bottom: 1.2rem; }
.dialog-form :is(select, input) { margin-bottom: .95rem; }
.dialog-form textarea { display: block; }
.dialog-form .form-error { margin-top: .5rem; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .45rem; margin-top: 1.1rem; }
.dialog-actions .button-danger { margin-right: auto; }

@media (max-width: 58rem) {
  .site-header-inner { padding-inline: 1.35rem; }
  .workspace { padding-inline: 1.35rem; }
  .workspace-columns { grid-template-columns: minmax(0, 1fr); }
  .chat-log { height: clamp(15.5rem, 37dvh, 27rem); }
  .draft-content { min-height: 0; max-height: none; overflow: visible; }
}

@media (max-width: 41rem) {
  .site-header-inner { height: 3.75rem; padding-inline: .95rem; }
  .brand { gap: .5rem; font-size: 1rem; }
  .brand-mark { width: 1.8rem; height: 1.8rem; }
  .brand-divider { margin-inline: .45rem; }
  .brand-subtitle { font-size: .8125rem; }
  .workspace { padding: 1.4rem .9rem 1.8rem; }
  .workspace-heading { align-items: flex-start; flex-direction: column; margin-bottom: 1rem; gap: .75rem; }
  .workspace-heading p { font-size: .9375rem; }
  .panel-heading, .chat-form, .chat-log, .draft-content { padding-inline: .9rem; }
  .draft-heading { align-items: flex-start; flex-wrap: wrap; }
  .drop-zone { align-items: flex-start; flex-direction: column; gap: .65rem; padding: .78rem; }
  .upload-progress { flex-wrap: wrap; }
  .upload-progress progress { flex-basis: 100%; max-width: 100%; }
  .source-icon { width: 2.4rem; height: 2.4rem; }
  .login-layout { width: calc(100% - 1.8rem); margin: 1.35rem auto; grid-template-columns: 1fr; border-radius: 1.05rem; }
  .login-cover { min-height: 15rem; padding: 1.6rem; }
  .login-cover-label { margin-bottom: .6rem; }
  .login-cover h1 { font-size: 3.05rem; }
  .login-cover-copy { margin-top: .8rem; }
  .cover-art { transform: rotate(-30deg) scale(.7); transform-origin: top right; top: -4rem; right: -5rem; }
  .login-card { padding: 1.7rem 1.6rem; }
}

@media (max-width: 23rem) {
  .brand-subtitle, .brand-divider { display: none; }
  .dialog-form { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
