:root {
  /* brand: graphite with an amber accent. Change here to re-theme the whole app. */
  --brand: #2B2F33;              /* buttons, primary actions */
  --brand-hover: #1C1F22;
  --brand-dark: #5C4108;         /* text on amber tints */
  --accent: #E0A526;             /* amber: selections, highlights, active states */
  --brand-soft: #F7E4B5;         /* active toggle buttons */
  --brand-tint: #FBF3E0;         /* info bars */
  --brand-line: #EBCF8C;
  --brand-line-strong: #D9AE4A;
  --brand-a08: rgba(224,165,38,.10);
  --brand-a10: rgba(224,165,38,.14);
  --brand-a12: rgba(224,165,38,.18);
  --brand-a25: rgba(224,165,38,.32);
  --canvas: #ECECEA;
}
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, sans-serif; background: var(--canvas); color: #222; }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; background: #fff; border-bottom: 1px solid #ddd; }
.logo { margin-right: 8px; }
.grow { flex: 1; }
.sep { width: 1px; height: 24px; background: #ddd; }
.btn { border: 1px solid #ccc; background: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.active { background: var(--brand-soft); border-color: var(--accent); }
.btn.icon { padding: 6px 10px; }
.fmt { display: flex; align-items: center; gap: 6px; }
.fmt input[type=number] { width: 64px; padding: 5px; border: 1px solid #ccc; border-radius: 6px; }
.fmt input[type=color] { width: 34px; height: 30px; border: 1px solid #ccc; border-radius: 6px; padding: 2px; }
.fontname { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #666; font-size: 12px; }
main { padding: 24px 16px 80px; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.empty { max-width: 520px; text-align: center; margin-top: 12vh; }
.page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); max-width: 100%; }
.page canvas { display: block; }
.layer { position: absolute; inset: 0; transform-origin: 0 0; }
.adding .layer { cursor: text; }
.t { position: absolute; white-space: pre; line-height: 1; transform-origin: 0 0; outline: none;
  color: transparent; cursor: text; border-radius: 1px; }
.t:hover { background: var(--brand-a12); }
.t.edited { color: var(--c); }
.t.sel { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 16px; border-radius: 8px; max-width: 90vw; }
[hidden] { display: none !important; }
.datewrap { display: flex; align-items: center; gap: 4px; }
.datewrap input, .smartbar input[type=date] { padding: 4px 6px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
.warn { color: #b45309; font-size: 12px; }
.btn.attention { border-color: #d97706; background: #fff7ed; }
.smartbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--brand-tint); border-bottom: 1px solid var(--brand-line); }
.smartbar .muted { color: #555; }
.invnum { width: 150px; padding: 5px 8px; border: 1px solid var(--brand-line-strong); border-radius: 6px; font: 600 14px ui-monospace, monospace; }
.btn.link { border-color: transparent; background: none; color: var(--brand); }
.datefmt { padding: 5px 6px; border: 1px solid #ccc; border-radius: 6px; font: inherit; max-width: 230px; background: #fff; }
.series { border: none; border-radius: 12px; padding: 20px 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.series::backdrop { background: rgba(0,0,0,.35); }
.series h2 { margin: 0 0 4px; font-size: 18px; }
.series .muted { color: #666; margin: 0 0 14px; }
.series label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 500; }
.series label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 8px; }
.series input:not([type=radio]):not([type=checkbox]), .series select { padding: 7px 8px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
.series fieldset { border: 1px solid #e3e3e3; border-radius: 8px; margin: 0 0 12px; padding: 8px 12px 4px; }
.series legend { font-weight: 500; padding: 0 4px; }
.series .preview { background: var(--brand-tint); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.series .actions { display: flex; justify-content: flex-end; gap: 8px; }
.t { caret-color: var(--c, #111); }
.t:focus { background: var(--brand-a08); }
.t.insel { background: var(--brand-a25); }
.dbtn { position: absolute; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; background: #fff; border: 1px solid var(--brand-line); border-radius: 5px; cursor: pointer;
  opacity: .75; box-shadow: 0 1px 3px rgba(0,0,0,.12); z-index: 2; }
.dbtn:hover { opacity: 1; border-color: var(--accent); }
.dbtn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; bottom: 0; left: 0; }
.area-mode .layer, .area-mode .t { cursor: crosshair; }
.marquee { position: absolute; border: 1.5px dashed var(--accent); background: var(--brand-a10); pointer-events: none; }
.areaactions { display: flex; gap: 6px; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 6px 0 0 6px; }
.seg .btn:last-child { border-radius: 0 6px 6px 0; }
@media print { .dbtn { display: none; } }

.top { position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.t { scroll-margin-top: var(--toph, 160px); }
.marquee.movable { pointer-events: auto; cursor: ns-resize; }
.series .preview { white-space: pre-line; }
.smartbar { flex-direction: column; align-items: stretch; }
.smartbar .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.smartbar label.inline { display: flex; align-items: center; gap: 6px; }
.calcsum { font: 600 13px ui-monospace, monospace; color: var(--brand-dark); }
.hint { font-size: 12px; }
.hint code { background: #fff; padding: 1px 4px; border-radius: 4px; }
.calcdlg { width: min(640px, calc(100vw - 32px)); }
.calctable { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
.calctable th, .calctable td { text-align: left; padding: 6px; border-bottom: 1px solid #eee; vertical-align: top; }
.calctable .num { text-align: right; white-space: nowrap; }
.calctable select { padding: 4px; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
.btn.small { padding: 2px 8px; font-size: 12px; margin-top: 4px; }
.status { font-size: 12px; color: #555; font-variant-numeric: tabular-nums; }

/* ---------- phones ---------- */
.area-mode .layer { touch-action: none; }
.calcdlg { overflow-x: auto; }
@media (max-width: 700px) {
  .top { position: static; box-shadow: none; }
  .bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; flex-wrap: nowrap; overflow-x: auto;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid #ddd; border-bottom: none;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08); -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .bar::-webkit-scrollbar { display: none; }
  .bar > * { flex-shrink: 0; }
  .logo, .grow, .sep { display: none; }
  .fmt { order: -1; flex-shrink: 0; padding-right: 8px; margin-right: 4px; border-right: 1px solid #ddd; }
  .fmt .fontname { display: none; }
  .btn { padding: 9px 12px; }           /* bigger tap targets */
  .btn.icon { padding: 9px 12px; }
  body { padding-bottom: 72px; }
  main { padding: 12px 16px 24px; }
  .smartbar { padding: 10px 16px; }
  .smartbar .hint { display: none; }
  .invnum { width: 130px; }
  .calcsum { width: 100%; }
  .toast { bottom: 84px; }
  .empty { margin-top: 8vh; }
}
@media (pointer: coarse) {
  /* invisible padding so small PDF text is easy to tap */
  .t::after { content: ''; position: absolute; inset: -7px -3px; }
  .dbtn { width: 28px; height: 28px; }
}
.calctable .note { font-size: 11px; color: #92400e; white-space: normal; margin-top: 4px; }
.calccard { position: fixed; right: 20px; bottom: 20px; z-index: 30; width: min(380px, calc(100vw - 32px)); background: #fff;
  border: 1px solid var(--brand-line); border-radius: 12px; padding: 14px 16px; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.calccard p { margin: 6px 0 10px; font-size: 13px; color: #333; }
.calccard .actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 700px) { .calccard { left: 16px; right: 16px; bottom: 84px; width: auto; } }
.calccard p { white-space: pre-line; line-height: 1.6; }
.empty h1 { font-size: 34px; margin: 0 0 8px; }
.empty .lead { font-size: 17px; color: #444; margin: 0 0 20px; }
.btn.big { display: inline-block; padding: 12px 28px; font-size: 16px; font-weight: 600; }
.features { list-style: none; padding: 0; margin: 32px auto 0; text-align: left; max-width: 480px; display: grid; gap: 12px; }
.features li { background: #fff; border-radius: 10px; padding: 12px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); line-height: 1.45; }

.logo::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.empty .mark { box-shadow: inset 0 -0.28em 0 var(--accent); padding: 0 2px; }
.features li { position: relative; padding-left: 34px; }
.features li::before { content: ''; position: absolute; left: 14px; top: 19px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.keys table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px; }
.keys td { padding: 7px 4px; border-bottom: 1px solid #eee; }
.keys td:first-child { white-space: nowrap; width: 1%; padding-right: 16px; }
kbd { display: inline-block; min-width: 22px; padding: 2px 6px; border: 1px solid #ccc; border-bottom-width: 2px; border-radius: 5px;
  background: #fafafa; font: 12px ui-monospace, monospace; text-align: center; }
@media (pointer: coarse) { #keysBtn { display: none; } }
.grip { position: absolute; z-index: 4; width: 22px; height: 22px; border-radius: 6px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: move; touch-action: none; user-select: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.sizer { position: absolute; z-index: 4; width: 10px; height: 10px; background: #fff; border: 2px solid var(--accent); border-radius: 2px;
  cursor: nwse-resize; touch-action: none; }
@media (pointer: coarse) { .grip { width: 30px; height: 30px; } .sizer { width: 18px; height: 18px; } }
.empty .brand { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px; }
