/* ─── NURR Design tokens ──────────────────────────────────────────────────── */
:root {
  --bg:          #f4ede0;
  --paper:       #f7f1e4;
  --paper-2:     #ede5d1;
  --ink:         #0a0540;
  --ink-2:       #08015F;
  --ink-dim:     rgba(10, 5, 64, 0.55);
  --ink-faint:   rgba(10, 5, 64, 0.28);
  --rule:        rgba(10, 5, 64, 0.18);
  --rule-soft:   rgba(10, 5, 64, 0.10);
  --accent:      #FC6C3D;
  --accent-soft: #f7d3c0;
  --shadow:      0 24px 80px rgba(10,5,64,0.25), 0 4px 16px rgba(10,5,64,0.10);

  --nurr-blue:      #08015F;
  --nurr-panel:     #f7f1e4;
  --nurr-panel-soft:#eef3ed;
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#root { width: 100vw; height: 100vh; position: relative; overflow: hidden; }
canvas.stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.is-picking-color, body.is-picking-color * { cursor: none !important; }

/* ─── NURR brand wordmark ─────────────────────────────────────────────────── */
.nurr-brand {
  position: absolute; left: 116px; top: 34px; z-index: 9;
  pointer-events: none;
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 58px; line-height: 0.86; letter-spacing: 0.025em; font-weight: 900;
  transform: scaleX(1.12); transform-origin: left top;
  color: var(--nurr-blue);
}

/* ─── Vertical rail (mode switcher) ──────────────────────────────────────── */
.rail {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 88px; z-index: 8; background: transparent;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 168px 0 66px;
  align-items: center;
  pointer-events: none;
}
.rail-group {
  display: flex; flex-direction: column; gap: 66px; align-items: center;
  pointer-events: auto;
}
.rail-item {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 24px; line-height: 1; letter-spacing: 0.025em;
  text-transform: none; font-weight: 300;
  color: rgba(244, 237, 224, 0.88);
  text-shadow: 0 1px 18px rgba(8, 1, 95, 0.35);
  cursor: pointer; user-select: none;
  transition: color 0.25s ease;
  padding: 4px 0;
  background: transparent; border: none;
}
.rail-item:hover { color: rgba(244, 237, 224, 1); }
.rail-item.active { color: #fffaf0; }
.rail-item .num { display: none; }
.rail-foot { display: none; }

/* ─── Floating panel ──────────────────────────────────────────────────────── */
.panel {
  position: absolute; top: 86px; right: 30px;
  width: 318px; max-height: calc(100vh - 116px);
  background: var(--nurr-panel);
  border: 1px solid var(--rule);
  box-shadow: 0 20px 64px rgba(8,1,95,0.16), 0 2px 8px rgba(8,1,95,0.08);
  z-index: 10;
  display: flex; flex-direction: column;
  overflow: visible;
  user-select: none;
  color: var(--ink);
  border-radius: 0;
}
.panel.collapsed { width: auto; max-height: none; }

.panel-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 22px 14px;
  min-height: 92px;
  border-bottom: 1px solid var(--rule);
  cursor: grab; background: var(--nurr-panel);
}
.panel-header:active { cursor: grabbing; }

.panel-eyebrow {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 10px; letter-spacing: 0.03em; text-transform: uppercase;
  font-weight: 700; color: #151515;
  margin-bottom: 9px;
}
.panel-title {
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 22px; line-height: 0.94; font-style: normal;
  font-weight: 700; letter-spacing: 0.005em; color: var(--nurr-blue);
  max-width: 190px;
}
.panel-title .amp { color: var(--accent); }

.panel-body {
  overflow-y: auto; overflow-x: visible;
  padding: 12px 22px 18px;
  max-height: calc(100vh - 202px);
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

/* ─── Icon buttons ────────────────────────────────────────────────────────── */
.icon-btn {
  width: 23px; height: 23px; border-radius: 50%;
  background: transparent; border: 1px solid var(--rule);
  color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--ink-2); color: var(--paper); border-color: var(--ink-2); }
.icon-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.header-actions { display: flex; gap: 5px; }

/* ─── Sections ────────────────────────────────────────────────────────────── */
.section { margin-top: 16px; }
.section:first-child { margin-top: 0; }
.section-label {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 6px; margin-bottom: 11px;
}
.section-label .name {
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-style: normal; font-size: 17px; font-weight: 400; color: var(--ink-2);
}
.section-label .value {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-dim);
}

