/* ─────────────────────────────────────────────────────────────────────────────
   mixing desk — a working table for color and notes
   Warm near-black instrument panel. The palette is the loudest thing on screen;
   the chrome stays quiet and neutral, with a single brass accent.
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --bg:        #16140f;   /* warm near-black desk surface */
  --panel:     #1e1b15;   /* raised surface */
  --panel-2:   #262219;   /* deeper inset surface */
  --ink:       #efe7d9;   /* warm paper ink */
  --ink-dim:   #9a8f7c;   /* muted ink */
  --line:      rgba(239, 231, 217, 0.10);
  --brass:     #d9a05b;   /* the one chrome accent */
  --brass-ink: #1e1303;

  --font-display: "Fraunces", Georgia, serif;
  --font-ui:      "Space Grotesk", ui-sans-serif, system-ui, sans-serif;

  /* set from JS: the ambient tint takes on the palette's temperature */
  --ambient-hsl: 28 55% 55%;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient warmth — the workspace quietly takes on the base hue's temperature */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(70rem 48rem at 26% -8%, hsl(var(--ambient-hsl) / 0.13), transparent 70%);
}

.topbar, .desk { position: relative; z-index: 1; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

::selection { background: hsl(var(--ambient-hsl) / 0.35); }

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 24px 14px;
}

.brand__name {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.brand__tag {
  margin: 2px 0 0;
  color: var(--ink-dim);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

/* Tabs only matter on mobile; hidden on the two-panel desk */
.tabs { display: none; gap: 8px; }

.tab {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.tab.is-active { background: var(--brass); border-color: transparent; color: var(--brass-ink); }

/* ── The desk ────────────────────────────────────────────────────────────── */

.desk {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 24px 24px;
  align-items: stretch;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 20px;
}

.panel__tools { display: flex; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: rgba(239, 231, 217, 0.06); }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--brass);
  border-color: transparent;
  color: var(--brass-ink);
}
.btn--primary:hover { background: #e3ae6c; }

.btn--ghost { color: var(--ink-dim); }
.btn--ghost:hover { color: var(--ink); }

.linkbtn {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-dim);
  font: inherit;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.linkbtn:hover { color: var(--ink); }

/* ── Swatches ────────────────────────────────────────────────────────────── */

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 20px 20px 8px;
}

.swatch { position: relative; }

.swatch__fill {
  position: relative;
  display: block;
  width: 100%;
  height: 230px;
  border: 0;
  border-radius: 12px;
  background: var(--sw);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.14s ease;
}
.swatch__fill:hover { transform: translateY(-3px); }
.swatch__fill:active { transform: translateY(0); }

.swatch__copyhint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none;
}
.swatch__fill:hover .swatch__copyhint { opacity: 1; transform: translateX(-50%) translateY(0); }

.swatch__hex {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  /* color set inline by JS to contrast with the swatch fill */
}

.swatch__lock {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  cursor: pointer;
  transition: background 0.12s ease;
}
.swatch__lock:hover { background: rgba(0, 0, 0, 0.5); }
.swatch__lock.is-locked { background: var(--brass); color: var(--brass-ink); }

/* ── Finishes ─────────────────────────────────────────────────────────────
   The palette-wide finish picker layers a semi-transparent sheen over each
   color. The base `--sw` always stays underneath, so the hex/contrast logic
   is untouched — these overlays are pure chrome. */

.desk[data-finish="matte"] .swatch__fill,
.solo-card[data-finish="matte"] .solo-fill { background-image: none; }

.desk[data-finish="metallic"] .swatch__fill,
.solo-card[data-finish="metallic"] .solo-fill {
  background-image:
    linear-gradient(160deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.05) 30%, rgba(255, 255, 255, 0.22) 48%, rgba(255, 255, 255, 0.03) 66%, rgba(0, 0, 0, 0.22) 100%),
    linear-gradient(160deg, transparent 34%, rgba(255, 255, 255, 0.45) 46%, rgba(255, 255, 255, 0.45) 49%, transparent 60%);
}

.desk[data-finish="gloss"] .swatch__fill,
.solo-card[data-finish="gloss"] .solo-fill {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.12) 22%, rgba(255, 255, 255, 0) 40%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0%, rgba(0, 0, 0, 0) 18%);
}

.desk[data-finish="pearl"] .swatch__fill,
.solo-card[data-finish="pearl"] .solo-fill {
  background-image:
    radial-gradient(130% 95% at 28% 18%, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0.08) 42%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.14) 90%);
}

.hint {
  margin: 4px 20px 0;
  padding-left: 2px;
  color: var(--ink-dim);
  font-size: 12.5px;
}

/* ── Controls ────────────────────────────────────────────────────────────── */

