/* impeccable · PrintMe! · register: product · v20260610d · Clean · Friendly · Sharp
 * layout: content-left / sidebar-right (desktop) · bottom-nav-cockpit (mobile)
 * accent: oklch(55% 0.24 265) indigo · bg: neutral white · sidebar: cool surface */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }

/* ── Z-index scale ────────────────────────────────────────── */
:root {
  --z-base:           0;
  --z-sticky:        10;
  --z-tabbar:        18;
  --z-printbar:      19;
  --z-header:        20;
  --z-modal-backdrop:50;
  --z-modal:         51;
  --z-toast:         60;
}

/* ── Color tokens (hex fallbacks) ────────────────────────── */
:root {
  --color-bg:        #fafafa;
  --color-surface:   #f3f3f8;
  --color-surface-2: #eaeaf2;
  --color-border:    #dcdce8;
  --color-border-2:  #c8c8d8;
  --color-muted:     #636378;
  --color-subtle:    #4a4a5e;
  --color-ink:       #141419;
  --color-accent:    #4338ca;
  --color-accent-2:  #3730a3;
  --color-accent-bg: #eef2ff;
  --color-accent-ink:#ffffff;
  --color-focus:     #3730a3;
  --color-success:   #15803d;
  --color-danger:    #b91c1c;
  --color-warning-bg:#fffbeb;
  --color-warning-ink:#92400e;

  /* Semantic state tokens */
  --color-btn-hover:     #1e1e2e;
  --color-btn-active:    #16162a;
  --color-outline-brd:   #c8c8da;
  --color-success-bg:    #d1fae5;
  --color-success-brd:   #6ee7b7;
  --color-success-text:  #065f46;
  --color-danger-brd:    #fca5a5;
  --color-danger-lt:     #fee2e2;
  --color-danger-lt-hv:  #fecaca;
  --color-danger-text:   #7f1d1d;
  --color-warn-brd:      #fde68a;
  --color-warn-dot:      #f59e0b;
  --color-accent-brd:    #c7d2fe;
  --color-overlay-bg:    rgba(12,12,22,0.45);
  --shadow-up:           0 -1px 0 #dcdce8, 0 -4px 12px rgba(12,12,22,0.06);
  --shadow-card:         0 2px 8px rgba(12,12,22,0.08);
  --shadow-xs:           0 1px 2px rgba(20,20,25,0.05);
  --shadow-sm:           0 1px 3px rgba(20,20,25,0.07), 0 1px 2px rgba(20,20,25,0.04);

  /* Connection type */
  --color-conn-bt:     #3b82f6;
  --color-conn-usb:    #8b5cf6;
  --color-conn-bridge: #10b981;
}

/* ── OKLCH upgrade ──────────────────────────────────────── */
@supports (color: oklch(0 0 0)) {
  :root {
    --color-bg:        oklch(99.0% 0.001 265);
    --color-surface:   oklch(96.5% 0.004 265);
    --color-surface-2: oklch(93.0% 0.006 265);
    --color-border:    oklch(87.5% 0.006 265);
    --color-border-2:  oklch(82.0% 0.009 265);
    --color-muted:     oklch(50.0% 0.008 265);
    --color-subtle:    oklch(40.0% 0.010 265);
    --color-ink:       oklch( 9.0% 0.013 265);
    --color-accent:    oklch(55.0% 0.240 265);
    --color-accent-2:  oklch(50.0% 0.260 265);
    --color-accent-bg: oklch(97.0% 0.040 265);
    --color-accent-ink:oklch(99.0% 0.002 265);
    --color-focus:     oklch(50.0% 0.260 265);
    --color-success:   oklch(50.0% 0.180 145);
    --color-danger:    oklch(54.0% 0.220  25);
    --color-warning-bg:oklch(97.0% 0.040  75);
    --color-warning-ink:oklch(42.0% 0.140  65);

    --color-btn-hover:     oklch(22%  0.01 265);
    --color-btn-active:    oklch(18%  0.01 265);
    --color-outline-brd:   oklch(80%  0.01 265);
    --color-success-bg:    oklch(96%  0.05 145);
    --color-success-brd:   oklch(82%  0.10 145);
    --color-success-text:  oklch(32%  0.14 145);
    --color-danger-brd:    oklch(88%  0.06  25);
    --color-danger-lt:     oklch(96%  0.04  25);
    --color-danger-lt-hv:  oklch(90%  0.08  25);
    --color-danger-text:   oklch(38%  0.18  25);
    --color-warn-brd:      oklch(85%  0.08  65);
    --color-warn-dot:      oklch(68%  0.17  65);
    --color-accent-brd:    oklch(80%  0.12 265);
    --color-overlay-bg:    oklch(8%   0.01 265 / 0.45);
    --shadow-up:           0 -1px 0 oklch(87.5% 0.006 265),
                           0 -4px 12px oklch(9% 0.013 265 / 0.06);
    --shadow-card:         0 2px 8px oklch(9% 0.013 265 / 0.08);
    --shadow-xs:           0 1px 2px oklch(9% 0.013 265 / 0.05);
    --shadow-sm:           0 1px 3px oklch(9% 0.013 265 / 0.07),
                           0 1px 2px oklch(9% 0.013 265 / 0.04);

    --color-conn-bt:     oklch(62% 0.20 265);
    --color-conn-usb:    oklch(58% 0.18 305);
    --color-conn-bridge: oklch(56% 0.17 172);
  }
}

