:root {
  color-scheme: light;
  --ink: #16211d;
  --muted: #62706a;
  --line: #d9e1dd;
  --paper: #f7f9f6;
  --panel: #ffffff;
  --accent: #0f7b68;
  --accent-2: #b43f4b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}
.sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
main {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 430px;
  gap: 0;
  min-height: calc(100vh - 75px);
}
.workspace {
  padding: 22px 28px 36px;
  border-right: 1px solid var(--line);
}
.preview {
  padding: 22px 24px 36px;
  background: #fff;
}
.section {
  margin-bottom: 24px;
}
.section h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 104, .12);
}
input[type="checkbox"] {
  width: auto;
}
textarea {
  min-height: 84px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 4px;
}
button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, background .12s;
}
button:hover { transform: translateY(-1px); background: #0c6a5a; }
button.secondary { background: #e7ece9; color: var(--ink); }
button.secondary:hover { background: #dce4df; }
.decoded-preview, .digits {
  word-break: break-all;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  background: #fbfcfb;
  border-radius: 6px;
  padding: 12px;
  min-height: 70px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}
.digits {
  color: #10231f;
  min-height: 120px;
}
.qrbox {
  display: grid;
  place-items: center;
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}
.qrbox img {
  width: min(300px, 100%);
  height: auto;
  image-rendering: pixelated;
}
.status {
  margin-top: 10px;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}
.status.err { color: var(--accent-2); }
.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.rail-data-status {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.rail-query-result {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  min-height: 18px;
  margin-top: 8px;
}
.rail-query-result strong {
  color: var(--ink);
}
.rail-query-result span {
  margin-left: 8px;
}
.rail-price-grid {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(70px, .7fr) minmax(50px, .6fr);
  gap: 4px 8px;
  margin-top: 4px;
}
.rail-price-grid span {
  margin-left: 0;
}
@font-face {
  font-family: "CRTicketRedNo";
  src: url("./fonts/A1中国铁路红票票号体-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "CRTicketHei";
  src: url("./fonts/simhei.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "CRTicketFangSong";
  src: url("./fonts/仿宋_GB2312.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "CRTicketTrainNo";
  src: url("./fonts/A3中国铁路车次体-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "CRTicketFace";
  src: url("./fonts/A2中国铁路票面体-Regular.ttf") format("truetype");
  font-display: swap;
  unicode-range: U+0020, U+002D-002E, U+0030-003A, U+0041-0044, U+0046, U+00A5, U+4E2D, U+5143, U+53F7, U+5E74, U+5F00, U+6708, U+65E5, U+8F66;
}
@font-face {
  font-family: "CRTicketSong";
  src: url("./fonts/simsun.ttf") format("truetype");
  font-display: swap;
}
.render-ticket {
  box-sizing: content-box;
  background: #ecc url('./assets/ticket-bg.png') -10px -50px / 110px 95px;
  padding: 12px;
  border: 12px solid #eee;
  margin: 0 auto;
  width: 280px;
  color: #111;
  font: 14px/1.25 "CRTicketSong", SimSun, serif;
}
.render-ticket .ticket-number {
  display: inline-block;
  font-family: "CRTicketRedNo", monospace;
  font-size: 19px;
  line-height: 17.5px;
  color: #b43;
}
.render-ticket .row {
  position: relative;
  padding: 1px 0;
}
.render-ticket .left, .render-ticket .middle, .render-ticket .right {
  display: inline-block;
  position: absolute;
}
.render-ticket .left { left: 0; }
.render-ticket .right { right: 0; }
.render-ticket .middle, .render-ticket .primary .station::after {
  left: 50%;
  transform: translate(-50%);
}
.render-ticket .primary {
  margin: 2px 8px 48px;
}
.render-ticket .primary .station {
  min-width: 64px;
  text-align-last: justify;
  font-family: "CRTicketHei", SimHei, sans-serif;
  font-size: 135%;
}
.render-ticket .primary .station::after {
  content: attr(data-pinyin);
  text-align: center;
  text-transform: capitalize;
  font-family: "CRTicketFangSong", FangSong, serif;
  font-size: 60%;
  position: absolute;
  top: 24px;
}
.render-ticket .train-code {
  width: 80px;
  text-align: center;
}
.render-ticket .train-big {
  font-family: "CRTicketTrainNo", serif;
  font-size: large;
}
.render-ticket .ticket-date-time,
.render-ticket .coach-seat,
.render-ticket .price,
.render-ticket .price-unit,
.render-ticket .id-number {
  font-family: "CRTicketFace", "CRTicketSong", SimSun, serif;
}
.render-ticket .ticket-date-time,
.render-ticket .coach-seat,
.render-ticket .price,
.render-ticket .price-unit,
.render-ticket .id-number {
  font-size: 16px;
  line-height: 17.5px;
}
.render-ticket .a2-spaced .a2-cjk + .a2-other,
.render-ticket .a2-spaced .a2-other + .a2-cjk {
  margin-left: 2px;
}
.render-ticket .paper-number {
  font-family: "CRTicketSong", SimSun, serif;
}
.render-ticket .arrow, .render-ticket .arrow::before {
  display: block;
  height: 1px;
  background: #000;
}
.render-ticket .arrow {
  position: relative;
  width: 100%;
}
.render-ticket .arrow::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  transform-origin: top right;
  transform: rotate(30deg);
}
.render-ticket .circled:not(:empty) {
  display: inline-block;
  border-radius: 50%;
  border: 1px solid;
}
.render-ticket .circled::before, .render-ticket .circled::after {
  content: '\200B';
  display: inline-block;
  line-height: 0;
  padding-top: 50%;
  padding-bottom: 50%;
}
.render-ticket .circled::before { padding-left: 1px; }
.render-ticket .circled::after { padding-right: 1px; }
.render-ticket .id-number {
  white-space: pre;
}
.render-ticket .mini-qr {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: transparent;
  image-rendering: pixelated;
  mix-blend-mode: multiply;
}
.scanner-modal,
.password-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 20, 17, .56);
}
.scanner-modal.hidden,
.password-modal.hidden {
  display: none;
}
.scanner-panel,
.password-panel {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .22);
}
.password-panel {
  width: min(360px, 100%);
}
.password-panel h2 {
  margin: 0 0 14px;
  font-size: 15px;
}
.password-error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--accent-2);
  font-size: 12px;
}
.password-actions {
  justify-content: flex-end;
  margin-bottom: 0;
}
.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.scanner-head h2 {
  margin: 0;
  font-size: 15px;
}
.scanner-view {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #111;
  aspect-ratio: 1 / 1;
}
.scanner-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-frame {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(255, 255, 255, .86);
  border-radius: 6px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .22);
}
@media (max-width: 980px) {
  main { grid-template-columns: 1fr; }
  .workspace { border-right: 0; border-bottom: 1px solid var(--line); }
  .grid, .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  header, .workspace, .preview { padding-left: 16px; padding-right: 16px; }
  .grid, .grid.two { grid-template-columns: 1fr; }
}
