:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #171717;
  --muted: #6b6860;
  --line: #dedad0;
  --accent: #1b3b2b;
  --accent-ink: #ffffff;
  --danger: #9b2226;
  --ok: #2d6a4f;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.top-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  appearance: none; border: 0; background: none; color: var(--muted);
  padding: 12px 4px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer;
}
.tab-btn.active { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.main { max-width: 820px; margin: 0 auto; padding: 16px 14px 88px; }
@media (min-width: 768px) {
  .tabbar {
    position: sticky; top: 45px; bottom: auto;
    max-width: 820px; margin: 0 auto;
    border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg);
  }
  .tab-btn.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .main { padding-bottom: 36px; }
}
h2 { font-family: var(--serif); font-size: 20px; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 14px; margin-bottom: 14px;
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 10px; font-size: 16px; font-family: var(--sans);
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
}
textarea { min-height: 86px; resize: vertical; }
.mono { font-family: var(--mono); font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.btn {
  appearance: none; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); padding: 9px 14px; border-radius: 4px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 99px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--danger); border-color: var(--danger); }
.kv-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 6px; }
.canvas-wrap {
  border: 1px solid var(--line); background: #fffcf7; border-radius: 4px;
  max-height: 360px; overflow-y: auto; margin-top: 10px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
canvas { display: block; width: 100%; }
.msg { font-size: 13px; margin-top: 8px; color: var(--muted); word-break: break-word; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--danger); }
.hidden { display: none !important; }