/* ── Dark mode ─────────────────────────────────────────── */
body.dark {
  --color-bg:        #131318;
  --color-surface:   #1c1c24;
  --color-surface-2: #252530;
  --color-border:    #32323e;
  --color-border-2:  #3e3e4e;
  --color-muted:     #7070a0;
  --color-subtle:    #b0b0d4;
  --color-ink:       #f0f0fc;
  --color-accent:    #818cf8;
  --color-accent-2:  #a5b4fc;
  --color-accent-bg: #1e1e3a;
  --color-accent-ink:#0f0f1e;
  --color-focus:     #a5b4fc;
  --color-success:   #4ade80;
  --color-danger:    #f87171;
  --color-warning-bg:#1c1a0e;
  --color-warning-ink:#fcd34d;
  --color-btn-hover:     #e0e0f8;
  --color-btn-active:    #c7c7f0;
  --shadow-xs:           0 1px 2px rgba(0,0,0,0.5);
  --shadow-sm:           0 1px 4px rgba(0,0,0,0.6);
  --shadow-up:           0 -1px 0 #32323e, 0 -4px 12px rgba(0,0,0,0.3);
  --shadow-card:         0 2px 8px rgba(0,0,0,0.4);
  --color-overlay-bg:    rgba(0,0,0,0.6);
  --color-success-bg:    #064e3b;
  --color-success-brd:   #065f46;
  --color-success-text:  #6ee7b7;
  --color-danger-lt:     #450a0a;
  --color-danger-lt-hv:  #7f1d1d;
  --color-danger-text:   #fca5a5;
  --color-danger-brd:    #7f1d1d;
  --color-warn-brd:      #78350f;
  --color-warn-dot:      #fbbf24;
  --color-accent-brd:    #4338ca;
}

@supports (color: oklch(0 0 0)) {
  body.dark {
    --color-bg:        oklch(10%  0.012 265);
    --color-surface:   oklch(15%  0.014 265);
    --color-surface-2: oklch(19%  0.016 265);
    --color-border:    oklch(24%  0.013 265);
    --color-border-2:  oklch(30%  0.012 265);
    --color-muted:     oklch(52%  0.010 265);
    --color-subtle:    oklch(72%  0.009 265);
    --color-ink:       oklch(96%  0.005 270);
    --color-accent:    oklch(72%  0.18  265);
    --color-accent-2:  oklch(78%  0.16  265);
    --color-accent-bg: oklch(18%  0.09  265);
    --color-accent-ink:oklch( 8%  0.015 265);
    --color-focus:     oklch(78%  0.16  265);
    --color-success:   oklch(64%  0.17  145);
    --color-danger:    oklch(68%  0.19   25);
    --color-warning-bg:oklch(18%  0.07   65);
    --color-warning-ink:oklch(78%  0.14  65);
    --color-success-bg:    oklch(20%  0.09 145);
    --color-success-brd:   oklch(28%  0.12 145);
    --color-success-text:  oklch(72%  0.16 145);
    --color-danger-lt:     oklch(16%  0.10  25);
    --color-danger-lt-hv:  oklch(26%  0.12  25);
    --color-danger-text:   oklch(74%  0.16  25);
    --color-danger-brd:    oklch(28%  0.12  25);
    --color-warn-brd:      oklch(30%  0.10  65);
    --color-warn-dot:      oklch(72%  0.16  65);
    --color-accent-brd:    oklch(30%  0.12 265);
    --shadow-xs:           0 1px 2px oklch(4% 0.01 265 / 0.5);
    --shadow-sm:           0 1px 4px oklch(4% 0.01 265 / 0.6);
    --shadow-up:           0 -1px 0 oklch(24% 0.013 265),
                           0 -4px 12px oklch(4% 0.01 265 / 0.3);
    --shadow-card:         0 2px 8px oklch(4% 0.01 265 / 0.4);
    --color-overlay-bg:    oklch(4% 0.005 265 / 0.6);
  }
}

/* ── Typography + spacing + easing ──────────────────────── */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
               "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;

  --space-2xs: 0.25rem;  --space-xs: 0.5rem;   --space-sm: 0.75rem;
  --space-md:  1rem;     --space-lg: 1.5rem;   --space-xl: 2.25rem;
  --space-2xl: 3.5rem;

  --text-2xs: 0.625rem;  /* 10px */
  --text-xs:  0.75rem;   /* 12px */
  --text-sm:  0.8125rem; /* 13px */
  --text-md:  0.9375rem; /* 15px */
  --text-lg:  1.0625rem; /* 17px */

  --radius-xs: 3px;  --radius-sm: 6px;  --radius-md: 9px;
  --radius-lg: 14px; --radius-pill: 999px;

  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-short:   140ms;
  --dur-mid:     200ms;
}

