:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #eef2f3;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, select, input, textarea { font: inherit; }
.topbar {
  display: flex; justify-content: space-between; gap: 1.5rem; align-items: center;
  padding: 1rem 1.4rem; color: #fff; background: #143642; border-bottom: 4px solid #2f7d8a;
}
.topbar h1 { margin: .15rem 0; font-size: clamp(1.2rem, 2.2vw, 1.8rem); }
.topbar p { margin: .2rem 0; max-width: 70rem; }
.eyebrow { font-size: .78rem; font-weight: 800; letter-spacing: .08em; color: #bfe8e7; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; min-width: 24rem; }
button { border: 0; border-radius: .5rem; padding: .65rem .8rem; background: #087f8c; color: white; font-weight: 700; cursor: pointer; }
button.secondary { background: #52656d; }
button.danger { background: #8f3d3d; }
button:disabled { opacity: .42; cursor: not-allowed; }
.layout { display: grid; grid-template-columns: minmax(13rem, 19rem) minmax(30rem, 1fr) minmax(20rem, 28rem); gap: 1rem; padding: 1rem; min-height: calc(100vh - 10rem); }
.panel { min-width: 0; background: #fff; border: 1px solid #cbd5d8; border-radius: .8rem; padding: 1rem; box-shadow: 0 4px 14px rgba(20,54,66,.08); }
h2 { margin: 0 0 .7rem; font-size: 1.08rem; }
label { display: block; font-weight: 700; font-size: .9rem; }
select, input, textarea { width: 100%; border: 1px solid #9cabb0; border-radius: .45rem; background: #fff; color: #17202a; }
select, input { min-height: 2.7rem; padding: .5rem .6rem; }
textarea { padding: .85rem; resize: vertical; }
.document-panel { display: flex; flex-direction: column; }
.section-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.section-head p { margin: .1rem 0 .7rem; color: #526168; }
#documentText { flex: 1; min-height: 58vh; font-family: "Aptos", "Segoe UI", sans-serif; font-size: 1rem; line-height: 1.55; }
.badge { display: inline-block; padding: .35rem .55rem; border-radius: 99rem; font-size: .72rem; font-weight: 900; white-space: nowrap; background: #f1d0cf; color: #702c2b; }
.badge[data-state="ready"] { background: #cce9df; color: #195b47; }
.evidence, .guardrail { margin-top: 1rem; padding: .8rem; border-radius: .55rem; background: #edf6f6; overflow-wrap: anywhere; font-size: .86rem; }
.guardrail { background: #fff1d6; }
.guardrail p { margin-bottom: 0; }
.phrase-board { display: grid; gap: .75rem; }
.phrase-card { border: 1px solid #c9d3d6; border-left: 4px solid #2f7d8a; border-radius: .55rem; padding: .7rem; }
.phrase-card.proposal { border-left-color: #b06f24; }
.phrase-card header { display: flex; align-items: flex-start; gap: .55rem; }
.phrase-card header input { width: 1.15rem; min-height: 1.15rem; margin-top: .2rem; accent-color: #087f8c; }
.phrase-card .kind { display: block; margin-top: .15rem; font-size: .68rem; font-weight: 900; letter-spacing: .04em; color: #34656d; }
.phrase-card.proposal .kind { color: #8a5419; }
.phrase-preview { margin: .55rem 0 .2rem; padding: .5rem; border-radius: .35rem; background: #f3f6f7; font-size: .86rem; }
.param { margin-top: .5rem; font-size: .8rem; }
.param input { margin-top: .15rem; }
.source { margin: .55rem 0 0; font-size: .73rem; color: #59686e; overflow-wrap: anywhere; }
.provenance { margin-top: .7rem; border-top: 1px solid #d6dfe1; padding-top: .6rem; }
.provenance-item { padding: .45rem 0; border-bottom: 1px solid #e6ebec; font-size: .8rem; }
.provenance-item strong { display: block; }
.provenance-item[data-kind="new_proposal"] strong { color: #8a5419; }
.empty { color: #66767c; font-style: italic; }
#printOutput { display: none; white-space: pre-wrap; }
footer { padding: .75rem 1rem 1.2rem; text-align: center; color: #506066; font-size: .84rem; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 15rem 1fr; }
  .phrase-panel { grid-column: 1 / -1; }
  .phrase-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .actions { min-width: 0; justify-content: stretch; }
  .actions button { flex: 1 1 45%; min-height: 2.8rem; }
  .layout { grid-template-columns: 1fr; }
  .phrase-panel { grid-column: auto; }
  .phrase-board { grid-template-columns: 1fr; }
  #documentText { min-height: 55vh; }
}
@page { size: A4; margin: 1.5cm; }
@media print {
  html, body { background: #fff; min-height: 0; }
  .topbar, .situation-panel, .phrase-panel, footer,
  .document-panel > :not(#printOutput) { display: none !important; }
  .layout, .document-panel { display: block; margin: 0; padding: 0; min-height: 0; border: 0; box-shadow: none; }
  #printOutput { display: block; position: static; margin: 0; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #000; background: #fff; font: 11pt/1.45 Arial, sans-serif; }
}
