:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f5f7ff;
  --text: #1e1b4b;
  --muted: #3730a3;
  --accent: #312e81;
  --accent-text: #ffffff;
  --estimate-bg: #e0e7ff;
  --estimate-text: #1e1b4b;
  --border: #c7d2fe;
  --focus: #1e1b4b;
  --amber-text: #78350f;
  --amber-bg: #fffbeb;
  --amber-border: #b45309;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1024;
    --surface: #1c1d3a;
    --text: #f8f9ff;
    --muted: #c7d2fe;
    --accent: #a5b4fc;
    --accent-text: #1e1b4b;
    --estimate-bg: #312e81;
    --estimate-text: #e0e7ff;
    --border: #4338ca;
    --focus: #f8f9ff;
    --amber-text: #fef3c7;
    --amber-bg: #3b2f12;
    --amber-border: #fbbf24;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 "Iowan Old Style", Palatino, Georgia, serif;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

h1, h2 { line-height: 1.2; }

.eyebrow {
  margin: 0;
  color: var(--accent);
  font: 700 13px/1.2 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lede, .disclaimer, #basis, #meta, #status { color: var(--text); }

.upload, button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: 600 16px/1.2 system-ui, sans-serif;
}

input[type="file"] {
  display: block;
  margin-top: 12px;
  color: var(--text);
}

#result {
  margin-top: 24px;
  padding: 16px;
  border-radius: 16px;
  background: var(--estimate-bg);
  color: var(--estimate-text);
}

#range {
  margin: 8px 0;
  font-size: 32px;
  font-weight: 700;
}

#status:empty { display: none; }

[hidden] { display: none !important; }

:focus-visible,
button:hover,
.upload:hover,
.side-link:hover,
.topnav a:hover,
.brand:hover {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

#status.is-error {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--amber-border);
  border-radius: 12px;
  background: var(--amber-bg);
  color: var(--amber-text);
}

.topbar,
.sidebar,
.desk-only,
.drop-hint { display: none; }

.app-shell,
.intro,
.columns,
.capture,
.reading { display: contents; }

@media (min-width: 768px) {
  .topbar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  .topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 24px;
    width: min(1200px, 100%);
    min-height: 64px;
    margin: 0 auto;
    padding: 8px 24px;
  }

  .brand {
    color: var(--accent);
    font: 700 20px/1.2 system-ui, sans-serif;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
  }

  .topnav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--text);
    font: 600 15px/1.2 system-ui, sans-serif;
    text-underline-offset: 3px;
  }

  .skip {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .skip:focus {
    position: absolute;
    left: 16px;
    top: 12px;
    width: auto;
    height: auto;
    clip-path: none;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-text);
    font: 600 15px/1.2 system-ui, sans-serif;
    z-index: 3;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 24px 24px 64px;
  }

  .sidebar {
    display: grid;
    grid-template-columns: minmax(160px, auto) minmax(0, 1fr);
    gap: 8px 28px;
    align-items: center;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
  }

  .side-count {
    margin: 4px 0;
    color: var(--accent);
    font: 700 40px/1 system-ui, sans-serif;
  }

  .side-copy,
  #side-line { margin: 8px 0 0; }

  .side-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-text);
    font: 600 16px/1.2 system-ui, sans-serif;
    text-decoration: none;
  }

  main {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .intro,
  .capture,
  .reading { display: block; }

  .intro .eyebrow { display: none; }

  .intro h1 {
    margin: 0 0 8px;
    font-size: 40px;
  }

  .lede { max-width: 42rem; }

  .columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 8px;
  }

  .workspace { min-width: 0; }

  .capture form { display: grid; }

  .drop-hint {
    display: block;
    margin-top: 8px;
    font: 600 15px/1.3 system-ui, sans-serif;
  }

  .upload {
    display: flex;
    grid-area: 1 / 1;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 232px;
    padding-bottom: 68px;
    border-width: 2px;
    border-style: dashed;
    background: var(--surface);
    color: var(--text);
    text-align: center;
  }

  .upload.is-drag {
    background: var(--estimate-bg);
    color: var(--estimate-text);
  }

  #submit {
    justify-content: center;
    width: 100%;
  }

  input[type="file"] {
    grid-area: 1 / 1;
    align-self: end;
    justify-self: center;
    z-index: 1;
    max-width: calc(100% - 24px);
    margin: 0 0 22px;
  }

  .desk-only { display: block; }

  #reading-empty {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
  }

  #result {
    margin-top: 0;
    border: 1px solid var(--border);
  }

  #meta { display: none; }

  .facts dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    margin: 16px 0;
  }

  .facts .span { grid-column: 1 / -1; }

  .facts dt {
    margin: 0;
    color: var(--muted);
    font: 700 12px/1.2 system-ui, sans-serif;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .facts dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
  }

  #preview-wrap {
    margin: 16px 0 0;
  }

  #preview {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
  }

  #preview-wrap figcaption {
    margin-top: 6px;
    font: 600 13px/1.3 system-ui, sans-serif;
  }

  #melt-section,
  #recent { margin-top: 28px; }

  .table-scroll {
    max-width: 100%;
    overflow-x: auto;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font: 15px/1.4 system-ui, sans-serif;
  }

  caption {
    margin: 0 0 10px;
    caption-side: top;
    text-align: left;
    font: 700 22px/1.3 system-ui, sans-serif;
  }

  th,
  td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
  }

  th {
    font: 700 13px/1.3 system-ui, sans-serif;
  }

  .num { text-align: right; font-variant-numeric: tabular-nums; }

  tfoot th { font-size: 15px; }

  .footnote,
  #melt-basis,
  #melt-composition {
    max-width: 70rem;
  }

  #melt-composition { margin: 0 0 8px; font-weight: 700; }
}

@media (min-width: 1024px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
    padding: 28px 32px 72px;
  }

  .sidebar {
    display: block;
    position: sticky;
    top: 92px;
  }

  .columns {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 24px;
  }

  .topbar-inner { padding: 8px 32px; }
}

.hinge-gutter { display: none; }

@media (min-width: 768px) {
  html[data-posture="book"] .columns {
    grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
    gap: 0;
  }

  html[data-posture="book"] .hinge-gutter {
    display: block;
    width: 48px;
    min-height: 48px;
    justify-self: center;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

@media (min-width: 1280px) {
  .app-shell { width: min(1200px, 100%); }
}

.try-foot{
  box-sizing:border-box;
  width:100%;
  max-width:1200px;
  margin:0 auto;
  padding:8px 20px 28px;
}
.try-foot a{
  color:var(--text);
  font:600 15px/1.45 system-ui,sans-serif;
  text-decoration:underline;
  text-underline-offset:3px;
  overflow-wrap:anywhere;
}
.try-foot .biz-address,.try-foot .biz-mail{display:block;margin-top:8px;color:var(--text);font:600 15px/1.5 system-ui,sans-serif}
.try-foot .biz-mail a{color:inherit}