/* ── Base ──────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.55;
  background: var(--color-bg);
  color: var(--color-ink);
  min-height: 100dvh;
  padding-bottom: calc(48px + 52px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
input, select, textarea, button {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--color-ink);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  background: var(--color-accent);
  border-bottom: none;
  padding: 0 var(--space-md);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}
.app-header .icon { font-size: 15px; opacity: 0.5; flex-shrink: 0; }
.app-header .header-logo { width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; object-fit: contain; box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff;
  flex: 1;
}
.btn-dark-toggle {
  width: 30px; height: 30px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur-short) var(--ease-out);
  flex-shrink: 0;
}
.btn-dark-toggle:hover { background: var(--color-surface); }
.btn-dark-toggle:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn-help {
  width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.12);
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  flex-shrink: 0;
  transition: background var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.btn-help:hover { background: rgba(255,255,255,0.22); color: #ffffff; }
/* ── Install button ──────────────────────────────────────── */
.btn-install {
  width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.18);
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  transition: background var(--dur-short) var(--ease-out);
  animation: pulse-install 2s ease-in-out 3;
}
.btn-install:hover { background: rgba(255,255,255,0.28); opacity: 1; }
.btn-install:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
@keyframes pulse-install {
  0%, 100% { box-shadow: 0 0 0 0 var(--color-accent-bg); }
  50% { box-shadow: 0 0 0 4px var(--color-accent-bg); }
}


/* ── Mobile layout ─────────────────────────────────────── */
.main {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 500px;
  margin: 0 auto;
}

/* ── Tab nav — fixed bottom bar (mobile) ───────────────── */
.tab-nav {
  position: fixed;
  bottom: calc(52px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  z-index: var(--z-tabbar);
  display: flex;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: 4px var(--space-xs);
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out);
  letter-spacing: -0.01em;
}
.tab-btn.active {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  font-weight: 600;
}
.tab-btn:hover:not(.active) { background: var(--color-surface); color: var(--color-ink); }
.tab-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Print bar — fixed bottom (mobile) ─────────────────── */
.action-row {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-printbar);
  display: flex;
  gap: var(--space-xs);
  align-items: stretch;
  padding: var(--space-xs) var(--space-md) calc(var(--space-xs) + env(safe-area-inset-bottom));
  background: var(--color-bg);
  box-shadow: var(--shadow-up);
}
.action-row .btn { flex-shrink: 0; height: 40px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Section labels — sidebar/tool style, not eyebrow */
.card-title {
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--color-muted);
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: var(--space-sm);
}

/* ── Status badge ──────────────────────────────────────── */
.status-row { display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; margin-bottom: var(--space-sm); }
.status-badge {
  font-size: var(--text-xs); font-weight: 500;
  padding: 3px var(--space-xs);
  border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-subtle);
  border: 1px solid var(--color-border);
  display: inline-flex; align-items: center; gap: 5px;
  letter-spacing: -0.01em;
}
.status-badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: var(--color-muted); flex-shrink: 0;
}
.status-badge[data-state="connected"] {
  background: var(--color-success-bg);
  border-color: var(--color-success-brd);
  color: var(--color-success-text);
}
.status-badge[data-state="connected"]::before { background: var(--color-success); }
.status-badge[data-state="reconnecting"],
.status-badge[data-state="connecting"] {
  background: var(--color-warning-bg); border-color: var(--color-warn-brd); color: var(--color-warning-ink);
}
.status-badge[data-state="reconnecting"]::before,
.status-badge[data-state="connecting"]::before {
  background: var(--color-warn-dot); animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.35 } }
.device-name { font-size: var(--text-xs); color: var(--color-muted); font-style: italic; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-xs);
  padding: 7px var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--text-sm); font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out);
  white-space: nowrap;
  letter-spacing: -0.01em;
  text-decoration: none;
  -webkit-user-select: none; user-select: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.btn-primary {
  background: var(--color-ink); color: var(--color-bg); border-color: var(--color-ink);
}
.btn-primary:hover:not(:disabled) { background: var(--color-btn-hover); border-color: var(--color-btn-hover); }
.btn-primary:active:not(:disabled) { background: var(--color-btn-active); }

.btn-outline {
  background: var(--color-bg); color: var(--color-subtle); border-color: var(--color-border);
}
.btn-outline:hover:not(:disabled) { background: var(--color-surface); border-color: var(--color-border-2); color: var(--color-ink); }
.btn-outline:active:not(:disabled) { background: var(--color-surface-2); }

.btn-danger {
  background: var(--color-bg); color: var(--color-danger);
  border-color: var(--color-danger-brd); width: 100%; margin-top: var(--space-xs);
}
.btn-danger:hover:not(:disabled) { background: var(--color-danger-lt); }

