:root {
  --bg: #f3f4f6; --panel: #ffffff; --line: #e5e7eb; --ink: #111827; --muted: #6b7280;
  --accent: #1a4d8f; --accent-soft: #e8f0fb; --danger: #b91c1c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
.muted { color: var(--muted); font-weight: 400; }
.hidden { display: none !important; }

.top { display: flex; align-items: center; gap: 16px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 15px; }
.sheets { display: flex; gap: 4px; margin-left: 12px; }
.sheet-btn { border: 1px solid var(--line); background: #fff; padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.sheet-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topgroup { display: flex; align-items: center; gap: 4px; margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--line); }
.topgroup .label { width: auto; margin: 0 4px 0 0; }
.topgroup .btn.small { width: auto; margin: 0; padding: 5px 9px; font-size: 13px; }

.btn { border: 1px solid #cbd5e1; background: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #163f75; }
.btn.primary[disabled] { opacity: .6; cursor: default; }
.btn.small { padding: 5px 8px; font-size: 12px; margin: 2px 0; width: 100%; }
.btn.danger { color: var(--danger); }

.main { flex: 1; display: flex; min-height: 0; }
.tools { width: 132px; background: var(--panel); border-right: 1px solid var(--line); padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.group { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.label { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 2px 0; }
.tool { width: 54px; height: 50px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.tool small { font-size: 10px; color: var(--muted); }
.tool.active { background: var(--accent-soft); border-color: var(--accent); }
.quality { width: calc(50% - 2px); text-align: center; border: 1px solid var(--line); background: #fff; padding: 4px 6px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.quality.active { background: var(--accent-soft); border-color: var(--accent); }
.check { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; width: 100%; margin-top: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.widths { display: flex; gap: 4px; width: 100%; }
.width { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 5px; font-size: 11px; padding: 4px 0; cursor: pointer; }
.width.active { background: var(--accent-soft); border-color: var(--accent); }
.readout { flex: 0 0 28px; text-align: center; font-size: 13px; color: var(--ink); line-height: 24px; }
.stamp { border: 1px solid var(--line); background: #fff; border-radius: 5px; font-size: 12px; padding: 4px 7px; cursor: pointer; }
.stamp:hover { background: #f8fafc; }

.stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; min-width: 0; overflow: hidden; }
.sheet { background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.12); }
.sheet canvas { display: block; }

.modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.card { background: #fff; border-radius: 10px; padding: 22px 24px; width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card input { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; margin: 8px 0; }
.row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.card a { color: var(--accent); word-break: break-all; }
