:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2230;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #f7931a;
  --green: #3fb950;
  --red: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; color: var(--accent); white-space: nowrap; }
.brand .tag { color: var(--muted); font-weight: 400; }

nav a { color: var(--muted); margin-right: 12px; }
nav a.active, nav a:hover { color: var(--text); }

#statsbar { margin-left: auto; color: var(--muted); font-size: 12px; }
#statsbar b { color: var(--text); }

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.canvas-toolbar .hint { color: var(--muted); font-size: 12px; }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}

button:hover { border-color: var(--muted); }
button.active { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #0d1117; font-weight: 700; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

#canvas-holder {
  position: relative;
  height: 640px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #090c10;
}

#grid { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#grid.painting { cursor: crosshair; }
#grid.erasing { cursor: not-allowed; }

#tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  display: none;
  white-space: nowrap;
  z-index: 5;
  width: 136px;
}

#lens {
  display: block;
  width: 120px;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: 4px;
  image-rendering: pixelated;
  margin-bottom: 6px;
}

#tip-pos { color: var(--muted); }
#tip-price b { color: var(--accent); }
#tip-owner { white-space: normal; overflow-wrap: break-word; }
#tip-owner .url { color: var(--accent); }

#zoomctl {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
  z-index: 4;
}

#zoomctl button { padding: 2px 9px; }
#zoom-pct { color: var(--muted); font-size: 12px; min-width: 44px; text-align: center; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: lowercase; color: var(--muted); }

.field { margin-bottom: 10px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.field input[type="text"], .field input[type="url"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
}
.field input[type="color"] {
  width: 48px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg); cursor: pointer;
}

#sel-info { color: var(--muted); font-size: 12px; }
#quote { font-size: 18px; margin: 8px 0; }
#quote b { color: var(--accent); }
.warn { color: var(--red); font-size: 12px; }

#ledger { list-style: none; margin: 0; padding: 0; font-size: 12px; max-height: 300px; overflow-y: auto; }
#ledger li { padding: 6px 0; border-bottom: 1px solid var(--border); }
#ledger li:last-child { border-bottom: none; }
#ledger .muted { color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: baseline; margin-right: 4px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: min(400px, 92vw);
  text-align: center;
}

.modal-box img { border-radius: 8px; background: #fff; }

#modal-loading { padding: 60px 0 70px; }
#modal-loading .muted-line { color: var(--muted); margin-top: 16px; }
.spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-box.loading #modal-qr,
.modal-box.loading #modal-bolt11,
.modal-box.loading #modal-amount,
.modal-box.loading #modal-status,
.modal-box.loading #modal-copy,
.modal-box.loading #modal-simulate { display: none !important; }
.modal-box:not(.loading) #modal-loading { display: none; }
#modal-bolt11 {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  margin: 10px 0;
}
#modal-status { margin: 10px 0; }
#modal-status.paid { color: var(--green); font-weight: 700; }
.demo-note { color: var(--muted); font-size: 11px; margin-top: 8px; }

/* about page */
.about {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.about h1 { color: var(--accent); }
.about h2 { border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-top: 40px; }
.about table { border-collapse: collapse; width: 100%; font-size: 13px; }
.about th, .about td { border: 1px solid var(--border); padding: 6px 10px; text-align: right; }
.about th:first-child, .about td:first-child { text-align: left; }
.about th { background: var(--panel); color: var(--muted); }
.about code, .about pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 13px;
}
.about pre { padding: 12px; overflow-x: auto; }
.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.props .panel h4 { margin: 0 0 6px; color: var(--accent); }
.props .panel p { margin: 0; color: var(--muted); font-size: 13px; }
.callout {
  border-left: 3px solid var(--accent);
  background: var(--panel);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
}
footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 16px 20px;
  text-align: center;
  margin-top: 24px;
}
