@font-face {
  font-family: "Patrick Hand Local";
  src: url("./assets/patrick-hand.ttf") format("truetype");
  font-display: swap;
}

:root {
  --mist: #e9f4f6;
  --paper: #fbfefe;
  --ink: #142e39;
  --muted: #52707a;
  --rule: #b7d3d9;
  --blue: #2458e6;
  --coral: #f05b45;
  --shadow: 0 24px 70px rgba(25, 66, 78, 0.13);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--mist);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, transparent 0 7.5%, rgba(36, 88, 230, 0.08) 7.5% calc(7.5% + 1px), transparent calc(7.5% + 1px)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(20, 46, 57, 0.035) 31px 32px),
    var(--mist);
}

button, input { font: inherit; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.masthead {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
  letter-spacing: -0.055em;
  font-size: 1.2rem;
}

.wordmark small,
.section-label,
.eyebrow,
.ticket-kicker,
.input-rule {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.wordmark small {
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.runtime-state {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(240, 91, 69, 0.13);
}

.runtime-state[data-state="ready"] .state-dot { background: #168665; box-shadow: 0 0 0 5px rgba(22, 134, 101, 0.12); }
.runtime-state[data-state="error"] .state-dot { background: #b42318; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: clamp(40px, 8vw, 110px);
  align-items: end;
  padding: clamp(68px, 10vw, 124px) 0 76px;
}

.eyebrow, .section-label {
  margin: 0 0 15px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(3.5rem, 8vw, 7.4rem);
  line-height: 0.84;
  letter-spacing: -0.075em;
  font-weight: 860;
}

h1 span {
  position: relative;
  display: inline-block;
  color: var(--blue);
  font-family: "Patrick Hand Local", cursive;
  font-weight: 400;
  letter-spacing: -0.035em;
  transform: rotate(-1.5deg);
}

h1 span::after {
  content: "";
  position: absolute;
  left: 2%;
  right: -2%;
  bottom: -4px;
  height: 5px;
  background: var(--coral);
  border-radius: 70% 30% 60% 40%;
  transform: rotate(0.7deg);
}

.lede {
  max-width: 650px;
  margin: 36px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: 1.65;
}

.model-ticket {
  position: relative;
  padding: 24px 25px 22px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 11px 11px 0 var(--coral);
  transform: rotate(1.2deg);
}

.model-ticket::before,
.model-ticket::after {
  content: "";
  position: absolute;
  left: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--mist);
}
.model-ticket::before { top: 30%; }
.model-ticket::after { top: 67%; }

.ticket-kicker { font-size: 0.58rem; color: #a9c4cc; }
.model-ticket > strong { display: block; margin-top: 12px; font-size: 3.8rem; line-height: 1; letter-spacing: -0.08em; }
.model-ticket > strong span { font-size: 1.3rem; margin-left: 3px; }
.model-ticket > span:not(.ticket-kicker) { color: #bcd0d5; font-size: 0.8rem; }
.model-ticket dl { margin: 25px 0 0; border-top: 1px dashed #58707a; }
.model-ticket dl div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed #405a64; font: 0.66rem/1.2 ui-monospace, monospace; }
.model-ticket dt { color: #a9c4cc; }
.model-ticket dd { margin: 0; }

.workbench {
  margin-bottom: 55px;
  padding: clamp(25px, 5vw, 58px);
  background: var(--paper);
  border: 1px solid rgba(20, 46, 57, 0.12);
  box-shadow: var(--shadow);
}

.workbench-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 30px;
}

.workbench h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.5rem); letter-spacing: -0.045em; }
.input-rule { margin: 0 0 4px; color: var(--muted); font-size: 0.61rem; }

.drop-zone {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 112px;
  padding: 22px 26px;
  border: 2px dashed var(--rule);
  background: #f3fafb;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone[data-drag="true"] { border-color: var(--blue); background: #edf3ff; transform: translateY(-2px); }
.drop-zone:focus-within { outline: 3px solid rgba(36, 88, 230, 0.28); outline-offset: 3px; }

.drop-index { font: 700 0.64rem/1 ui-monospace, monospace; color: var(--coral); }
.drop-copy { display: flex; flex-direction: column; gap: 4px; }
.drop-copy strong { font-size: 1.05rem; }
.drop-copy small { color: var(--muted); }
.file-mark { display: flex; align-items: end; gap: 4px; height: 30px; }
.file-mark i { display: block; width: 3px; background: var(--blue); border-radius: 3px; }
.file-mark i:nth-child(1) { height: 14px; }
.file-mark i:nth-child(2) { height: 30px; }
.file-mark i:nth-child(3) { height: 21px; }

.line-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
  margin-top: 20px;
  padding: 34px;
  overflow: hidden;
  background: repeating-linear-gradient(0deg, #fff 0 39px, #dfecef 39px 40px);
  border-left: 3px solid rgba(240, 91, 69, 0.55);
}

.empty-line { text-align: center; color: #78919a; }
.empty-line span { font: 2.8rem/1 "Patrick Hand Local", cursive; color: #9cb4bb; }
.empty-line p { margin: 8px 0 0; font-size: 0.84rem; }
#line-preview { display: none; width: 100%; max-height: 160px; object-fit: contain; }
.line-stage[data-state="image"] #line-preview,
.line-stage[data-state="processing"] #line-preview { display: block; }
.line-stage:not([data-state="empty"]) .empty-line { display: none; }
.scan-rule { display: none; position: absolute; top: 0; bottom: 0; width: 3px; background: var(--blue); box-shadow: 0 0 22px 8px rgba(36, 88, 230, 0.28); }
.line-stage[data-state="processing"] .scan-rule { display: block; animation: scan 1.15s ease-in-out infinite alternate; }

@keyframes scan { from { left: 2%; } to { left: calc(98% - 3px); } }

.result-panel {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 30px;
  margin-top: 20px;
  padding: 30px 0 24px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}

.result-heading { display: flex; gap: 20px; }
.result-heading .section-label { margin-bottom: 6px; }
.result-status { margin: 0; color: var(--muted); font-size: 0.74rem; }
.result-text { min-height: 76px; font: 2rem/1.35 "Patrick Hand Local", cursive; color: var(--ink); overflow-wrap: anywhere; }
.result-text[data-state="empty"] { color: #a7b9be; }
.result-text[data-state="error"] { color: #b42318; font: 600 0.95rem/1.5 ui-sans-serif, system-ui; }

.measurements {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 30px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.measurements div { padding: 17px 18px; background: #f4fafa; }
.measurements span { display: block; color: var(--muted); font: 0.62rem/1.2 ui-monospace, monospace; text-transform: uppercase; letter-spacing: 0.07em; }
.measurements strong { display: block; margin-top: 6px; font-size: 0.92rem; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  padding: 26px 0 44px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}
footer p { margin: 0; max-width: 560px; }
footer a { color: inherit; text-underline-offset: 0.18em; }
footer a:hover { color: var(--ink); }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 680px); }
  .masthead { min-height: 76px; }
  .runtime-state { max-width: 180px; text-align: right; }
  .hero { grid-template-columns: 1fr; padding: 64px 0 60px; }
  .model-ticket { width: min(260px, calc(100% - 12px)); justify-self: end; }
  .workbench-heading, footer { align-items: start; flex-direction: column; }
  .workbench-heading { display: flex; }
  .drop-zone { grid-template-columns: 34px 1fr auto; padding-inline: 17px; }
  .line-stage { min-height: 150px; padding: 20px; }
  .result-panel { grid-template-columns: 1fr; }
  .measurements { grid-template-columns: 1fr; }
  footer { display: flex; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