/* ── Connection section ────────────────────────────────── */
.conn-btns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
.conn-btn {
  width: 100%;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: -0.01em;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px var(--space-sm);
  color: var(--color-subtle);
}
.conn-btn::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%; flex-shrink: 0;
}
#btn-connect-bt::before    { background: var(--color-conn-bt); }
#btn-connect-usb::before   { background: var(--color-conn-usb); }
#btn-connect-bridge::before { background: var(--color-conn-bridge); }
.conn-btn:hover::before { opacity: 0.65; }
.conn-btn-wide { grid-column: 1 / -1; }
#bridge-input-row { margin-top: var(--space-xs); }
.bridge-row { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.bridge-row input { min-width: 0; flex-basis: 160px; }
.bridge-row .btn  { flex-shrink: 0; }
.bridge-row input {
  flex: 1; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 7px var(--space-sm);
  font-size: var(--text-sm); font-family: var(--font-mono);
  background: var(--color-surface);
  transition: border-color var(--dur-short) var(--ease-out);
}
.bridge-row input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg); }
#bridge-port-picker { display: flex; gap: var(--space-xs); margin-top: var(--space-xs); align-items: center; }
#bridge-port-select { flex: 1; }
.paper-row { display: flex; gap: var(--space-md); align-items: center; flex-wrap: wrap; margin-top: var(--space-sm); }
.paper-opt { display: flex; align-items: center; gap: var(--space-xs); }
.paper-opt label { font-size: var(--text-xs); color: var(--color-muted); white-space: nowrap; }

/* ── Print button ──────────────────────────────────────── */
.btn-print {
  flex: 1; height: 40px;
  font-size: var(--text-sm); font-weight: 600; letter-spacing: -0.01em;
  border: none; border-radius: var(--radius-sm);
  background: var(--color-accent); color: var(--color-accent-ink);
  cursor: pointer;
  transition: background var(--dur-short) var(--ease-out),
              transform var(--dur-short) var(--ease-out);
}
.btn-print:hover:not(:disabled) { background: var(--color-accent-2); }
.btn-print:active:not(:disabled) { transform: translateY(1px); }
.btn-print:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-print:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* ── Selects ───────────────────────────────────────────── */
select {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 5px 24px 5px var(--space-xs);
  font-size: var(--text-xs); background: var(--color-surface); cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6' fill='none' stroke='%239090a8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
select:focus { outline: 2px solid var(--color-focus); outline-offset: 1px; border-color: var(--color-accent); }

/* ── Text editor ───────────────────────────────────────── */
.size-row { display: flex; gap: var(--space-xs); align-items: center; margin-bottom: var(--space-sm); flex-wrap: wrap; }
.size-row label { font-size: var(--text-xs); color: var(--color-muted); }
.size-row input[type=number] {
  width: 48px; padding: 4px 6px;
  border: 1px solid var(--color-border); border-radius: var(--radius-xs);
  font-size: var(--text-sm); text-align: center; background: var(--color-surface);
}
.fmt-toolbar { display: flex; gap: 4px; margin-bottom: var(--space-sm); flex-wrap: wrap; align-items: center; }
.fmt-divider { width: 1px; background: var(--color-border); height: 22px; margin: 0 2px; }
.fmt-btn, .align-btn {
  padding: 4px 8px; border: 1px solid var(--color-border);
  border-radius: var(--radius-xs); background: var(--color-surface);
  font-size: var(--text-sm); cursor: pointer; color: var(--color-subtle);
  transition: background var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out);
  font-family: var(--font-sans); font-weight: 500;
}
.fmt-btn.active, .align-btn.active {
  background: var(--color-accent-bg); border-color: var(--color-accent-brd); color: var(--color-accent);
}
.fmt-btn:hover:not(.active), .align-btn:hover:not(.active) { background: var(--color-surface-2); color: var(--color-ink); }
.fmt-btn:focus-visible, .align-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }

textarea {
  width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-sm); font-size: var(--text-sm); resize: vertical; min-height: 120px;
  font-family: var(--font-mono); background: var(--color-surface);
  transition: border-color var(--dur-short) var(--ease-out); line-height: 1.6;
}
/* ── Paper editor frame ─────────────────────────────────── */
.text-toolbar { display:flex; flex-direction:column; gap:var(--space-xs); margin-bottom:var(--space-sm); }
#panel-text.active { display:flex; flex-direction:column; }
.editor-outer-frame {
  flex:1; min-height:260px;
  background:var(--color-surface); border-radius:var(--radius-sm);
  overflow:auto; display:flex; justify-content:center; align-items:stretch;
  padding:var(--space-md);
}
.editor-paper {
  background:var(--color-bg); box-shadow:0 1px 3px rgba(0,0,0,0.12),0 0 0 1px var(--color-border);
  border-radius:2px; padding:12px;
  font-family:var(--font-mono); font-size:14px;
  width:32ch; min-width:100px; min-height:240px;
  box-sizing:content-box; display:flex; flex-direction:column;
}
#text-input {
  flex:1; width:100%; min-height:220px;
  border:none !important; outline:none !important; box-shadow:none !important;
  background:transparent !important; padding:0 !important;
  font-family:inherit; font-size:inherit; line-height:1.6;
  resize:none; color:var(--color-ink); overflow-y:auto;
}
#text-input:focus { border:none !important; box-shadow:none !important; }
textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg); }
.char-counter { font-size: var(--text-2xs); color: var(--color-muted); text-align: right; margin-top: var(--space-2xs); font-variant-numeric: tabular-nums; }

