:root {
  --bg: #e9e8e3;
  --panel: #f8f7f3;
  --panel-strong: #ffffff;
  --ink: #202320;
  --muted: #717770;
  --line: #d2d2cb;
  --green: #174f43;
  --green-dark: #103c33;
  --orange: #de6b37;
  --ticket: #cf9cb0;
  --ticket-deep: #b87891;
  --ticket-ink: #171615;
  --sans: "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", "Microsoft YaHei", Arial, sans-serif;
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", "AR PL UMing CN", "Songti SC", serif;
  --weibei: "FZWeiBei-S03", "STXinwei", "华文新魏", "Noto Serif CJK SC", serif;
  --mono: "DejaVu Sans Mono", "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  line-height: 1.45;
}
button, input, textarea { font: inherit; }
button { color: inherit; }

.topbar {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid #c9cac4;
  background: rgba(249, 248, 244, .94);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--green); font-weight: 900; }
.brand b, .brand small { display: block; }
.brand b { font-size: 13px; }
.brand small { margin-top: -1px; color: var(--muted); font: 700 8px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.document-status { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10px; }
.linux-badge { padding: 5px 9px; border: 1px solid #a8c1b9; border-radius: 999px; color: var(--green); background: #f5faf8; font: 700 8px var(--mono); letter-spacing: .06em; }

main { width: min(1510px, calc(100% - 36px)); margin: 0 auto; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 29px 2px 20px; }
.kicker { margin: 0 0 5px; color: var(--orange); font: 800 8px var(--mono); letter-spacing: .16em; }
.workspace-heading h1 { margin: 0; color: var(--green-dark); font: 650 clamp(28px, 3.2vw, 43px) var(--serif); letter-spacing: -.05em; }
.workspace-heading > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.rules { display: flex; gap: 8px; padding-bottom: 4px; }
.rules span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: #5c625d; background: rgba(255,255,255,.5); font-size: 9px; white-space: nowrap; }
.rules i { color: var(--green); font-style: normal; font-weight: 900; }

.editor-shell { display: grid; grid-template-columns: minmax(0, 1fr) 318px; min-height: 680px; overflow: hidden; border: 1px solid #c8c9c2; border-radius: 13px 13px 0 0; background: var(--panel); box-shadow: 0 24px 70px rgba(40, 43, 39, .09); }
.stage-panel { min-width: 0; display: flex; flex-direction: column; background: #deddd8; }
.stage-toolbar { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid #c6c6c1; background: #f2f1ed; }
.tool-group { display: flex; align-items: center; gap: 5px; }
.toolbar-actions { display: flex; align-items: center; gap: 13px; }
.tool, .icon-button, .reset-button { cursor: pointer; border: 0; background: transparent; font-size: 10px; }
.tool { display: flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 5px; font-weight: 700; }
.tool.active { color: white; background: var(--green); }
.cursor-icon { font-size: 13px; }
.toolbar-divider { width: 1px; height: 19px; margin: 0 5px; background: var(--line); }
.icon-button { width: 25px; height: 25px; border-radius: 4px; font-size: 15px; }
.icon-button:hover { background: #e1e2dc; }
#zoomValue { width: 40px; color: var(--muted); font: 700 9px var(--mono); text-align: center; }
.reset-button { color: var(--green); font-weight: 800; }
.ticket-mode-picker { display: flex; margin: 0; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: #e6e6e0; }
.ticket-mode-picker label { position: relative; cursor: pointer; }
.ticket-mode-picker input { position: absolute; opacity: 0; pointer-events: none; }
.ticket-mode-picker span { display: block; padding: 5px 9px; border-radius: 5px; color: var(--muted); font-size: 9px; font-weight: 800; }
.ticket-mode-picker input:checked + span { color: white; background: var(--green); }
.ticket-mode-picker input:focus-visible + span { box-shadow: 0 0 0 3px rgba(23,79,67,.16); }

.stage-viewport { min-height: 570px; display: grid; place-items: center; overflow: auto; padding: 54px 34px 42px; background-image: radial-gradient(#c5c4be 1px, transparent 1px); background-size: 18px 18px; }
.ticket-canvas {
  position: relative;
  width: min(100%, 1000px);
  aspect-ratio: 832 / 480;
  flex: 0 0 auto;
  overflow: hidden;
  container-type: inline-size;
  color: var(--ticket-ink);
  background:
    linear-gradient(115deg, rgba(255,255,255,.23), transparent 28%, rgba(110,47,71,.07) 58%, transparent 77%),
    var(--ticket);
  border: 10px solid #f3f0e8;
  box-shadow: 0 4px 7px rgba(39,30,34,.18), 0 25px 55px rgba(65,46,54,.17);
  transform: scale(var(--zoom, 1));
  transform-origin: center;
  transition: transform .15s ease;
  isolation: isolate;
}
.paper-noise { position: absolute; inset: 0; z-index: -1; opacity: .58; background: repeating-linear-gradient(32deg, transparent 0 2px, rgba(255,255,255,.2) 2px 3px, transparent 3px 5px), repeating-linear-gradient(-29deg, rgba(111,47,74,.07) 0 1px, transparent 1px 4px); }
.ticket-canvas::after { content: ""; position: absolute; inset: 3%; z-index: -1; border: 1px solid rgba(104,45,68,.13); }
.ticket-canvas.font-weibei .ticket-element[data-index="1"],
.ticket-canvas.font-weibei .ticket-element[data-index="2"] { font-family: var(--weibei) !important; }

.ticket-element { position: absolute; z-index: 4; display: inline-flex; align-items: baseline; max-width: 54%; padding: .08em .14em; border: 1px dashed transparent; border-radius: 3px; color: var(--ticket-ink); line-height: 1.05; white-space: nowrap; }
.ticket-element:hover, .ticket-element:focus-within { border-color: rgba(23,79,67,.72); background: rgba(255,255,255,.52); }
.ticket-element.selected { border-color: var(--orange); background: rgba(255,250,236,.7); box-shadow: 0 0 0 2px rgba(222,107,55,.25); }
.ticket-input { min-width: 0; margin: 0; padding: 0; outline: 0; border: 0; color: inherit; background: transparent; font: inherit; line-height: inherit; text-align: inherit; }
.ticket-input::placeholder { color: #513f47; opacity: .55; font: .62em var(--sans); }
.affix { flex: 0 0 auto; }
.centered { transform: translateX(-50%); text-align: center; }
.station { font: 800 4.65cqw var(--serif); letter-spacing: .08em; }
.station .ticket-input { width: 6.6em; }
.train { font: 800 4.45cqw var(--mono); letter-spacing: .04em; }
.train .ticket-input { width: 4.7em; }
.latin { font: 700 2.55cqw "Liberation Sans Narrow", "DejaVu Sans Condensed", sans-serif; letter-spacing: .12em; }
.latin .ticket-input { width: 11em; }
.date { font: 700 3.45cqw var(--mono); }
.year .ticket-input { width: 4ch; }
.month .ticket-input, .day .ticket-input { width: 2ch; }
.time .ticket-input { width: 5ch; }
.carriage .ticket-input { width: 2ch; }
.seat .ticket-input { width: 4ch; }
.regular { font: 650 2.95cqw var(--serif); }
.regular .ticket-input { width: 8em; }
.berth .ticket-input { width: 5em; }
.restriction .ticket-input { width: 11em; }
.small { font: 650 2.45cqw var(--serif); }
.gate { font-size: 2.85cqw; }
.gate .ticket-input { width: 10em; }
.fare { font: 700 3.7cqw var(--mono); }
.fare .ticket-input { width: 7ch; }
.class-name { font: 800 3.35cqw var(--sans); }
.class-name .ticket-input { width: 6em; }
.validity { max-width: 72%; }
.validity .ticket-input { width: 24em; }
.through-line-row { position: absolute; left: 6.7%; top: 50%; z-index: 4; display: flex; align-items: baseline; gap: .85cqw; max-width: 88%; white-space: nowrap; }
.through-line-row > .ticket-element { position: relative; left: auto; top: auto; max-width: none; }
.through-first-line, .through-extra-box { font-size: 2.55cqw; }
.through-first-line .ticket-input { flex: 0 0 auto; width: auto; }
.through-first-line .through-heading-input { font-weight: 800; }
.through-first-line .through-literal { flex: 0 0 auto; font-size: .7em; font-weight: 650; }
.through-extra-box .ticket-input { flex: 0 0 auto; width: auto; }
.discount .ticket-input { width: 5em; }
.ticket-type { width: 9em; min-height: 1.58em; align-items: center; justify-content: center; }
.ticket-type .ticket-input { position: absolute; inset: 0; z-index: 2; width: 100%; color: transparent; caret-color: var(--ticket-ink); }
.ticket-type .ticket-input:placeholder-shown { color: #513f47; }
.ticket-type-circles { display: flex; align-items: center; justify-content: center; gap: .12em; pointer-events: none; }
.ticket-type-circles span { width: 1.36em; height: 1.36em; display: grid; place-items: center; flex: 0 0 auto; border: .085em solid currentColor; border-radius: 50%; line-height: 1; }
.advertisement { width: 54%; max-width: 54%; min-height: 13%; padding: .8cqw 1.2cqw; border: 1px dashed #282123 !important; font: 600 2.05cqw var(--serif); line-height: 1.5; white-space: normal; }
.advertisement .ticket-input { width: 100%; height: 3.2em; resize: none; overflow: hidden; }
.selling-station { font: 650 2.55cqw var(--serif); }
.selling-station .ticket-input { width: 8em; }
.route-line { position: absolute; left: 30.8%; top: 25%; z-index: 2; width: 18%; height: 2px; background: #221c1e; }
.route-line::after { content: ""; position: absolute; right: -1px; top: -4px; border-width: 5px 0 5px 10px; border-style: solid; border-color: transparent transparent transparent #221c1e; }
.qr-placeholder { position: absolute; right: 4.5%; bottom: 7.2%; z-index: 3; width: 16.3%; aspect-ratio: 1; display: grid; place-items: center; border: .42cqw solid #171615; color: #171615; background: rgba(255,255,255,.12); text-align: center; }
.qr-placeholder::before, .qr-placeholder::after { content: ""; position: absolute; width: 22%; aspect-ratio: 1; border: .3cqw solid currentColor; }
.qr-placeholder::before { left: 8%; top: 8%; }
.qr-placeholder::after { right: 8%; top: 8%; }
.qr-placeholder span { max-width: 70%; font: 800 1.7cqw/1.35 var(--sans); letter-spacing: .06em; }
.identity-row { position: absolute; left: 6.5%; top: 66.5%; z-index: 4; display: flex; align-items: baseline; gap: .65cqw; max-width: 66%; font: 700 2.35cqw var(--mono); }
.identity-row span { white-space: nowrap; }
.identity-row input { padding: .05em .12em; outline: 0; border: 1px dashed transparent; border-radius: 3px; color: inherit; background: transparent; font: inherit; }
.identity-row .identity-number { width: 18ch; }
.identity-row .identity-name { width: 7em; }
.identity-row input:hover, .identity-row input:focus { border-color: var(--orange); background: rgba(255,250,236,.7); }
.bottom-number-row { position: absolute; left: 6.2%; bottom: 2.3%; z-index: 4; width: 51%; font: 700 2.35cqw var(--mono); }
.bottom-number-row input { width: 100%; padding: .05em .12em; outline: 0; border: 1px dashed transparent; border-radius: 3px; color: inherit; background: transparent; font: inherit; letter-spacing: .02em; }
.bottom-number-row input:hover, .bottom-number-row input:focus { border-color: var(--orange); background: rgba(255,250,236,.7); }
.stage-tip { margin: 0; padding: 11px 17px; border-top: 1px solid #c8c8c2; color: #696e69; background: #f2f1ed; font-size: 9px; }
.stage-tip span { color: var(--orange); font-size: 12px; }

.properties-panel { min-width: 0; border-left: 1px solid #cacbc5; background: #fbfaf7; }
.properties-title { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid #dedfd9; }
.properties-title h2 { margin: 0; font: 650 19px var(--serif); }
.field-chip { display: none; }
.property-field { display: block; margin: 18px 20px 0; }
.property-field > span { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; color: #5f655f; font-size: 10px; font-weight: 750; }
.property-field textarea, .property-field input { width: 100%; padding: 10px 11px; outline: 0; border: 1px solid #c8cbc4; border-radius: 6px; color: var(--ink); background: white; font-size: 11px; resize: vertical; }
.property-field textarea:focus, .property-field input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(222,107,55,.12); }
.field-hint { min-height: 27px; margin: 7px 20px 0; color: var(--muted); font-size: 8px; }
.field-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 20px 16px; }
.field-nav button { width: 28px; height: 26px; cursor: pointer; border: 1px solid var(--line); border-radius: 5px; background: white; }
.field-nav span { color: var(--muted); font: 700 8px var(--mono); }
.fields { border-top: 1px solid #dedfd9; border-bottom: 1px solid #dedfd9; }
.fields summary { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; cursor: pointer; list-style: none; }
.fields summary::-webkit-details-marker { display: none; }
.fields summary span { font-size: 11px; font-weight: 800; }
.fields summary small { color: var(--muted); font-size: 8px; }
.layer-list { max-height: 224px; overflow: auto; padding: 0 10px 10px; }
.layer-row { width: 100%; min-width: 0; display: grid; grid-template-columns: 1fr; align-items: center; padding: 7px 9px; cursor: pointer; border: 0; border-radius: 5px; background: transparent; text-align: left; }
.layer-row:hover { background: #efefea; }
.layer-row.selected { background: #e6efe9; }
.layer-row b { display: none; }
.layer-row span, .layer-row strong, .layer-row small { min-width: 0; display: block; }
.layer-row strong { overflow: hidden; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.layer-row small { overflow: hidden; color: var(--muted); font-size: 7px; white-space: nowrap; text-overflow: ellipsis; }
.contact-block { padding: 15px 20px 22px; }
.hidden { display: none !important; }
.compact-field { display: block; margin-bottom: 12px; }
.compact-field span { display: block; margin-bottom: 6px; color: #5f655f; font-size: 9px; font-weight: 800; }
.compact-field input { width: 100%; padding: 8px 9px; outline: 0; border: 1px solid var(--line); border-radius: 6px; background: white; font-size: 10px; }
.compact-field input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(222,107,55,.12); }
.property-field em { padding: 2px 5px; border-radius: 999px; color: white; background: var(--orange); font-size: 7px; font-style: normal; }
.encoding-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 13px 0 0; padding: 0; border: 0; }
.encoding-picker legend { margin-bottom: 7px; color: #5f655f; font-size: 9px; font-weight: 800; }
.encoding-picker label { position: relative; cursor: pointer; }
.encoding-picker input { position: absolute; opacity: 0; pointer-events: none; }
.encoding-picker span { display: block; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: white; font: 700 9px var(--mono); text-align: center; }
.encoding-picker input:checked + span { border-color: var(--green); color: white; background: var(--green); }
.encoding-picker input:focus-visible + span { box-shadow: 0 0 0 3px rgba(23,79,67,.16); }
.soft-warning { display: none; margin: 13px 0 0; padding: 10px 11px; border: 1px solid #d89a47; border-radius: 6px; color: #70430d; background: #fff6df; font-size: 10px; line-height: 1.55; }
.soft-warning.visible { display: block; }
.form-error { min-height: 18px; margin: 5px 0; color: #a43b2a; font-size: 8px; }
.save-button { width: 100%; min-height: 47px; cursor: pointer; border: 0; border-radius: 7px; color: #fff; background: var(--green); box-shadow: 0 9px 22px rgba(23,79,67,.19); font-weight: 800; }
.save-button:hover { background: var(--green-dark); }
.save-button:disabled { cursor: wait; opacity: .6; }
.save-button span, .save-button small { display: block; }
.save-button small { margin-top: 1px; opacity: .68; font-size: 7px; font-weight: 500; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 40; padding: 9px 14px; border-radius: 6px; color: white; background: #303430; box-shadow: 0 9px 35px rgba(0,0,0,.25); font-size: 9px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .18s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(22,33,29,.68); backdrop-filter: blur(7px); }
.modal.hidden { display: none; }
.modal-card { width: min(410px, 100%); padding: 34px; border-radius: 14px; background: #fbfaf7; box-shadow: 0 32px 90px rgba(0,0,0,.28); text-align: center; }
.success-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 50%; color: white; background: var(--green); font-size: 22px; }
.modal-card h2 { margin: 0; color: var(--green-dark); font: 650 27px var(--serif); }
.modal-card > p:not(.kicker) { color: var(--muted); font-size: 10px; }
.output-label { display: block; margin: 18px 0 6px; color: var(--muted); font-size: 9px; font-weight: 800; text-align: left; }
.output-string { width: 100%; padding: 11px; border: 1px solid #c7cbc4; border-radius: 7px; color: #202320; background: #fff; font: 10px/1.55 var(--mono); resize: vertical; }
.secondary-button { width: 100%; margin-top: 9px; padding: 10px; cursor: pointer; border: 1px solid var(--line); border-radius: 7px; color: var(--green); background: transparent; font-size: 10px; font-weight: 800; }
.string-importer { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.string-importer summary { cursor: pointer; color: var(--green); font-size: 9px; font-weight: 800; }
.string-importer textarea { width: 100%; margin-top: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: white; font: 9px/1.45 var(--mono); resize: vertical; }
.display-disclaimer { min-height: 170px; flex: 1; display: grid; place-items: center; margin: 0; padding: 24px 30px; border: 0; border-top: 1px solid #c5c5bf; border-radius: 0; color: #7d271b; background: #fff2e9; text-align: center; box-shadow: inset 0 5px 18px rgba(125,39,27,.04); }
.display-disclaimer > div { width: min(900px, 100%); }
.display-disclaimer span { display: inline-block; margin-bottom: 8px; padding: 5px 10px; border-radius: 999px; color: #fff; background: #bd432d; font-size: clamp(10px, 1.05vw, 13px); font-weight: 850; letter-spacing: .05em; }
.display-disclaimer strong { display: block; font: 850 clamp(22px, 2.8vw, 36px) var(--sans); letter-spacing: .02em; }
.display-disclaimer p { max-width: 820px; margin: 8px auto 0; color: #72473d; font-size: clamp(11px, 1.2vw, 15px); font-weight: 650; }

@media (max-width: 1060px) {
  .editor-shell { grid-template-columns: 1fr; }
  .properties-panel { border-top: 1px solid #cacbc5; border-left: 0; }
  .layer-list { max-height: 260px; }
}
@media (max-width: 730px) {
  .topbar { padding-inline: 14px; }
  .document-status #saveState { display: none; }
  main { width: min(100% - 16px, 1510px); }
  .workspace-heading { align-items: start; flex-direction: column; }
  .rules { flex-wrap: wrap; }
  .stage-viewport { display: block; min-height: 0; overflow: auto; padding: 30px 16px; }
  .ticket-canvas { width: 720px; }
}
@media (max-width: 450px) {
  .brand b { font-size: 11px; }
  .linux-badge { display: none; }
  .workspace-heading { padding-top: 22px; }
  .rules { display: grid; }
}