/* ─── Slider ──────────────────────────────────────────────────────────────── */
.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 1px;
  background: var(--rule); outline: none; cursor: pointer; margin: 8px 0;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; transition: transform 0.1s;
  border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--accent);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--accent);
}

/* ─── Swatches / palette editor ───────────────────────────────────────────── */
.swatches { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 32px; height: 32px;
  border: 1px solid rgba(8, 1, 95, 0.14);
  cursor: pointer; position: relative;
  transition: transform 0.12s;
  border-radius: 50%;
}
.swatch:hover { transform: translateY(-1px) scale(1.06); }
.swatch.active { outline: 2px solid var(--nurr-blue); outline-offset: 3px; }
.swatch input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.swatch.add {
  background: transparent; border: 1px dashed var(--rule);
  color: var(--ink-faint);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.swatch.add:hover { color: var(--accent); border-color: var(--accent); }
.swatch.remove-target:hover::after {
  content: ''; position: absolute; top: -3px; right: -3px;
  width: 12px; height: 12px;
  background: var(--accent); border: 1px solid var(--paper); border-radius: 50%;
}

.palette-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  max-height: 140px; overflow-y: auto; padding-right: 4px;
}
.palette-card {
  cursor: pointer; padding: 3px;
  border: 1px solid transparent; transition: border-color 0.15s;
  display: flex; height: 32px;
}
.palette-card:hover { border-color: var(--rule); }
.palette-card.active { border-color: var(--ink-2); }
.palette-card span { flex: 1; height: 100%; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  flex: 1; padding: 8px 12px;
  background: var(--paper); border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
  border-radius: 999px;
}
.btn:hover { background: var(--ink-2); color: var(--paper); border-color: var(--ink-2); }
.btn.primary { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.active { background: var(--ink-2); color: var(--paper); border-color: var(--ink-2); }
.btn-italic {
  font-family: "Instrument Serif", serif; font-style: italic;
  text-transform: none; letter-spacing: 0; font-size: 16px;
}
.compact-row { margin-top: 10px; }

/* ─── Segmented control ───────────────────────────────────────────────────── */
.seg {
  display: flex; background: transparent;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.seg-opt {
  flex: 1; padding: 10px 6px;
  background: transparent; border: none; border-right: 1px solid var(--rule);
  color: var(--ink-dim);
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s;
}
.seg-opt:last-child { border-right: none; }
.seg-opt.active { background: var(--ink-2); color: var(--paper); }
.seg-opt:hover:not(.active) { color: var(--ink); background: var(--paper-2); }

/* ─── Geometric layout cards ──────────────────────────────────────────────── */
.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.layout-card {
  aspect-ratio: 1; position: relative;
  background: var(--paper-2); border: 1px solid var(--rule);
  cursor: pointer; transition: border-color 0.15s, transform 0.12s;
  overflow: hidden;
}
.layout-card:hover { transform: translateY(-1px); }
.layout-card.active { border-color: var(--ink-2); }
.layout-card.active::after {
  content: ''; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 2px var(--ink-2); pointer-events: none;
}
.layout-card svg { width: 100%; height: 100%; display: block; }

/* ─── Help text ───────────────────────────────────────────────────────────── */
.help {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px; line-height: 1.32;
  color: var(--ink-dim);
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--rule-soft);
}
.help em { color: var(--accent); }
.help kbd {
  display: inline-block;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 11px; padding: 1px 6px;
  border: 1px solid var(--rule); border-radius: 3px;
  color: var(--ink); margin: 0 1px;
}
.compact-help { margin-top: 13px; }

/* ─── Nature / photo mode ─────────────────────────────────────────────────── */
.nature-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 4px; max-height: 220px; overflow-y: auto; padding-right: 4px;
}
.nature-thumb {
  aspect-ratio: 1; overflow: hidden;
  background: var(--paper-2); border: 1px solid transparent;
  cursor: pointer; position: relative;
  transition: border-color 0.15s;
}
.nature-thumb.active { border-color: var(--ink-2); }
.nature-thumb.active::after {
  content: ''; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 2px var(--ink-2);
}
.nature-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nature-stage { z-index: 1; }
.nature-fallback-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; pointer-events: none;
}