/* ── Image editor ──────────────────────────────────────── */
.img-zone {
  border: 1px dashed var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-xl); text-align: center; cursor: pointer;
  transition: background var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
  position: relative; min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--color-surface);
}
.img-zone:hover, .img-zone.drag-over { border-color: var(--color-accent); background: var(--color-accent-bg); }
.img-placeholder { color: var(--color-muted); font-size: var(--text-sm); pointer-events: none; }
.img-placeholder .icon { font-size: 26px; display: block; margin-bottom: var(--space-xs); opacity: 0.45; }
#img-preview { max-width: 100%; border-radius: var(--radius-sm); }
#img-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#img-editor {
  margin-top: var(--space-sm); padding: var(--space-sm);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
}
.editor-row { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-xs); }
.editor-row label { font-size: var(--text-xs); color: var(--color-muted); width: 88px; flex-shrink: 0; }
.editor-row input[type=range] { flex: 1; accent-color: var(--color-accent); }
.slider-val { font-size: var(--text-xs); color: var(--color-subtle); width: 28px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.editor-btns { display: flex; gap: var(--space-xs); flex-wrap: wrap; margin-top: var(--space-xs); }
.editor-btns .btn { font-size: var(--text-xs); padding: 4px 9px; }

/* ── Barcode validation ────────────────────────────────── */
.bc-validation { font-size: var(--text-xs); margin-top: var(--space-2xs); min-height: 14px; }
.bc-valid   { color: var(--color-success); }
.bc-invalid { color: var(--color-danger); }

/* ── Table editor ──────────────────────────────────────── */
.table-config-row { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-sm); font-size: var(--text-xs); color: var(--color-muted); }
.tbl-editor-table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); margin-bottom: var(--space-xs); }
.tbl-editor-table th, .tbl-editor-table td { border: 1px solid var(--color-border); padding: 0; }
.tbl-editor-table input { width: 100%; border: none; padding: 5px var(--space-xs); background: transparent; font-family: var(--font-mono); font-size: var(--text-xs); }
.tbl-editor-table input:focus { outline: none; background: var(--color-accent-bg); }
.tbl-editor-table th input { font-weight: 600; }
.tbl-editor-table .tbl-del-row { width: 28px; }

/* ── Field groups ──────────────────────────────────────── */
.field-group { margin-bottom: var(--space-sm); }
.field-group label { display: block; font-size: var(--text-xs); color: var(--color-muted); margin-bottom: 3px; font-weight: 500; }
.field-group input[type=text],
.field-group input[type=number],
.field-group textarea,
.field-group select {
  width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 7px var(--space-sm); font-size: var(--text-sm); background: var(--color-surface);
  transition: border-color var(--dur-short) var(--ease-out);
}
.field-group input:focus, .field-group textarea:focus, .field-group select:focus {
  outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-bg);
}
.inline-row { display: flex; gap: var(--space-sm); }
.inline-row .field-group { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); cursor: pointer; }
.checkbox-row input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--color-accent); }

/* ── Combined blocks ───────────────────────────────────── */
.block-add-bar { display: flex; gap: var(--space-xs); flex-wrap: wrap; margin-bottom: var(--space-sm); }
.btn-add-block {
  padding: 4px 9px; border: 1px solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-subtle);
  font-size: var(--text-xs); font-weight: 500; cursor: pointer;
  transition: background var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out);
  font-family: var(--font-sans);
}
.btn-add-block:hover { background: var(--color-accent-bg); border-color: var(--color-accent-brd); color: var(--color-accent); }
.btn-add-block:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.block-empty { font-size: var(--text-sm); color: var(--color-muted); text-align: center; padding: var(--space-xl) 0; }
.block-card { border: 1px solid var(--color-border); border-radius: var(--radius-sm); margin-bottom: var(--space-xs); overflow: hidden; transition: box-shadow var(--dur-short) var(--ease-out); }
.block-card.drag-over { box-shadow: 0 0 0 2px var(--color-accent); }
.block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-xs) var(--space-sm); background: var(--color-surface);
  cursor: grab; user-select: none; gap: var(--space-xs);
}
.block-header:active { cursor: grabbing; }
.drag-handle { color: var(--color-muted); font-size: 14px; cursor: grab; flex-shrink: 0; }
.block-type-label { font-size: var(--text-xs); font-weight: 600; color: var(--color-subtle); flex: 1; }
.block-controls { display: flex; gap: 3px; }
.btn-icon {
  width: 24px; height: 24px; border: none; border-radius: var(--radius-xs);
  background: var(--color-surface-2); color: var(--color-subtle); font-size: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--dur-short) var(--ease-out);
}
.btn-icon:hover { background: var(--color-border); }
.btn-icon:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.btn-icon-danger { background: var(--color-danger-lt); color: var(--color-danger); }
.btn-icon-danger:hover { background: var(--color-danger-lt-hv); }
.block-body { padding: var(--space-sm); display: none; }
.block-body.open { display: block; }
.combined-actions { display: flex; gap: var(--space-xs); margin-top: var(--space-sm); flex-wrap: wrap; }
.combined-actions .btn { font-size: var(--text-xs); padding: 5px var(--space-sm); }

