:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --error: #b91c1c;
  --tape: #d9dce1;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #1a1d23;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #2b2f37;
    --accent: #3b82f6;
    --ok: #4ade80;
    --error: #f87171;
    --tape: #3a3f48;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #1a1d23;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #2b2f37;
  --accent: #3b82f6;
  --ok: #4ade80;
  --error: #f87171;
  --tape: #3a3f48;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  max-width: 640px;
  margin: 0 auto;
}
.top h1 { margin: 0; font-size: 1.35rem; }
.top .help { margin-left: auto; color: var(--accent); }
.model { color: var(--muted); font-size: .9rem; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h2 { margin: 0; font-size: 1.05rem; }
h3 { margin: 0 0 2px; font-size: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card > p { margin: 0; }

.muted { color: var(--muted); font-size: .88rem; }
.empty { margin: 0; }

.printer-head { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot[data-on="1"] { background: var(--ok); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

button {
  font: inherit;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }

input[type="password"], input[type="number"], input[type="email"], input[type="text"] {
  font: inherit;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
#mcp-url { flex: 1; min-width: 0; }
input[type="number"] { width: 72px; }
input[type="file"] { max-width: 100%; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

#jobs { display: flex; flex-direction: column; gap: 12px; }

.preview {
  background: var(--tape);
  border-radius: 6px;
  padding: 8px;
  overflow-x: auto;
}
.preview canvas {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #fff;
}

.opts { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.opts label { display: inline-flex; align-items: center; gap: 8px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.tape-warn { margin: 0; color: var(--error); font-weight: 600; }

.message { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.message[data-kind="ok"] { color: var(--ok); }
.message[data-kind="error"] { color: var(--error); }

.progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .progress span { animation: none; width: 100%; } }

.upload { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; }
.chips button { min-height: 36px; padding: 0 12px; border-radius: 18px; white-space: nowrap; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary h2::after { content: " ▸"; color: var(--muted); }
details[open] summary h2::after { content: " ▾"; }
.account { display: flex; flex-direction: column; gap: 10px; }
.account p { margin: 0; }
.account label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: .88rem; }
#server-parts { display: flex; flex-direction: column; gap: inherit; }
button.link { border: 0; background: none; padding: 0 4px; min-height: 44px; color: var(--accent); text-decoration: underline; }

.bridge { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.bridge span:nth-child(2) { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.bridge button { min-height: 36px; padding: 0 12px; }
.pair { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--bg); }
.pair strong { font-size: 1.4rem; letter-spacing: .15em; }
.btn-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
code { overflow-wrap: anywhere; }