.drop-zone {
  border: 1px dashed var(--rule); padding: 12px;
  text-align: center; color: var(--ink-dim);
  font-size: 13px; line-height: 1.4;
  cursor: pointer; transition: all 0.2s; margin-top: 10px;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent); color: var(--ink);
  background: rgba(252, 108, 61, 0.06);
}
.drop-zone strong { color: var(--ink-2); font-weight: 600; }
.drop-zone .code {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 11px; background: var(--paper-2); padding: 2px 6px;
  color: var(--ink-2); border-radius: 2px;
}

.folder-widget {
  margin-top: 12px; padding: 12px 13px;
  border: 1px solid var(--rule-soft); background: rgba(255,255,255,0.24);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px; line-height: 1.35; color: rgba(10,5,64,0.72);
}
.folder-title {
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--nurr-blue); margin-bottom: 7px;
}
.folder-widget p { margin: 7px 0; }
.folder-widget code {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 11px; background: rgba(8,1,95,0.07); padding: 2px 5px; color: var(--nurr-blue);
}

/* ─── Color picker / wheel ────────────────────────────────────────────────── */
.color-wheel-card {
  position: fixed; right: 142px; top: 292px;
  width: 270px; padding: 24px 27px 25px;
  background: var(--nurr-panel-soft); border-radius: 18px; z-index: 40;
  box-shadow: 0 24px 72px rgba(10,5,64,0.18); border: 0;
}
.color-wheel-surface {
  position: relative; height: 142px; border-radius: 32px;
  overflow: hidden; cursor: none; border: 0; touch-action: none;
  background:
    linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(255,255,255,0.72) 9%, rgba(255,255,255,0) 29%, rgba(0,0,0,0) 58%, rgba(0,0,0,0.95) 100%),
    linear-gradient(to right, #ff2b2b 0%, #ff8e1f 9%, #ffe436 18%, #57f04d 31%, #00d9a6 43%, #13c9ff 56%, #2261ff 68%, #7a41ff 80%, #ff4fe9 91%, #ff2b2b 100%);
}
.color-wheel-surface::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to right, rgba(255,255,255,0.52), rgba(255,255,255,0) 18%, rgba(0,0,0,0) 74%, rgba(0,0,0,0.32));
  mix-blend-mode: soft-light;
}
.color-readout {
  margin-top: 18px; border-top: 1px solid rgba(10,5,64,0.28);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: #101010;
}
.color-readout div {
  display: flex; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid rgba(10,5,64,0.28);
  font-size: 13px; letter-spacing: 0.01em; white-space: nowrap;
}
.color-readout span:first-child { width: 52px; font-weight: 500; }
.color-readout strong { font-weight: 400; }

.eyedropper-follow {
  position: fixed; z-index: 99999; width: 54px; height: 54px;
  transform: translate3d(-27px, -27px, 0);
  pointer-events: none; display: flex; align-items: center; justify-content: center;
  will-change: left, top;
}
.eyedropper-follow svg {
  width: 28px; height: 28px; color: #050505;
  filter: drop-shadow(0 1px 2px rgba(255,255,255,0.55));
  z-index: 2; transform: translate(3px, -3px);
}
.eyedropper-color {
  position: absolute; width: 45px; height: 45px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.92);
  box-shadow: 0 4px 18px rgba(0,0,0,0.24); opacity: 0.96; z-index: 1;
}

