/* style.css — all styling */
:root {
  --bg: #0e1116;
  --bg-2: #161b22;
  --panel: #1b2129;
  --panel-2: #232b35;
  --border: #2c3440;
  --text: #e6edf3;
  --muted: #8b95a5;
  --accent: #6ea8fe;
  --accent-2: #7ee787;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f8fb;
  --bg-2: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f1f4f9;
  --border: #dde3ec;
  --text: #1c2430;
  --muted: #5d6878;
  --accent: #2f6feb;
  --accent-2: #1a7f37;
  --shadow: 0 8px 30px rgba(20,30,50,0.10);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    --bg: #f6f8fb;
    --bg-2: #eef2f7;
    --panel: #ffffff;
    --panel-2: #f1f4f9;
    --border: #dde3ec;
    --text: #1c2430;
    --muted: #5d6878;
    --accent: #2f6feb;
    --accent-2: #1a7f37;
    --shadow: 0 8px 30px rgba(20,30,50,0.10);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

body { overflow: hidden; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(110,168,254,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(126,231,135,0.08), transparent 60%),
    var(--bg);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(14,17,22,0.6);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}
html[data-theme="light"] .topbar { background: rgba(255,255,255,0.7); }

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #061018;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(110,168,254,0.35);
}
.brand-text h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.harmony {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 6px 10px 6px 12px;
  border-radius: var(--radius-sm);
}
.harmony-label { font-size: 12px; color: var(--muted); }
.harmony select {
  background: transparent;
  color: var(--text);
  border: none;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding: 2px 4px;
}
.harmony select option { background: var(--panel); color: var(--text); }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--panel-2); border-color: #3a4452; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4f8ce0);
  color: #061018;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(110,168,254,0.25);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.active {
  background: var(--accent-2);
  color: #06160a;
  border-color: transparent;
}

/* Stage */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  min-height: 0;
}

.swatches {
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.swatch {
  flex: 1 1 0;
  position: relative;
  border: none;
  background: var(--c, #444);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 16px;
  text-align: left;
  transition: flex-basis .25s ease, transform .12s ease;
  min-width: 0;
  border-right: 1px solid rgba(0,0,0,0.12);
}
.swatch:last-child { border-right: none; }
.swatch:hover { transform: translateY(-2px); }
.swatch.selected::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.6);
}
html[data-theme="light"] .swatch.selected::after { background: #111; box-shadow: 0 0 10px rgba(0,0,0,0.4); }
.sw-top { display: flex; justify-content: space-between; align-items: center; }
.sw-name { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.sw-lock { font-size: 14px; opacity: 0.85; cursor: pointer; padding: 4px; }
.sw-lock.on { opacity: 1; }
.sw-hex { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }

/* Inspector */
.inspector {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow: auto;
  min-width: 0;
}
.inspector-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 18px;
}
.inspector-head h2 { margin: 0; font-size: 16px; }
.insp-hex {
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--panel-2); padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border);
}
.inspector-body { display: flex; flex-direction: column; gap: 14px; }

.field {
  display: grid;
  grid-template-columns: 78px 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.field > span { color: var(--muted); }
.field b { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}

.insp-row { display: flex; gap: 8px; align-items: center; }
input[type="color"] {
  width: 42px; height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  padding: 2px;
}

.previews { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.preview-card {
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--border);
}
.pv-text { font-size: 15px; font-weight: 700; }
.pv-sub { font-size: 12px; margin-top: 4px; }
.pv-btn {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.18);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: #fff;
}

/* Footer */
.footbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 22px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  gap: 12px;
}
.footbar kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.copy-state { font-variant-numeric: tabular-nums; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: var(--shadow);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.x {
  background: transparent; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.x:hover { background: var(--panel-2); color: var(--text); }
.code {
  margin: 0;
  padding: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-2);
  color: var(--text);
  max-height: 50vh;
  overflow: auto;
  white-space: pre;
}
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* Responsive */
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 38vh) 1fr; }
  .inspector { border-left: none; border-top: 1px solid var(--border); }
  .topbar { padding: 12px 14px; }
  .brand-text h1 { font-size: 16px; }
}
@media (max-width: 480px) {
  .swatches { flex-direction: row; }
  .swatch { padding: 12px 10px; }
  .sw-name { font-size: 11px; }
  .sw-hex { font-size: 12px; }
  .controls { width: 100%; justify-content: space-between; }
  .harmony { padding: 5px 8px; }
  .btn { padding: 8px 10px; font-size: 12px; }
  .footbar { font-size: 11px; padding: 8px 14px; }
  .hint { display: none; }
}
