:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --border: #dde1e8;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2b5fd9;
  --accent-ink: #ffffff;
  --warn-bg: #fff6e0;
  --warn-border: #f0c36d;
  --paper: #ffffff;
  --shadow: 0 2px 12px rgba(20, 30, 60, .12);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; }
.topbar .sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.topbar-actions { display: flex; gap: 8px; }
.nav { display: flex; gap: 4px; margin-left: auto; margin-right: 12px; }
.nav a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.nav a:hover { background: #f0f2f6; color: var(--text); }
.nav a.active { background: #eaf0ff; color: var(--accent); }

.drop { border: 2px dashed var(--border); border-radius: 10px; padding: 18px 12px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: background .15s; }
.drop:hover, .drop.over { background: #f3f6ff; border-color: var(--accent); }
.drop img { max-width: 100%; max-height: 180px; display: block; margin: 8px auto 0; border-radius: 4px; }
.thumb { display: block; width: 100%; max-height: 220px; object-fit: contain; background: #e9ecf1; border-radius: 6px; margin-top: 6px; }
label.sub { font-size: 12px; }
.method-opts.hidden { display: none; }

.layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 16px;
  padding: 16px; max-width: 1600px; margin: 0 auto;
  align-items: start;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

.panel { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text); margin-bottom: 8px; }
label.small { font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row { display: flex; gap: 12px; align-items: center; margin-top: 6px; }

input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: #fff;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.4; }
input[type=range] { width: 100%; }
input[type=color] { width: 100%; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }

button {
  font: inherit; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer;
}
button:hover { background: #f6f7fa; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }

.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }
.hint.warn-text { color: #9a3412; }
.row.wrap { flex-wrap: wrap; gap: 6px; }
button.danger { background: #fff1f0; border-color: #f0a9a0; color: #b42318; }
button.danger:hover { background: #ffe4e1; }

.plot-status { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.off { background: #eef0f3; color: #6b7280; }
.badge.on { background: #e3f7ea; color: #15803d; }
.badge.busy { background: #fff3d6; color: #b45309; }
progress { width: 100%; height: 10px; margin-top: 8px; accent-color: var(--accent); }
.log {
  margin: 8px 0 0; padding: 8px 10px; max-height: 150px; overflow: auto; font-size: 11px; line-height: 1.45;
  background: #0f172a; color: #cbd5e1; border-radius: 6px; white-space: pre-wrap; word-break: break-word; min-height: 32px;
}

.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }

.warn {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px; font-size: 12px;
  background: var(--warn-bg); border: 1px solid var(--warn-border); line-height: 1.4;
}
.hidden { display: none; }

.preview { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 10px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pages { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.page-wrap { width: 100%; max-width: 820px; }
.page-wrap svg {
  width: 100%; height: auto; display: block; background: var(--paper);
  box-shadow: var(--shadow); border-radius: 2px;
}
.page-wrap .caption { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.status { font-size: 12px; color: var(--muted); text-align: center; min-height: 16px; }