/* ─── Collection drawer ───────────────────────────────────────────────────── */
.collection-drawer {
  position: absolute; right: 30px; bottom: 26px;
  width: 318px; max-height: 210px; z-index: 12;
  background: rgba(247,241,228,0.96); border: 1px solid var(--rule);
  box-shadow: 0 12px 42px rgba(8,1,95,0.14);
  padding: 12px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.collection-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 9px;
  color: var(--nurr-blue); font-size: 12px; font-weight: 700;
}
.collection-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  max-height: 96px; overflow: auto;
}
.collection-tile { position: relative; }
.collection-item {
  display: block; border: 1px solid var(--rule);
  background: var(--paper); padding: 2px;
  text-decoration: none;
}
.collection-item img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.collection-delete {
  position: absolute; top: -4px; right: -4px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); color: white;
  border: none; cursor: pointer; font-size: 10px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.collection-tile:hover .collection-delete { opacity: 1; }
.collection-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ─── Toggle row (abstract mode) ─────────────────────────────────────────── */
.toggle-row { display: flex; gap: 8px; }

/* ─── Toast notification ──────────────────────────────────────────────────── */
.snapshot-toast {
  position: absolute; bottom: 36px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink-2); color: var(--paper);
  padding: 12px 22px; border-radius: 999px;
  font-family: "Instrument Serif", serif; font-style: italic; font-size: 18px;
  box-shadow: var(--shadow); z-index: 20; pointer-events: none;
  opacity: 0; transition: opacity 0.35s, transform 0.35s;
}
.snapshot-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Corner mark ─────────────────────────────────────────────────────────── */
.corner-mark {
  position: absolute; right: 28px; bottom: 28px;
  z-index: 5; pointer-events: none; text-align: right; color: var(--ink-faint);
}
.corner-mark .big {
  font-family: "Instrument Serif", serif; font-style: italic;
  font-size: 22px; color: var(--ink-2); line-height: 1;
}
.corner-mark .small {
  font-family: "EB Garamond", serif;
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; margin-top: 4px;
}

/* ─── Placeholder (photo mode with no image) ──────────────────────────────── */
.placeholder-overlay {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; pointer-events: none; z-index: 2;
  background: linear-gradient(135deg, #f4ede0 0%, #ede2c8 100%);
}
.placeholder-card {
  max-width: 480px; padding: 36px 40px;
  background: var(--paper); border: 1px solid var(--rule);
  box-shadow: var(--shadow); text-align: left; pointer-events: auto;
}
.placeholder-card h2 {
  font-family: "monotalic", "Helvetica Neue", Arial, sans-serif;
  font-size: 32px; font-weight: 700; color: var(--ink-2);
  margin-bottom: 10px; line-height: 1.05;
}
.placeholder-card p {
  font-family: "EB Garamond", serif;
  font-size: 15px; color: var(--ink); line-height: 1.55;
}
.placeholder-card code {
  background: var(--paper-2); padding: 2px 7px; border-radius: 2px;
  color: var(--ink-2); font-size: 13px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* ─── Abstract formation grid ─────────────────────────────────────────────── */
.formation-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.formation-card {
  aspect-ratio: 4/3; position: relative;
  border: 1px solid var(--rule); cursor: pointer;
  overflow: hidden; transition: border-color 0.15s;
  background: var(--paper-2);
}
.formation-card:hover { border-color: var(--ink-dim); }
.formation-card.active { border-color: var(--ink-2); }
.formation-card.active::after {
  content: ''; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 2px var(--ink-2); pointer-events: none;
}
.formation-canvas { width: 100%; height: 100%; display: block; }
.formation-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 3px 5px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.9); background: rgba(0,0,0,0.35);
  text-align: center;
}
