:root {
  --brand: #2f5d50; --brand-dark: #234840; --brand-soft: #e5eee9;
  --accent: #b8862f; --accent-soft: #f6ecd6;
  --bg: #f4f1ea; --surface: #ffffff; --ink: #23211d; --muted: #6b665c; --line: #e2dccf;
  --danger: #a33a2c; --radius: 10px;
  --stage: #d9d4c7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--brand-dark); font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 19px; font-weight: 600; white-space: nowrap; }
.brand svg { width: 34px; height: 21px; color: var(--brand); }
.status { flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.link { font-size: 14px; text-decoration: none; }

.workspace { flex: 1; display: flex; min-height: 0; }
.panel { width: 340px; flex: none; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 4px 18px 24px; }
.sec { padding: 14px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h2 { font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.pro-hint { color: #8a6420; }
.field { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
.field input:not([type=range]), .field select { display: block; width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 14px; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field input[type=range] { width: 100%; accent-color: var(--brand); margin-top: 6px; }
.field output { float: right; color: var(--ink); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; margin-top: 9px; cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #c9c1b0; background: #fbfaf7; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-pro { background: var(--accent-soft); border-color: #e3cf9f; color: #6e4f15; font-weight: 600; }
.btn-pro:hover { background: #f1e2bd; }
.btn-pro.is-pro { background: var(--brand-soft); border-color: #bcd3c8; color: var(--brand-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand); padding-left: 6px; padding-right: 6px; }
.btn-ghost:hover { background: var(--brand-soft); border-color: transparent; }
.btn-ghost.danger { color: var(--danger); }
.btn-lg { width: 100%; padding: 11px 16px; font-size: 15.5px; font-weight: 600; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btn-row .btn { flex: 1; }
.btn-row.small { margin-top: 8px; }
.btn-row.small .btn { flex: none; font-size: 13px; }
.file-btn { cursor: pointer; }
.lock { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; background: var(--accent-soft); color: #7a5818; border-radius: 4px; padding: 1px 5px; }
.export .btn-row { margin-top: 8px; }

.seg { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: #fff; padding: 7px 2px; font-size: 12.5px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-checked=true] { background: var(--brand); color: #fff; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme { position: relative; border: 1px solid var(--line); border-radius: 9px; padding: 6px 6px 5px; background: #fff; cursor: pointer; text-align: left; font-size: 12px; }
.theme[aria-pressed=true] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.theme .sw { display: flex; height: 22px; border-radius: 5px; overflow: hidden; margin-bottom: 4px; border: 1px solid rgba(0,0,0,.06); }
.theme .sw i { flex: 1; }
.theme .lock { position: absolute; top: -6px; right: -4px; }

.picker { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 8px; max-height: 240px; overflow-y: auto; background: #fff; }
.picker li { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.picker li small { color: var(--muted); margin-left: 6px; }
.picker li:hover, .picker li.active { background: var(--brand-soft); }

.stage-wrap { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--stage); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: rgba(255,255,255,.55); border-bottom: 1px solid rgba(0,0,0,.06); }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer; font-size: 17px; line-height: 1; }
.icon-btn.wide { width: auto; padding: 0 10px; font-size: 13px; }
.zoom-label { font-size: 12.5px; color: var(--muted); min-width: 44px; }
.spacer { flex: 1; }
.readability { font-size: 12.5px; padding: 3px 9px; border-radius: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.readability.ok { background: #e3efe8; color: #1f5a3c; }
.readability.small { background: #f6ecd6; color: #6e4f15; }
.readability.tiny { background: #f8e3dd; color: #8a2f1d; }
.tip { font-size: 12.5px; color: #555; }
.stage { flex: 1; overflow: auto; cursor: grab; padding: 28px; display: grid; }
.stage.dragging { cursor: grabbing; }
.paper { margin: auto; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.12), 0 16px 40px rgba(0,0,0,.14); line-height: 0; }
.paper svg { display: block; width: 100%; height: auto; }
.paper .cell { cursor: pointer; transition: opacity .12s; }
.paper .cell:hover { opacity: .78; }
.pro-banner { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 7px 12px; background: var(--accent-soft); color: #6e4f15; font-size: 13.5px; border-bottom: 1px solid #ead9b0; }
.drop-overlay { position: absolute; inset: 0; display: none; place-items: center; background: rgba(47,93,80,.82); color: #fff; font-size: 22px; font-family: Georgia, serif; z-index: 5; }
.dragover .drop-overlay { display: grid; }
.loading { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); background: #fff; padding: 8px 14px; border-radius: 20px; box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: 13.5px; display: flex; align-items: center; gap: 8px; z-index: 4; }
.loading[hidden] { display: none; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dlg { border: 0; border-radius: 14px; padding: 22px 24px; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--ink); }
.dlg-wide { width: min(980px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(30,28,24,.45); }
.dlg h3 { margin: 0 0 4px; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 22px; font-weight: 600; color: var(--brand-dark); }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.dlg-actions .last { order: 10; }
.price { margin: 4px 0 12px; color: var(--muted); }
.price strong { font-size: 28px; color: var(--ink); margin-right: 4px; }
.ticks { list-style: none; padding: 0; margin: 0 0 12px; }
.ticks li { padding: 5px 0 5px 26px; position: relative; font-size: 14.5px; }
.ticks li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 10px; height: 5px; border-left: 2px solid var(--brand); border-bottom: 2px solid var(--brand); transform: rotate(-45deg); }
.guarantee { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 0 0 14px; }
.pro-reasons { background: var(--accent-soft); border: 1px solid #ead9b0; color: #6e4f15; border-radius: 8px; padding: 8px 10px; font-size: 13.5px; margin-bottom: 12px; }
.have-key { margin-top: 14px; font-size: 14px; }
.have-key summary { cursor: pointer; color: var(--brand); }
.key-row { display: flex; gap: 8px; margin-top: 8px; }
.key-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; min-width: 0; }

.quick-table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
.quick { border-collapse: collapse; width: 100%; font-size: 13px; }
.quick th { position: sticky; top: 0; background: var(--bg); text-align: left; font-weight: 600; padding: 7px 6px; color: var(--muted); z-index: 1; }
.quick td { padding: 3px 4px; border-top: 1px solid var(--line); }
.quick td:first-child { color: var(--muted); white-space: nowrap; padding-left: 8px; font-size: 12.5px; }
.quick tr.gen-start td { border-top: 2px solid #cfc7b5; }
.quick input { width: 100%; min-width: 90px; padding: 5px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; font-size: 13px; }
.quick input:hover { border-color: var(--line); }
.quick input:focus { border-color: var(--brand); background: #fff; outline: none; }
.quick tr.disabled input { opacity: .35; pointer-events: none; }

/* Print ordering */
.btn-print { flex-direction: column; gap: 1px; margin-bottom: 8px; background: #b8862f; border-color: #a5761f; color: #fff; }
.btn-print:hover { background: #a5761f; border-color: #8f6519; }
.btn-print small { font-size: 12px; font-weight: 500; opacity: .9; }
.dlg-print { width: min(1040px, calc(100vw - 32px)); padding: 0; overflow: hidden; }
.print-grid { display: grid; grid-template-columns: 1.15fr 1fr; min-height: 560px; }
.print-wall { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px 28px 20px; background: radial-gradient(ellipse at 50% 35%, #ece5d6, #d6cbb4 75%); }
.print-frame { position: relative; max-height: 64vh; }
.print-frame.is-framed { background: var(--frame, #1e1e1e); padding: 3.2%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 18px 40px rgba(40,25,10,.35), 0 4px 10px rgba(40,25,10,.25); }
.print-frame.is-framed .print-mat { box-shadow: inset 0 0 6px rgba(0,0,0,.35); }
.print-frame.is-poster { box-shadow: 0 14px 30px rgba(40,25,10,.28), 0 2px 6px rgba(40,25,10,.2); }
.print-mat { height: 100%; background: #fff; line-height: 0; }
.print-mat svg { width: 100%; height: 100%; display: block; }
.print-dims { margin: 16px 0 0; font-size: 13px; color: #5d584e; }
.print-opts { padding: 24px 26px 18px; overflow-y: auto; max-height: calc(100vh - 40px); }
.print-sub { margin: 0 0 12px; }
.print-mock { background: #e8f0fb; color: #23456e; border-radius: 8px; padding: 7px 10px; font-size: 13px; margin: 0 0 12px; }
.seg-2 { grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
.size-list { display: grid; gap: 6px; }
.size-opt { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; cursor: pointer; font-size: 14.5px; }
.size-opt.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.size-opt input { accent-color: var(--brand); }
.size-name { flex: 1; }
.size-name em { font-style: normal; font-size: 11.5px; font-weight: 600; color: #7a5818; background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.size-price { font-weight: 600; }
.swatches { display: flex; gap: 10px; margin-top: 6px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; background: var(--sw); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--brand); }
.print-warn { background: var(--accent-soft); border: 1px solid #ead9b0; color: #6e4f15; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 12px 0 0; }
.check.proof { align-items: flex-start; margin-top: 14px; font-size: 13.5px; }
.check.proof input { margin-top: 2px; flex: none; }
.print-notes { margin: 12px 0 14px; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.print-error { color: var(--danger); font-size: 13.5px; min-height: 1.2em; margin: 8px 0 0; }
@media (max-width: 860px) {
  .print-grid { grid-template-columns: 1fr; }
  .print-wall { padding: 24px 16px 12px; }
  .print-frame { max-height: 40vh; }
}

.file-notice { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(30,28,24,.55); }
.file-card { background: #fff; max-width: 500px; border-radius: 14px; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.3); font-size: 15px; line-height: 1.5; }
.file-card h3 { margin: 0 0 10px; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 22px; color: var(--brand-dark); }
.file-card p { margin: 0 0 10px; }
.file-card code { background: var(--bg); padding: 1px 6px; border-radius: 5px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #23211d; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 50; max-width: calc(100vw - 32px); }

@media (max-width: 860px) {
  body { height: auto; }
  .workspace { flex-direction: column; }
  .panel { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .stage-wrap { height: 72vh; order: 1; }
  .status, .tip { display: none; }
  .stage { padding: 14px; }
}
