@font-face { font-family: 'Saira Condensed'; font-weight: 400; font-display: swap; src: url(../assets/fonts/saira-condensed-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-weight: 500; font-display: swap; src: url(../assets/fonts/saira-condensed-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-weight: 700; font-display: swap; src: url(../assets/fonts/saira-condensed-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-weight: 800; font-display: swap; src: url(../assets/fonts/saira-condensed-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Crimson Pro'; font-weight: 500; font-display: swap; src: url(../assets/fonts/crimson-pro-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Crimson Pro'; font-weight: 700; font-display: swap; src: url(../assets/fonts/crimson-pro-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Crimson Pro'; font-style: italic; font-weight: 500; font-display: swap; src: url(../assets/fonts/crimson-pro-latin-500-italic.woff2) format('woff2'); }
@font-face { font-family: 'Crimson Pro'; font-style: italic; font-weight: 700; font-display: swap; src: url(../assets/fonts/crimson-pro-latin-700-italic.woff2) format('woff2'); }
@font-face { font-family: 'IASymbols'; font-display: block; src: url(../assets/fonts/ia-symbols.ttf) format('truetype'); }

:root {
  --sys: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --head: 'Saira Condensed', "Arial Narrow", var(--sys);
  --red: #b8232e;
  --red-2: #d8333f;
  --navy: #121726;
  --navy-2: #1d2438;
  --steel: #8b94a7;
  --bg: #e7e9ee;
  --panel: #ffffff;
  --panel-2: #f3f4f7;
  --line: #c8cdd7;
  --text: #171b26;
  --muted: #5a6274;
  --chip: #ffffff;
  --chip-on: var(--navy);
  --chip-on-text: #fff;
  --shadow: 0 1px 2px rgba(10, 14, 25, .08), 0 4px 14px rgba(10, 14, 25, .06);
  --cut: 12px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b0e17;
  --panel: #151a29;
  --panel-2: #1b2133;
  --line: #2b3349;
  --text: #e4e7ef;
  --muted: #9aa3b8;
  --chip: #1b2133;
  --chip-on: var(--red);
  --chip-on-text: #fff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 var(--sys);
  color: var(--text);
  background: var(--bg);
  background-image: linear-gradient(rgba(127, 137, 160, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(127, 137, 160, .07) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--red); }
h1, h2, h3 { font-family: var(--head); font-weight: 700; line-height: 1.1; letter-spacing: .02em; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #eef0f5; border-bottom: 3px solid var(--red); }
.top-inner { display: flex; align-items: center; gap: 12px; max-width: 1200px; margin: 0 auto; padding: 10px 14px 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; background: url(../assets/icon.svg) center/contain no-repeat; font-size: 0; }
.brand-text { font-family: var(--head); font-weight: 700; font-size: 1.3rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-small { display: block; font-size: .62rem; letter-spacing: .3em; color: var(--steel); line-height: 1; }
.brand-tag { color: var(--red-2); }
.icon-btn { background: transparent; border: 1px solid rgba(255, 255, 255, .2); color: inherit; border-radius: 8px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); }
.tabs { display: flex; gap: 2px; max-width: 1200px; margin: 0 auto; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; color: #b9c0d0; text-decoration: none; font-family: var(--head); font-weight: 700; font-size: 1.05rem; letter-spacing: .06em; text-transform: uppercase; padding: 8px 14px 9px; white-space: nowrap; }
.tabs a:hover { color: #fff; }
.tabs a.on { color: #fff; }
.tabs a.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 4px; background: var(--red-2); clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 100%, 0 100%); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--red); color: #fff; font: 700 .75rem/20px var(--sys); text-align: center; letter-spacing: 0; vertical-align: 2px; }

main { max-width: 1200px; margin: 0 auto; padding: 16px 14px 96px; outline: none; }

/* Panels with a clipped corner, like the card frames */
.panel { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut))); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.eyebrow { font-family: var(--head); font-size: .78rem; font-weight: 700; letter-spacing: .25em; text-transform: uppercase; color: var(--red); margin-bottom: 2px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 14px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-family: var(--head); font-weight: 700; font-size: 1rem; letter-spacing: .05em; text-transform: uppercase; cursor: pointer; text-decoration: none; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px)); }
.btn:hover { border-color: var(--steel); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-2); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 32px; font-size: .88rem; padding: 3px 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Filters */
.filters { display: grid; gap: 10px; }
.search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 0; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-label { font-family: var(--head); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; color: var(--muted); min-width: 64px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--chip); padding: 4px 10px; min-height: 34px; font-size: .9rem; cursor: pointer; border-radius: 17px; }
.chip.on { background: var(--chip-on); color: var(--chip-on-text); border-color: var(--chip-on); }
.chip .sym { font-family: IASymbols; font-size: 1.05rem; line-height: 1; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--red); }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }

/* Card grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.tile { position: relative; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tile.in-queue { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.tile-img { display: block; width: 100%; aspect-ratio: 56 / 87; background: #0c0f18; border: 0; padding: 0; cursor: zoom-in; overflow: hidden; }
.tile-img.mini { aspect-ratio: 56 / 87; }
.tile-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-body { padding: 6px 8px 8px; display: grid; gap: 6px; flex: 1; align-content: space-between; }
.tile-name { font-family: var(--head); font-weight: 700; font-size: 1rem; line-height: 1.1; }
.tile-meta { display: flex; gap: 4px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }
.tag { border: 1px solid var(--line); padding: 0 5px; white-space: nowrap; }
.tag.old { border-color: #b88b23; color: #9a6f0f; }
[data-theme="dark"] .tag.old { color: #e0b54d; }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--line); height: 34px; }
.stepper button { width: 36px; border: 0; background: var(--panel-2); cursor: pointer; font-size: 1.2rem; line-height: 1; }
.stepper button:hover { background: var(--line); }
.stepper output { flex: 1; display: grid; place-items: center; font-weight: 700; min-width: 30px; }
.add-btn { height: 34px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-family: var(--head); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.add-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }

/* Sticky queue bar on small screens */
.queue-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--navy); color: #fff; border-top: 3px solid var(--red); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.queue-bar strong { font-family: var(--head); font-size: 1.1rem; letter-spacing: .04em; }

/* Viewer */
.viewer { border: 0; padding: 0; background: transparent; max-width: min(94vw, 560px); width: 100%; }
.viewer::backdrop { background: rgba(5, 8, 15, .82); }
.viewer-inner { display: grid; gap: 10px; justify-items: center; }
.viewer img, .viewer canvas { max-width: 100%; max-height: 74vh; width: auto; height: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); border-radius: 3.5%; }
.viewer .row { justify-content: center; }
.viewer-title { color: #fff; font-family: var(--head); font-size: 1.3rem; font-weight: 700; text-align: center; }
.viewer-sub { color: #b9c0d0; font-size: .85rem; text-align: center; }

/* Print queue */
.q-list { display: grid; gap: 8px; }
.q-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 6px; border: 1px solid var(--line); background: var(--panel-2); }
.q-item img, .q-item canvas { width: 48px; height: auto; display: block; }
.q-item .stepper { width: 120px; }
.options { display: grid; gap: 14px; }
.opt-title { font-family: var(--head); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.radio-card { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; padding: 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; align-items: start; }
.radio-card input { margin-top: 3px; accent-color: var(--red); }
.radio-card b { font-family: var(--head); letter-spacing: .03em; font-size: 1.02rem; }
.radio-card span { grid-column: 2; font-size: .84rem; color: var(--muted); }
.radio-card:has(input:checked) { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.diagram { display: flex; gap: 6px; align-items: flex-end; grid-column: 2; margin-top: 4px; }
.diagram i { display: block; width: 18px; height: 28px; background: var(--steel); }
.diagram i.b { background: var(--red); }
.diagram .pair { display: grid; gap: 0; }
.diagram .pair i:first-child { border-bottom: 1px dashed #fff; }
.progress { height: 6px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--red); transition: width .2s; }

/* Creator */
.creator { display: grid; gap: 16px; }
@media (min-width: 900px) { .creator { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; } .preview-wrap { position: sticky; top: 110px; } }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span, .fieldset-title { font-family: var(--head); font-weight: 700; font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field input[type=text], .field input[type=number], .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 0; }
.field textarea { min-height: 130px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }
.cols { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.sym-bar { display: flex; flex-wrap: wrap; gap: 4px; }
.sym-bar button { min-width: 36px; height: 34px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-family: IASymbols; font-size: 1.1rem; }
.sym-bar button.txt { font-family: var(--sys); font-size: .8rem; font-weight: 700; padding: 0 8px; }
.sym-bar button:hover { border-color: var(--red); }
.preview-wrap { display: grid; gap: 10px; justify-items: center; }
.preview-wrap canvas { width: 100%; max-width: 360px; height: auto; border-radius: 3.5%; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); background: #111; }
.preview-wrap canvas.mini { max-width: 280px; }
.art-tools { display: grid; gap: 8px; width: 100%; max-width: 360px; }
.art-tools input[type=range] { width: 100%; accent-color: var(--red); }
.my-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.my-card { border: 1px solid var(--line); background: var(--panel-2); padding: 6px; display: grid; gap: 6px; cursor: pointer; text-align: left; }
.my-card canvas { width: 100%; height: auto; display: block; }
.my-card b { font-family: var(--head); font-size: .98rem; }
details.help { border: 1px solid var(--line); padding: 8px 12px; background: var(--panel-2); }
details.help summary { cursor: pointer; font-weight: 600; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 0 4px; font-size: .88em; }

/* About */
.prose { max-width: 70ch; }
.credit-list { padding-left: 1.2em; }
.credit-list li { margin-bottom: .5em; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 40; background: var(--navy); color: #fff; padding: 10px 16px; border-left: 4px solid var(--red); box-shadow: var(--shadow); max-width: 90vw; }

@media (min-width: 760px) {
  .filters { grid-template-columns: 1fr; }
  h1 { font-size: 2.2rem; }
}
