@font-face {
  font-family: "Inter";
  src: url("vendor/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* neutrals */
  --canvas: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #e9ecf0;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #8b93a1;
  /* brand */
  --accent: #0e7c66;
  --accent-hover: #0a6553;
  --accent-soft: #e6f3ef;
  --accent-ring: rgba(14, 124, 102, .28);
  --danger: #c4320a;
  --danger-soft: #fef3f2;
  /* shape */
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --paper-shadow: 0 0 0 1px rgba(16, 24, 40, .04), 0 2px 4px rgba(16, 24, 40, .06), 0 10px 24px -6px rgba(16, 24, 40, .14);
  --sheet-w: 320px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --appbar-h: 60px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
button, input, select { font: inherit; color: inherit; }
b { font-weight: 600; }

.i {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r);
  font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible, .chip-grid button:focus-visible, .chip-row button:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--accent-ring);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-sm .i { width: 16px; height: 16px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ================= app bar ================= */
.appbar {
  height: var(--appbar-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 5;
}
.appbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.appbar-right { display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { width: 28px; height: 28px; color: var(--accent); }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.file-chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; height: 34px; padding: 0 12px;
  background: var(--surface-2); border-radius: var(--r); color: var(--text-2);
}
.file-chip .i { width: 16px; height: 16px; color: var(--accent); }
.file-name { font-weight: 550; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
.file-meta { color: var(--text-3); white-space: nowrap; font-size: 13px; }
.file-meta::before { content: "·"; margin-right: 8px; }
body:not(.has-file) .needs-file { display: none; }

/* ================= layout ================= */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- settings panel ---------- */
.panel {
  width: 340px; flex-shrink: 0; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); padding: 8px 0 12px; scrollbar-width: thin;
}
.panel-head { display: none; }
.group { padding: 18px 20px 20px; }
.group + .group { border-top: 1px solid var(--border); }
.group-title { font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 14px; letter-spacing: -.005em; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
.help { font-size: 12.5px; color: var(--text-3); margin: -6px 0 12px; }
.panel-foot { padding: 12px 14px 4px; border-top: 1px solid var(--border); }

/* inputs */
input[type=number], input[type=text], select {
  height: 36px; padding: 0 10px; width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
input[type=number]:hover, input[type=text]:hover, select:hover { border-color: #b8bfca; }
input[type=number]:focus, input[type=text]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input::placeholder { color: var(--text-3); }
input:disabled { background: var(--surface-2); color: var(--text-3); }
input[type=number] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; margin-top: -6px; pointer-events: none;
  border-right: 1.8px solid var(--text-2); border-bottom: 1.8px solid var(--text-2); transform: rotate(45deg);
}
select { appearance: none; padding-right: 34px; cursor: pointer; }

.inline-input { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.inline-input input { width: 72px; height: 32px; }

/* segmented controls */
.seg, .chip-grid {
  display: grid; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r);
}
.seg-2 { grid-template-columns: 1fr 1fr; }
.seg-3 { grid-template-columns: 1fr 1fr 1fr; }
.chip-grid { grid-template-columns: repeat(4, 1fr); }
.seg button, .chip-grid button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color .15s, color .15s, box-shadow .15s;
}
.seg button .i { width: 15px; height: 15px; }
.chip-grid button { height: 34px; font-size: 14px; font-variant-numeric: tabular-nums; }
.seg button:hover, .chip-grid button:hover { color: var(--text); }
.seg button.on, .chip-grid button.on {
  background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-sm);
}

/* range sliders */
.range-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.range-head label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.range-head output { font-size: 12.5px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; cursor: pointer; margin: 0;
  --fill: 30%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill));
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--accent); box-shadow: var(--shadow-sm);
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 1.5px solid var(--accent); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-ring); }

/* switches */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; cursor: pointer;
}
.switch-row > span { display: flex; flex-direction: column; min-width: 0; }
.switch-row b { font-size: 13.5px; font-weight: 500; }
.switch-row small { font-size: 12px; color: var(--text-3); }
.switch {
  -webkit-appearance: none; appearance: none; flex-shrink: 0; position: relative; cursor: pointer; margin: 0;
  width: 36px; height: 20px; border-radius: 20px; background: var(--border-strong); transition: background-color .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .2); transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.grid-inputs { display: flex; align-items: flex-end; gap: 10px; margin-top: 8px; }
.grid-inputs label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.grid-inputs .times { color: var(--text-3); padding-bottom: 8px; }