/* ── Templates ─────────────────────────────────────────── */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-xs); margin-bottom: var(--space-sm); }
.tpl-card {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-xs); text-align: center; cursor: pointer;
  transition: background var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
  background: var(--color-surface);
}
.tpl-card:hover { border-color: var(--color-accent-brd); background: var(--color-surface-2); }
.tpl-card.selected { border-color: var(--color-accent); background: var(--color-accent-bg); }
.tpl-icon { font-size: 20px; display: block; margin-bottom: 3px; }
.tpl-name { font-size: var(--text-xs); font-weight: 600; color: var(--color-subtle); }
.tpl-card.selected .tpl-name { color: var(--color-accent); }
.tpl-card:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.custom-tpl-list { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: var(--space-xs); }
.custom-tpl-item {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
}
.custom-tpl-item span { flex: 1; font-size: var(--text-sm); }
.tpl-io-row { display: flex; gap: var(--space-xs); margin-top: var(--space-md); flex-wrap: wrap; }
.tpl-io-row .btn { font-size: var(--text-xs); padding: 5px var(--space-sm); }

/* ── Receipt ────────────────────────────────────────────── */
.receipt-items-header {
  display: grid; grid-template-columns: 1fr 52px 90px 28px; gap: var(--space-xs);
  padding: 0 0 var(--space-2xs);
  font-size: var(--text-2xs); font-weight: 600; color: var(--color-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.receipt-item {
  display: grid; grid-template-columns: 1fr 52px 90px 28px;
  gap: var(--space-xs); margin-bottom: var(--space-xs); align-items: center;
}
.receipt-item input {
  border: 1px solid var(--color-border); border-radius: var(--radius-xs);
  padding: 5px var(--space-xs); font-size: var(--text-sm); width: 100%;
  background: var(--color-surface);
  transition: border-color var(--dur-short) var(--ease-out);
}
.receipt-item input:focus { outline: none; border-color: var(--color-accent); }
.btn-add-item {
  width: 100%; padding: 6px; margin-top: var(--space-2xs);
  border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
  background: transparent; color: var(--color-muted);
  font-size: var(--text-xs); font-weight: 500; cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out),
              background-color var(--dur-short) var(--ease-out);
  font-family: var(--font-sans);
}
.btn-add-item:hover { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-bg); }
.btn-add-item:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.receipt-extras {
  display: flex; gap: var(--space-md); flex-wrap: wrap; margin: var(--space-sm) 0;
  padding: var(--space-sm); background: var(--color-surface);
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
}
.receipt-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-sm) 0 0; margin-top: var(--space-xs);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-md); font-weight: 600; letter-spacing: -0.01em;
}

/* ── Catalog ────────────────────────────────────────────── */
.catalog-bar {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface); border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); margin-bottom: var(--space-sm);
  overflow-x: auto; scrollbar-width: none;
}
.catalog-bar::-webkit-scrollbar { display: none; }
.catalog-label { font-size: var(--text-2xs); font-weight: 700; color: var(--color-muted); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.05em; }
.catalog-chips { display: flex; gap: var(--space-2xs); flex: 1; overflow-x: auto; scrollbar-width: none; }
.catalog-chips::-webkit-scrollbar { display: none; }
.catalog-chip {
  padding: 3px var(--space-xs); border-radius: var(--radius-pill);
  background: var(--color-accent); color: var(--color-accent-ink);
  font-size: var(--text-xs); font-weight: 500; cursor: pointer;
  white-space: nowrap; border: none;
  transition: opacity var(--dur-short) var(--ease-out); font-family: var(--font-sans);
}
.catalog-chip:hover { opacity: 0.8; }
.catalog-chip:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.catalog-add-form { display: flex; gap: var(--space-xs); margin-bottom: var(--space-sm); flex-wrap: wrap; }
.catalog-add-form input {
  flex: 1; min-width: 80px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 7px var(--space-sm); font-size: var(--text-sm); background: var(--color-surface);
}
.catalog-add-form input:focus { outline: none; border-color: var(--color-accent); }
.catalog-list { display: flex; flex-direction: column; gap: var(--space-xs); }
.catalog-item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
}
.catalog-item-name { flex: 1; font-size: var(--text-sm); }
.catalog-item-price { font-size: var(--text-sm); color: var(--color-muted); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Print options ─────────────────────────────────────── */
.options-row { display: flex; gap: var(--space-md); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-sm); }
.option-item { display: flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-sm); }
.option-item input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--color-accent); cursor: pointer; }
.option-item input[type=number] {
  width: 46px; padding: 3px 6px;
  border: 1px solid var(--color-border); border-radius: var(--radius-xs);
  font-size: var(--text-sm); text-align: center; background: var(--color-surface);
}
.option-item input[type=number]:focus { outline: none; border-color: var(--color-accent); }

