:root {
  color-scheme: light;
  --navy: #081c3d;
  --blue: #174f9b;
  --blue-light: #2d74cb;
  --paper: #f8f3df;
  --panel: #d9e4ef;
  --line: #7e98b4;
  --ink: #152236;
  --muted: #52647b;
  --alarm: #f4bc35;
  --danger: #bd2845;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  padding: clamp(0px, 2vw, 24px);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(71, 147, 220, .72), transparent 26rem),
    repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 1px, transparent 1px 10px),
    #07182d;
  font: 14px/1.45 Tahoma, "Segoe UI", Arial, sans-serif;
}

button, select, input { font: inherit; }
button, select { min-height: 42px; }
button { touch-action: manipulation; }

.app-shell {
  width: min(1180px, 100%);
  min-height: calc(100dvh - clamp(0px, 4vw, 48px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #07182d;
  border-radius: 10px;
  background: #f3f6f9;
  box-shadow: 0 26px 80px rgba(0,0,0,.5), inset 0 0 0 1px #fff;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 7px 12px;
  color: #fff;
  background: linear-gradient(#367fd2, #134583);
  border-bottom: 1px solid #0c315d;
}
.app-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 4px;
  background: #fff2;
  font-size: 21px;
}
.title-copy { min-width: 0; flex: 1; }
.title-copy h1 { margin: 0; font-size: 15px; letter-spacing: .04em; }
.title-copy p { margin: 1px 0 0; color: #dbeaff; font-size: 11px; }
.desktop-link { color: #fff; text-underline-offset: 3px; }

.menubar {
  display: flex;
  gap: 22px;
  padding: 5px 12px;
  color: #24384f;
  background: #e8eef4;
  border-bottom: 1px solid #a8bacd;
  font-size: 12px;
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: clamp(18px, 4vw, 38px);
  color: #fff;
  background:
    radial-gradient(circle at 82% 10%, rgba(244,188,53,.26), transparent 15rem),
    linear-gradient(125deg, #0b244c, #1b5ba4 65%, #123666);
}
.intro > div:first-child { max-width: 740px; }
.eyebrow { margin: 0 0 5px; color: #54708f; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.intro .eyebrow { color: #a9cfff; }
.intro h2 { margin: 0 0 8px; font-size: clamp(25px, 4vw, 44px); line-height: 1.05; letter-spacing: -.035em; }
.intro p:last-child { margin: 0; color: #d9e9fa; font-size: clamp(14px, 2vw, 17px); }
.seal {
  display: grid;
  place-items: center;
  flex: 0 0 126px;
  width: 126px;
  height: 126px;
  border: 3px double #f4cc64;
  border-radius: 50%;
  color: #ffe5a1;
  text-align: center;
  transform: rotate(7deg);
  box-shadow: inset 0 0 0 5px rgba(244,204,100,.13);
}
.seal span { display: block; margin-bottom: -32px; font-size: 38px; font-weight: 900; }
.seal small { align-self: end; margin-bottom: 23px; font-size: 9px; font-weight: 800; letter-spacing: .13em; }

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 350px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}
.control-panel { display: flex; flex-direction: column; gap: 14px; }
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px;
  border: 1px solid #9db0c4;
  border-radius: 5px;
  background: #e8eef4;
  box-shadow: inset 0 0 0 1px #fff;
}
legend { padding: 0 6px; color: #253d58; font-weight: 800; }
label { color: #3b5068; font-size: 12px; font-weight: 700; }
select {
  width: 100%;
  padding: 8px 34px 8px 10px;
  border: 1px solid #7691ad;
  border-radius: 3px;
  color: #18283c;
  background: #fff;
}
select + label { margin-top: 5px; }
.range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.range-head output { color: #164f91; font-size: 12px; font-weight: 800; }
input[type="range"] { width: 100%; accent-color: #1a5aa5; }
.range-scale { display: flex; justify-content: space-between; color: #6c7c8e; font-size: 10px; }
.generate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid #9c6914;
  border-radius: 5px;
  color: #2c210b;
  background: linear-gradient(#ffd96d, #efb32d);
  box-shadow: inset 0 0 0 1px #fff4b6, 0 3px 0 #9a6815;
  font-weight: 900;
  cursor: pointer;
}
.generate-button:hover { background: linear-gradient(#ffe698, #f3bd43); }
.generate-button:active { transform: translateY(2px); box-shadow: inset 0 0 0 1px #fff4b6, 0 1px 0 #9a6815; }
.shortcut { margin: 0; color: var(--muted); text-align: center; font-size: 11px; }
kbd { padding: 1px 4px; border: 1px solid #a4b0bc; border-bottom-width: 2px; border-radius: 3px; background: #fff; font-size: 10px; }

.result-panel { min-width: 0; }
.result-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.result-toolbar h2 { margin: 0; font-size: 21px; }
.result-actions { display: flex; gap: 7px; }
.result-actions button {
  padding: 7px 12px;
  border: 1px solid #7891aa;
  border-radius: 4px;
  background: linear-gradient(#fff, #dce6f0);
  color: #1f334a;
  cursor: pointer;
}
.result-actions button:hover { border-color: #2b6caf; background: linear-gradient(#fff, #cfe1f3); }

.fax-paper {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  padding: clamp(24px, 5vw, 48px);
  color: #20201e;
  background: var(--paper);
  border: 1px solid #c6bea1;
  box-shadow: 0 8px 22px rgba(20,35,51,.2), inset 0 0 45px rgba(128,116,75,.08);
  font: 15px/1.6 "Courier New", monospace;
}
.fax-paper:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #f0a51c; outline-offset: 2px; }
.fax-noise { position: absolute; inset: 0; pointer-events: none; opacity: .12; background: repeating-linear-gradient(0deg, #fff 0 2px, #504d42 3px, #fff 4px); mix-blend-mode: multiply; }
.fax-header { position: relative; display: flex; justify-content: space-between; gap: 20px; }
.fax-logo { font-size: clamp(25px, 4vw, 42px); font-weight: 900; letter-spacing: -.09em; }
.fax-meta { display: grid; gap: 2px; text-align: right; font-size: 10px; line-height: 1.35; }
.fax-rule { position: relative; margin: 12px 0 22px; border-top: 5px double #272722; }
.fax-date { text-align: right; font-size: 12px; }
.alibi-copy { min-height: 6.5em; font-weight: 700; }
.fax-signature { display: inline-grid; gap: 2px; margin: 15px 0 22px; padding-top: 6px; border-top: 1px solid #555348; }
.fax-signature span { font-size: 10px; }
.fax-paper footer { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding-top: 12px; border-top: 1px dashed #777264; font-size: 10px; }
.fax-stamp { padding: 4px 8px; border: 3px solid #8f2636; color: #8f2636; font: 900 16px/1 Arial, sans-serif; letter-spacing: .08em; transform: rotate(-5deg); }

.liability-meter { margin-top: 14px; padding: 13px 14px; border: 1px solid #a4b5c7; border-radius: 5px; background: #e6edf4; }
.meter-copy { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 8px; font-size: 11px; }
.meter-copy strong { color: #9c2439; text-align: right; }
.meter-track { height: 14px; overflow: hidden; border: 1px solid #7c8c9b; background: linear-gradient(90deg, #59bd76, #f0cc48 50%, #d44b60); box-shadow: inset 0 1px 3px #2335; }
.meter-track span { display: block; width: 54%; height: 100%; border-right: 4px solid #141f2d; background: rgba(255,255,255,.58); transition: width .28s ease; }
.liability-meter p { margin: 8px 0 0; color: #516174; font-size: 11px; }
.status { min-height: 1.4em; margin: 8px 0 0; color: #1e5b39; font-size: 12px; font-weight: 700; }

body.embedded { padding: 0; background: #07182d; }
.embedded .app-shell { width: 100%; min-height: 100dvh; border: 0; border-radius: 0; }
.embedded .desktop-link { display: none; }

@media (max-width: 820px) {
  body { padding: 0; }
  .app-shell { min-height: 100dvh; border: 0; border-radius: 0; }
  .workspace { grid-template-columns: 1fr; }
  .desktop-link, .seal { display: none; }
  .intro { padding: 22px 18px; }
  .intro h2 { font-size: 30px; }
}
@media (max-width: 540px) {
  .titlebar { min-height: 46px; }
  .title-copy p, .menubar { display: none; }
  .workspace { padding: 12px; }
  .result-toolbar { align-items: stretch; flex-direction: column; }
  .result-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .fax-paper { min-height: 420px; padding: 24px 18px; font-size: 13px; }
  .fax-header { flex-direction: column; }
  .fax-meta { text-align: left; }
  .fax-paper footer { align-items: flex-start; flex-direction: column; }
  .meter-copy { flex-direction: column; }
  .meter-copy strong { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .generate-button:active { transform: none; }
}

@media print {
  @page { margin: .55in; }
  body { padding: 0; background: #fff; }
  .titlebar, .menubar, .intro, .control-panel, .result-toolbar, .liability-meter, .status { display: none !important; }
  .app-shell, .workspace, .result-panel { display: block; width: auto; min-height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; }
  .fax-paper { min-height: 0; padding: 0; border: 0; box-shadow: none; background: #fff; break-inside: avoid; }
  .fax-noise { display: none; }
}