.controls {
  display: grid;
  grid-template-columns: 236px 1fr;
  gap: 24px;
  align-items: center;
  margin-top: auto;
  padding: 16px 20px 22px;
  border-top: 1px solid var(--line);
}

.wheel-wrap { text-align: center; }

#wheel {
  width: 218px;
  height: 218px;
  cursor: grab;
  touch-action: none;   /* let the wheel own horizontal drags on touch */
  user-select: none;
}
#wheel:active { cursor: grabbing; }

.wheel-note {
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.controls__right { display: flex; flex-direction: column; gap: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.chip:hover { color: var(--ink); }
.chip.is-active { background: var(--brass); border-color: transparent; color: var(--brass-ink); }

.chips--small .chip { padding: 5px 12px; font-size: 12px; }

.finish-row { display: flex; align-items: center; gap: 14px; }

.hue-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}
.hue-row__label {
  color: var(--ink-dim);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.hue-row__value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  min-width: 42px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff5a3c, #ffb03c, #c9e93c, #3ce98c, #3cc9e9, #3c5ae9, #b03ce9, #ff5a3c);
  outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #17140e;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #17140e;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: grab;
}

/* ── Solo color ────────────────────────────────────────────────────────────
   The "Solo" button drops a single big color on the desk. It borrows the
   palette-wide finish, so a Metal solo reads the same way as a Metal palette. */

.solo-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 10, 6, 0.55);
  backdrop-filter: blur(2px);
  animation: solo-in 0.16s ease;
}

.solo-card {
  position: relative;
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: solo-rise 0.18s ease;
}

.solo-x {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease;
}
.solo-x:hover { background: rgba(0, 0, 0, 0.5); }

.solo-fill {
  position: relative;
  display: block;
  width: 100%;
  height: 300px;
  border: 0;
  border-radius: 12px;
  background-color: var(--sw);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

.solo-hex {
  position: absolute;
  left: 18px;
  bottom: 14px;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.solo-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.14s ease;
  pointer-events: none;
}
.solo-fill:hover .solo-hint { opacity: 1; }

.solo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 0;
}
.solo-actions .linkbtn { margin-left: auto; }

@keyframes solo-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes solo-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Notes ───────────────────────────────────────────────────────────────── */

.notes-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.notelist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

#note-filter {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  outline-offset: 2px;
}
#note-filter::placeholder { color: var(--ink-dim); }

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-item {
  padding: 11px 13px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.note-item:hover { background: rgba(239, 231, 217, 0.04); }
.note-item.is-active { background: var(--panel-2); border-left-color: var(--brass); }

.note-item__title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item.is-active .note-item__title { color: var(--brass); }

.note-item__snippet {
  font-size: 12.5px;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item__time {
  margin-top: 3px;
  font-size: 11px;
  color: var(--ink-dim);
  opacity: 0.8;
}

.note-list-empty {
  padding: 16px 4px;
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
}

/* Editor */
.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.editor__fields { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.editor__title {
  padding: 26px 28px 8px;
  background: transparent;
  border: 0;
  outline: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 30px;
  color: var(--ink);
  width: 100%;
}
.editor__title::placeholder { color: var(--ink-dim); opacity: 0.7; }

.editor__body {
  flex: 1;
  min-height: 240px;
  padding: 6px 28px 18px;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  font-family: var(--font-ui);
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--ink);
}
.editor__body::placeholder { color: var(--ink-dim); opacity: 0.7; }

.editor__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 28px 18px;
}

.editor__meta {
  color: var(--ink-dim);
  font-size: 12px;
}

.editor__delete {
  border: 0;
  background: none;
  padding: 4px 6px;
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.editor__delete:hover { color: #e08a7a; }
.editor__delete.is-armed { color: #e08a7a; font-weight: 600; }

/* Empty editor state */
.editor__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  padding: 28px 32px;
}
.editor__empty h3 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
}
.editor__empty p {
  margin: 0;
  max-width: 40ch;
  color: var(--ink-dim);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  z-index: 5;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #2b2619;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .desk { grid-template-columns: 1fr; }
  .notes-body { grid-template-columns: 180px 1fr; }
}

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .tabs { display: flex; width: 100%; }

  .desk[data-panel-view="mix"] .panel--notes { display: none; }
  .desk[data-panel-view="notes"] .panel--mix { display: none; }

  .swatch__fill { height: 140px; }
  .solo-fill { height: 240px; }

  .controls { grid-template-columns: 1fr; }
  .wheel-wrap { display: none; }          /* hue slider is the small-screen path */
  .controls__right { gap: 12px; }

  .notes-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .notelist { border-right: 0; border-bottom: 1px solid var(--line); }
  .note-list { max-height: 190px; }
  .editor__body { min-height: 48vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .swatch__fill:hover { transform: none; }
}