/* ── Progress ───────────────────────────────────────────── */
.progress-bar-wrap {
  display: flex; align-items: center; gap: var(--space-xs); margin-bottom: var(--space-xs);
  background: var(--color-surface); border-radius: var(--radius-pill);
  padding: 4px var(--space-sm); border: 1px solid var(--color-border);
}
.progress-bar { height: 4px; background: var(--color-accent); border-radius: var(--radius-pill); transition: width var(--dur-short) linear; min-width: 0; }
.progress-label { font-size: var(--text-2xs); color: var(--color-muted); white-space: nowrap; min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.queue-badge { font-size: var(--text-xs); color: var(--color-muted); padding-bottom: var(--space-sm); }

/* ── Print log ──────────────────────────────────────────── */
.print-log { display: flex; flex-direction: column; gap: 3px; }
.log-entry {
  font-size: var(--text-xs); padding: 3px var(--space-xs); border-radius: var(--radius-xs);
  background: var(--color-surface); color: var(--color-muted); font-family: var(--font-mono);
}
.log-success { background: var(--color-success-bg); color: var(--color-success-text); }
.log-error   { background: var(--color-danger-lt);  color: var(--color-danger-text); }
.log-warn    { background: var(--color-warning-bg); color: var(--color-warning-ink); }

/* ── History ────────────────────────────────────────────── */
.history-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
#history-chevron { font-size: var(--text-xs); color: var(--color-muted); transition: transform var(--dur-short) var(--ease-out); }
#history-chevron.open { transform: rotate(180deg); }
.history-list { margin-top: var(--space-sm); display: flex; flex-direction: column; gap: var(--space-xs); }
.history-item {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
}
.history-item-info { flex: 1; min-width: 0; }
.history-item-label { font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-ts { font-size: var(--text-2xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.history-item-actions { display: flex; gap: 3px; flex-shrink: 0; }
.history-empty { font-size: var(--text-sm); color: var(--color-muted); text-align: center; padding: var(--space-md) 0; }

/* ── Note ───────────────────────────────────────────────── */
.note {
  font-size: var(--text-2xs); color: var(--color-muted);
  background: var(--color-surface); border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm); margin-top: var(--space-xs);
  border: 1px solid var(--color-border); line-height: 1.6;
  overflow-wrap: anywhere; min-width: 0;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--color-overlay-bg);
  backdrop-filter: blur(3px);
  z-index: var(--z-modal-backdrop);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 480px; max-height: 88dvh;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md); border-bottom: 1px solid var(--color-border);
  font-weight: 600; font-size: var(--text-md); letter-spacing: -0.01em;
}
.modal-close {
  width: 26px; height: 26px; border: 1px solid var(--color-border); border-radius: 50%;
  background: var(--color-surface); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-subtle); transition: background var(--dur-short) var(--ease-out);
}
.modal-close:hover { background: var(--color-surface-2); }
.modal-close:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.modal-body { flex: 1; overflow-y: auto; padding: 0; }
.modal-footer { padding: var(--space-sm) var(--space-md); border-top: 1px solid var(--color-border); }
.modal-footer .btn-print { width: 100%; border-radius: var(--radius-md); height: 44px; }