/* file list */
.group-title-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.group-title-row .group-title { margin-bottom: 0; }
.count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.file-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.file-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 6px 10px 10px; background: var(--surface); }
.file-row + .file-row { border-top: 1px solid var(--border); }
.file-num {
  flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; border-radius: 6px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.file-list.single .file-num, .file-list.single [data-act=up], .file-list.single [data-act=down] { display: none; }
.file-body { flex: 1; min-width: 0; }
.file-title { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.file-sub input.range-input { width: 112px; height: 28px; padding: 0 8px; font-size: 12.5px; box-shadow: none; }
.file-actions { display: flex; margin: -4px 0; }
.file-actions .icon-btn { color: var(--text-3); }
@media (hover: hover) {
  .file-list:not(.single) .file-row .file-actions .icon-btn:not(.danger) { opacity: .55; }
  .file-row:hover .file-actions .icon-btn { opacity: 1; }
}
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .i { width: 16px; height: 16px; }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.multi-field { margin-top: 16px; margin-bottom: 4px; }
.help-below { margin: 8px 0 0; }

.trim { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.trim label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.suffix-input { position: relative; display: block; }
.suffix-input input { padding-right: 28px; }
.suffix-input i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--text-3); font-size: 13px; pointer-events: none; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }

/* ================= workspace ================= */
.workspace { flex: 1; min-width: 0; overflow-y: auto; position: relative; }

.summary {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.summary-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.headline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.headline strong { font-size: 20px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.headline .from { color: var(--text-2); font-size: 14px; }
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.meta { display: flex; flex-wrap: wrap; gap: 2px 0; color: var(--text-3); font-size: 12.5px; }
.meta span { white-space: nowrap; }
.meta span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .7; margin: 0 9px; vertical-align: middle; }
.meta b { color: var(--text-2); font-weight: 500; }
.zoom { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.zoom input { width: 110px; margin: 0 4px; }
.quickbar { display: none; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; }
.progress span { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--accent); animation: slide 1s ease-in-out infinite; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }

/* empty state */
.empty { min-height: 100%; display: grid; place-items: center; padding: 40px 24px; }
.empty-card { max-width: 520px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.empty-icon {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 20px;
  background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.empty-icon .i { width: 26px; height: 26px; }
.empty h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.025em; margin: 0 0 10px; }
.lead { color: var(--text-2); font-size: 15px; margin: 0 0 26px; max-width: 440px; }
.drop-note { color: var(--text-3); font-size: 13px; margin: 12px 0 0; }
.features {
  list-style: none; padding: 0; margin: 40px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  text-align: left; border-top: 1px solid var(--border-strong); padding-top: 24px; width: 100%;
}
.features li { display: flex; gap: 10px; font-size: 12.5px; color: var(--text-3); }
.features .i { color: var(--accent); margin-top: 1px; }
.features b { display: block; color: var(--text); font-size: 13px; }

/* preview */
.preview { display: flex; flex-wrap: wrap; gap: 32px 28px; justify-content: center; align-items: flex-start; padding: 28px 24px 24px; }
.sheet { margin: 0; width: min(var(--sheet-w), 100%); cursor: zoom-in; }
.paper { background: #fff; width: 100%; overflow: hidden; border-radius: 2px; box-shadow: var(--paper-shadow); transition: box-shadow .2s, transform .2s; }
.sheet:hover .paper { box-shadow: 0 0 0 2px var(--accent), var(--paper-shadow); }
.paper canvas { display: block; width: 100%; height: 100%; }
.sheet figcaption { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.tap-hint { text-align: center; color: var(--text-3); font-size: 12.5px; margin: 0 0 40px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; width: max-content; max-width: min(520px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-lg);
  background: #1f2937; color: #fff; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: rise .2s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.mobilebar, .backdrop { display: none; }

/* full-screen page viewer */
.viewer { position: fixed; inset: 0; z-index: 60; background: #16181d; display: flex; flex-direction: column; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #e5e7eb;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid rgba(255,255,255,.08);
}
.viewer-nav { display: flex; align-items: center; gap: 6px; font-size: 14px; font-variant-numeric: tabular-nums; }
.viewer-nav span { min-width: 104px; text-align: center; }
.viewer .icon-btn { color: #d1d5db; width: 40px; height: 40px; }
.viewer .icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.1); color: #fff; }
.viewer-body { flex: 1; overflow: auto; padding: 20px; -webkit-overflow-scrolling: touch; }
.viewer-body canvas { display: block; width: 100%; max-width: 860px; height: auto; margin: 0 auto; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.viewer-body.zoomed canvas { width: 220%; max-width: none; }
body.viewer-open { overflow: hidden; }

.drag-overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none;
  background: rgba(14, 124, 102, .08); box-shadow: inset 0 0 0 3px var(--accent);
}
.drag-overlay div {
  display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-radius: var(--r-lg);
  background: var(--surface); color: var(--accent); font-weight: 600; font-size: 15px; box-shadow: var(--shadow-lg);
}

/* ================= tablets ================= */
@media (max-width: 1040px) {
  .file-meta { display: none; }
  .zoom input { width: 80px; }
}

/* ================= phones ================= */
@media (max-width: 760px) {
  :root { --appbar-h: 56px; }
  html, body { height: auto; }
  body { display: block; min-height: 100dvh; }
  body.has-file { padding-bottom: calc(72px + var(--safe-b)); }

  .appbar { padding: 0 16px; position: sticky; top: 0; }
  .appbar-right .needs-file { display: none; }
  body.has-file .brand-name { display: none; }
  .file-chip { padding: 0 10px; }
  .file-name { max-width: 46vw; }
  #openBtn { height: 36px; padding: 0 12px; }
  body.has-file #openBtn .i { display: none; }

  .layout { display: block; }
  .workspace { overflow: visible; }

  /* settings → bottom sheet */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; width: auto; max-height: 88dvh;
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(16, 24, 40, .22);
    padding: 0 0 calc(12px + var(--safe-b)); overscroll-behavior: contain;
    transform: translateY(105%); visibility: hidden; transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s linear .28s;
  }
  body.settings-open .panel { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  body.settings-open { overflow: hidden; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(16, 24, 40, .4); animation: fade .2s; }
  .panel-head {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2;
    background: var(--surface); padding: 20px 12px 10px 20px; border-bottom: 1px solid var(--border);
  }
  .panel-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
  .grabber { position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--border-strong); }

  /* touch sizes; 16px inputs stop iOS zooming on focus */
  input[type=number], input[type=text], select { height: 44px; font-size: 16px; }
  .inline-input input { height: 40px; width: 84px; }
  .seg button { height: 38px; font-size: 14px; }
  .chip-grid button { height: 42px; font-size: 15px; }
  .switch-row { padding: 10px 0; }
  .switch-row b { font-size: 15px; }
  .switch { width: 44px; height: 26px; }
  .switch::after { width: 22px; height: 22px; }
  .switch:checked::after { transform: translateX(18px); }
  .btn-sm { height: 40px; font-size: 14px; }
  input[type=range] { height: 32px; }
  input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9px; }

  /* summary */
  .summary { flex-wrap: wrap; padding: 12px 16px; gap: 12px; top: var(--appbar-h); }
  .zoom { display: none; }
  .headline strong { font-size: 18px; }
  .quickbar { display: flex; align-items: center; gap: 12px; width: 100%; }
  .quickbar > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
  .chip-row {
    flex: 1; display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r);
    overflow-x: auto; scrollbar-width: none;
  }
  .chip-row::-webkit-scrollbar { display: none; }
  .meta .duplex { display: none; }
  .file-row { padding: 12px 8px 12px 12px; }
  .file-sub input.range-input { height: 36px; width: 130px; font-size: 16px; }
  .icon-btn.sm { width: 36px; height: 36px; }
  .chip-row button {
    flex: 1 0 30px; height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2);
    font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
  }
  .chip-row button.on { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-sm); }

  .empty { padding: 32px 20px 40px; min-height: calc(100dvh - var(--appbar-h)); }
  .empty h1 { font-size: 23px; }
  .lead { font-size: 14.5px; }
  .btn-lg { width: 100%; }
  .drop-note { display: none; }
  .features { grid-template-columns: 1fr; gap: 14px; margin-top: 32px; }

  .preview { gap: 22px; padding: 18px 16px 16px; }
  .sheet { width: 100%; }
  .sheet:hover .paper { box-shadow: var(--paper-shadow); }
  .tap-hint { margin-bottom: 24px; }

  .mobilebar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 8px;
    padding: 10px 16px calc(10px + var(--safe-b)); background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
  .mobilebar .btn { height: 46px; font-size: 15px; }
  .mobilebar #openSettings { flex: 0 0 auto; padding: 0 16px; }
  .mobilebar .btn-icon-only { width: 46px; padding: 0; flex: 0 0 46px; }
  .mobilebar .btn-primary { flex: 1; }
  .toast { bottom: calc(84px + var(--safe-b)); }
}

@media (min-width: 560px) and (max-width: 760px) {
  .sheet { width: calc(50% - 11px); }
}

/* =====================================================================
   Toolkit: tool tabs, per-tool panels, compress results, convert choices
   ===================================================================== */
.paper { aspect-ratio: var(--ar, 210 / 297); }

.tools { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.tools a {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 7px;
  color: var(--text-2); font-weight: 550; font-size: 13.5px; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.tools a:hover { color: var(--text); }
.tools a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tools .i { width: 16px; height: 16px; }
.tools a.on .i { color: var(--accent); }
.tools a:focus-visible, .mobile-tools a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.mobile-tools { display: none; }

.tool-panel { display: none; }
body[data-tool="nup"] .tool-panel[data-tool="nup"],
body[data-tool="merge"] .tool-panel[data-tool="merge"],
body[data-tool="compress"] .tool-panel[data-tool="compress"],
body[data-tool="convert"] .tool-panel[data-tool="convert"] { display: block; }
#filesGroup:not([hidden]) ~ .tool-panel > .group:first-child { border-top: 1px solid var(--border); }
body:not([data-tool="nup"]) .quickbar { display: none !important; }
body[data-tool="compress"] .zoom, body[data-tool="compress"] .preview { display: none !important; }

.seg-4 { grid-template-columns: repeat(4, 1fr); }
.btn-block { width: 100%; height: 42px; }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }
.muted, .arrow { color: var(--text-3); }

.file-thumb { width: 22px; height: 22px; margin-top: 1px; border-radius: 5px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface-2); }

/* compress */
.target-row { display: grid; grid-template-columns: 1fr 112px; gap: 8px; align-items: center; }
.target-row input { height: 38px; font-size: 16px; font-weight: 600; }
.target-row .seg button { height: 32px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preset {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 500; cursor: pointer; font-variant-numeric: tabular-nums;
}
.preset:hover { border-color: var(--accent); color: var(--text); }
.preset.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.results { max-width: 760px; margin: 0 auto; padding: 24px 24px 48px; display: flex; flex-direction: column; gap: 12px; }
.result-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.rc-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-3); }
.result-card.done .rc-icon { background: var(--accent-soft); color: var(--accent); }
.result-card.warn .rc-icon { background: #fff4e5; color: #b54708; }
.rc-body { flex: 1; min-width: 0; }
.rc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-sizes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rc-sizes b { color: var(--text); }
.rc-bar { height: 6px; margin: 10px 0 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.rc-bar span { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.rc-note { margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.rc-note.working { color: var(--accent); }
.rc-note.working::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--accent-ring); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rc-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* convert: choice cards on the empty screen */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 18px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.choice:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.choice .i { width: 22px; height: 22px; margin-bottom: 8px; color: var(--accent); }
.choice b { font-size: 14.5px; }
.choice span { font-size: 12.5px; color: var(--text-3); }

@media (max-width: 1180px) {
  .brand-name { display: none; }
}
@media (max-width: 960px) {
  .tools a { padding: 0 9px; font-size: 13px; gap: 6px; }
  .appbar-right .btn { padding: 0 12px; }
}

@media (max-width: 760px) {
  .tools { display: none; }
  .brand-name, body.has-file .brand-name { display: inline; }
  .mobile-tools {
    display: flex; gap: 4px; padding: 6px 12px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobile-tools::-webkit-scrollbar { display: none; }
  .mobile-tools a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 52px; padding: 0 4px; border-radius: 10px; color: var(--text-2); font-size: 11.5px; font-weight: 550;
    text-decoration: none; white-space: nowrap;
  }
  .mobile-tools a .i { width: 20px; height: 20px; }
  .mobile-tools a.on { background: var(--accent-soft); color: var(--accent); }
  .target-row input { height: 44px; }
  .target-row .seg button { height: 38px; }
  .preset { height: 34px; padding: 0 13px; font-size: 14px; }
  .results { padding: 16px; }
  .result-card { flex-wrap: wrap; }
  .rc-actions { width: 100%; padding-left: 50px; }
  .choice-cards { grid-template-columns: 1fr; }
  .file-thumb { width: 28px; height: 28px; }
}
.target-switch { margin-top: 10px; padding-top: 14px; border-top: 1px dashed var(--border); }
#levelBox[hidden] + .target-switch { margin-top: 0; padding-top: 0; border-top: 0; }
.files-note { margin: -4px 0 12px; }
