:root {
  --ink: #3b3226;
  --muted: #7a6e5d;
  --paper: rgba(253, 249, 240, 0.95);
  --line: rgba(80, 62, 36, 0.14);
  --accent: #b5603c;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(90, 70, 40, 0.18);
  font-family: "Segoe UI", "Rubik", "Assistant", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f4ead6; }
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; }

button {
  font: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); background: #fffaf0; color: var(--ink);
  border-radius: 999px; padding: 8px 16px;
}
button:hover { background: #f6ecd8; }
button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

#topbar {
  position: fixed; top: 12px; right: 12px; left: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#topbar .title {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px 16px; display: flex; align-items: baseline; gap: 10px;
}
#topbar h1 { margin: 0; font-size: 22px; }
#topbar .sub { color: var(--muted); font-size: 14px; }
#topbar .tools { display: flex; gap: 8px; flex-wrap: wrap; }
#topbar .tools button { box-shadow: var(--shadow); }

#sidebar {
  position: fixed; top: 74px; right: 12px; width: 250px; max-height: calc(100% - 130px);
  overflow: auto; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px;
}
#sidebar h2 { font-size: 15px; margin: 0 0 8px; }
.cat-title { font-size: 12px; color: var(--muted); margin: 12px 0 4px; display: flex; align-items: center; gap: 6px; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.place-item {
  display: block; width: 100%; text-align: right; border: 0; background: transparent;
  padding: 6px 8px; border-radius: 6px; font-size: 14px;
}
.place-item:hover { background: #eef3f1; }
.place-item .draft { font-size: 11px; color: #b5452f; margin-inline-start: 6px; }

#info {
  position: fixed; bottom: 40px; right: 12px; width: 320px; max-height: 60%;
  overflow: auto; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px;
}
#info .close {
  position: absolute; top: 6px; left: 8px; border: 0; background: transparent;
  font-size: 22px; line-height: 1; padding: 2px 6px;
}
#info h3 { margin: 0 0 4px; font-size: 18px; }
#info .en { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
#info .badge { display: inline-block; font-size: 12px; color: #fff; border-radius: 99px; padding: 2px 9px; margin-bottom: 8px; }
#info p { margin: 6px 0; line-height: 1.5; font-size: 14px; }
#info img { width: 100%; border-radius: 8px; margin: 6px 0; }
#info .meta { color: var(--muted); font-size: 12px; direction: ltr; text-align: right; }
#info pre {
  direction: ltr; text-align: left; background: #f3f5f4; border-radius: 6px; padding: 8px;
  font-size: 11px; white-space: pre-wrap; word-break: break-all;
}

.add-form h3 { margin: 0 0 10px; }
.add-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.add-form input, .add-form select, .add-form textarea {
  display: block; width: 100%; margin-top: 3px; font: inherit; font-size: 14px;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink);
}
.add-form .row { display: flex; gap: 8px; }
.add-form button[type=submit] { background: var(--accent); color: #fff; border-color: var(--accent); }
.add-form .note { font-size: 12px; color: var(--muted); }

#add-hint {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 99px; box-shadow: var(--shadow);
  font-size: 14px;
}
#add-hint kbd { background: rgba(255,255,255,.2); border-radius: 4px; padding: 0 5px; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center; font-size: 18px;
  background: #f4ead6; color: var(--muted);
}
#loading.done { display: none; }

#attribution {
  position: fixed; bottom: 0; left: 0; right: 0; padding: 4px 10px; font-size: 11px;
  color: var(--muted); background: rgba(255,255,255,.7); direction: ltr; text-align: left;
}

/* place pins (CSS2D labels) */
.pin {
  display: flex; flex-direction: column; align-items: center; cursor: pointer;
  transform: translateY(-50%); user-select: none;
}
.pin .label {
  background: #fff; border-radius: 99px; padding: 3px 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); border: 2px solid currentColor; white-space: nowrap;
}
.pin .label span { color: var(--ink); }
.pin .stem { width: 2px; height: 26px; background: currentColor; }
.pin .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; border: 2px solid #fff; }
.pin.draft .label { border-style: dashed; }
.pin:hover .label { transform: scale(1.06); }

#view-panel {
  position: fixed; top: 74px; left: 12px; width: 290px; max-height: calc(100% - 130px); overflow: auto;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
}
#view-panel h3 { margin: 0 0 10px; font-size: 16px; }
#view-panel label { display: block; font-size: 13px; color: var(--ink); margin-bottom: 10px; }
#view-panel label small { color: var(--muted); }
#view-panel output { float: left; color: var(--muted); font-variant-numeric: tabular-nums; }
#view-panel input[type=range] { display: block; width: 100%; margin-top: 4px; accent-color: var(--accent); }
#view-panel select { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fffaf0; color: var(--ink); }
#view-panel .switch input { accent-color: var(--accent); margin-inline-end: 6px; }
#view-panel .cine-only.off { opacity: .45; pointer-events: none; }
#view-panel .note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

@media (max-width: 700px) {
  #view-panel { left: 12px; right: 12px; width: auto; }
  #sidebar { display: none; }
  #info { width: auto; left: 12px; }
  #topbar .sub { display: none; }
}