/* ── Preview paper ──────────────────────────────────────── */
.preview-wrap {
  display: flex; justify-content: center;
  background: transparent; border-radius: 0; padding: 0;
}
.preview-paper {
  background: var(--color-bg); color: var(--color-ink);
  box-shadow: none;
  width: 100%; max-width: none; min-height: 120px;
  padding: var(--space-md); font-family: var(--font-mono); font-size: 11px; line-height: 1.55;
}
.preview-paper.w80 { max-width: none; }
.prev-text { word-break: break-all; white-space: pre-wrap; }
.prev-img { width: 100%; filter: grayscale(1) contrast(1.2); display: block; }
.prev-qr { width: 80px; height: 80px; border: 2px solid var(--color-ink); display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--color-muted); margin: 4px auto; }
.prev-barcode { height: 48px; background: repeating-linear-gradient(90deg,#000 0,#000 2px,#fff 2px,#fff 5px); margin: 4px 0; }
.prev-barcode-text { text-align: center; font-size: 9px; margin-top: 2px; }
.prev-separator { border-top: 1px dashed var(--color-border); margin: 4px 0; }
.prev-spacer { height: 11px; }

/* ══════════════════════════════════════════════════════════
   DESKTOP LAYOUT — content-left / sidebar-right
   ══════════════════════════════════════════════════════════ */
@media (min-width: 48rem) {

  body { padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom)); }

  /* ── Grid: content left (flex), sidebar right (220px) ── */
  .main {
    display: grid;
    grid-template-columns: 1fr 220px;
    grid-template-areas:
      "tabnav  conn"
      "panel   conn"
      "panel   opts"
      "hist    acts";
    grid-template-rows: auto 1fr auto auto;
    max-width: 960px;
    padding: 0;
    gap: 0;
    align-items: start;
  }

  /* ── Content column ──────────────────────────────────── */
  #main-tab-nav { grid-area: tabnav; }
  .tab-panel    { grid-area: panel; }
  #history-card { grid-area: hist; }

  /* ── Sidebar column ──────────────────────────────────── */
  #connection-card { grid-area: conn; }
  #options-card    { grid-area: opts; }
  #main-actions    { grid-area: acts; }

  /* Content column padding */
  #main-tab-nav { padding: 0 var(--space-lg); }
  .tab-panel    { padding: var(--space-md) var(--space-lg); }
  #history-card {
    margin: 0 var(--space-lg) var(--space-md);
    background: transparent; border: none; border-top: 1px solid var(--color-border); border-radius: 0; padding: var(--space-md) 0;
  }

  /* ── Sidebar styling ─────────────────────────────────── */
  #connection-card,
  #options-card,
  #main-actions {
    background: var(--color-surface);
    border: none;
    border-radius: 0;
    border-left: 1px solid var(--color-border);
  }
  #connection-card {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 60px;
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
  }
  #options-card {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
  }
  #main-actions {
    position: sticky;
    bottom: 0;
    padding: var(--space-sm) var(--space-md);
    border-top: none;
    box-shadow: none;
    background: var(--color-surface);
    flex-direction: column;
    gap: 4px;
  }
  #main-actions .btn {
    height: 32px;
    width: 100%;
    font-size: var(--text-xs);
  }
  .btn-print {
    height: 38px;
    flex: none;
    margin-top: 2px;
    border-radius: var(--radius-sm);
  }

  /* ── Connection sidebar tweaks ────────────────────────── */
  .conn-btns {
    grid-template-columns: 1fr; /* single col in 220px sidebar */
  }
  .conn-btn-wide { grid-column: 1; }
  .card-title { margin-bottom: var(--space-xs); }

  /* ── Tab nav — underline style (Linear) ─────────────── */
  .tab-nav {
    position: static;
    bottom: auto; left: auto; right: auto;
    z-index: var(--z-base);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    padding: 0 0 0 var(--space-xs);
    gap: 0;
    box-shadow: none;
  }
  .tab-btn {
    padding: 8px 10px;
    border-radius: 0;
    background: transparent;
    color: var(--color-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    letter-spacing: -0.01em;
  }
  .tab-btn.active {
    background: transparent;
    color: var(--color-ink);
    font-weight: 600;
    border-bottom-color: var(--color-accent);
    box-shadow: none;
  }
  .tab-btn:hover:not(.active) {
    background: transparent;
    color: var(--color-subtle);
    border-bottom-color: var(--color-border-2);
  }

  /* ── Tab panels — no card chrome on desktop ──────────── */
  .tab-panel {
    border: none;
    border-radius: 0;
    background: transparent;
  }
  /* panel fills grid row height */
  .main {
    min-height: calc(100dvh - 60px);
    grid-template-rows: auto 1fr auto auto;
    align-items: stretch;
  }
  #panel-text.active { height: 100%; }
  .editor-outer-frame { min-height: 0; }

  /* Cancel mobile fixed styles */
  .action-row {
    position: static;
    bottom: auto; left: auto; right: auto;
    z-index: var(--z-base);
    box-shadow: none;
    border-top: none;
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
}


/* ── App dialogs (native <dialog> confirm + prompt) ───────────────────────── */
.app-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  background: var(--color-bg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  max-width: 320px;
  width: calc(100vw - 48px);
}
.app-dialog::backdrop {
  background: var(--color-overlay-bg);
  backdrop-filter: blur(3px);
}
.app-dialog-msg {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--color-ink);
  margin: 0 0 var(--space-md);
  line-height: 1.5;
}
.app-dialog-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  background: var(--color-surface);
  color: var(--color-ink);
  margin-bottom: var(--space-md);
  transition: border-color var(--dur-short) var(--ease-out);
}
.app-dialog-input:focus {
  outline: none;
  border-color: var(--color-accent);
}
.app-dialog-btns {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}
.btn-danger-outline {
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-danger-outline:hover {
  background: var(--color-danger);
  color: #fff;
}


/* ── Mid-size (600px-767px): tablet / large phone landscape ────────────────── */
@media (min-width: 37.5rem) and (max-width: 47.9375rem) {
  .tab-panel { padding: var(--space-md); }
  .tab-btn { padding: 6px 10px; font-size: var(--text-sm); }
  .size-row { flex-wrap: nowrap; }
}

/* ── Narrow screen ──────────────────────────────────────── */
@media (max-width: 375px) {
  .receipt-items-header,
  .receipt-item { grid-template-columns: 1fr 78px 24px; }
  .receipt-col-qty { display: none; }
  .receipt-item .item-qty { display: none; }
}

/* ── History PDF button ─────────────────────────────────────── */
.btn-history-pdf { padding: 3px 10px; font-size: 12px; margin-right: 4px; line-height: 1.4; }
.history-header-right { display: flex; align-items: center; gap: 4px; }

/* ── Image mode selector ────────────────────────────────────── */
.img-mode-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.img-mode-row label { font-size: 13px; color: var(--color-muted); min-width: 64px; }
.img-mode-row select { flex: 1; padding: 5px 8px; border: 1px solid var(--color-border); border-radius: 6px; font-size: 13px; background: var(--color-surface); }

/* ── PDF tab ──────────────────────────────────────────────────────── */
.pdf-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px;
}
.pdf-thumb {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--color-border);
  flex: 0 0 auto;
  transition: border-color 0.15s;
  opacity: 0.5;
}
.pdf-thumb.selected { border-color: var(--color-accent); opacity: 1; }
.pdf-thumb canvas { display: block; width: 72px; height: auto; }
.pdf-thumb-num {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  line-height: 1.4;
}


/* ── Teks→Img panel ────────────────────────────────────────────────────────── */
#panel-textimg textarea { font-family: var(--font-sans); min-height: 80px; }
.textimg-preview-label {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--color-muted); margin: var(--space-sm) 0 4px;
}
.textimg-preview-wrap {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 60px;
  overflow: auto;
}
#textimg-canvas {
  display: block;
  max-width: 100%;
  image-rendering: pixelated;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
}
