/* ─── Reset & Base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #08080e;
  --surface:     #111118;
  --card:        #16161f;
  --border:      #1a1a26;
  --border-mid:  #242430;
  --accent:      #8a5cf6;
  --pink:        #ec4899;
  --grad:        linear-gradient(135deg, #8a5cf6, #ec4899);
  --accent-dim:  rgba(138, 92, 246, 0.15);
  --accent-glow: rgba(138, 92, 246, 0.06);
  --text:        #f5f3ff;
  --text-2:      #5a5a78;
  --text-3:      #2c2c3a;
  --danger:      #f87171;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Subtle noise grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 300px 300px;
}

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

button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ─── Header ────────────────────────────────────────────────────────────────── */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 7, 13, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-mark {
  font-size: 20px;
  color: var(--accent);
  line-height: 1;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.header-link {
  font-size: 13px;
  color: var(--text-3);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: color 0.2s;
}

.header-link:hover {
  color: var(--text-2);
  text-decoration: none;
}

/* ─── Main ──────────────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 24px 80px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ─── Hero ──────────────────────────────────────────────────────────────────── */

.hero {
  text-align: center;
  margin-bottom: 56px;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(44px, 7vw, 72px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 20px;
}

.hero-title em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-to {
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.7;
  max-width: 480px;
  margin: 0 auto;
  font-weight: 300;
}

/* ─── Input Panel ───────────────────────────────────────────────────────────── */

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Upload zone */

.upload-zone {
  border: 1.5px dashed rgba(138, 92, 246, 0.2);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  position: relative;
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: rgba(138, 92, 246, 0.5);
  background: rgba(13, 13, 26, 0.9);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 0 48px rgba(138, 92, 246, 0.05);
  outline: none;
}

.upload-zone:hover::before,
.upload-zone:focus-visible::before {
  opacity: 1;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(13, 13, 26, 0.95);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 0 60px rgba(138, 92, 246, 0.08);
}

.upload-zone.drag-over::before {
  opacity: 1;
}

.upload-dragover-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(7, 7, 13, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}

.upload-zone.drag-over .upload-dragover-label {
  opacity: 1;
}

.upload-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.upload-zone.drag-over .upload-body {
  opacity: 0;
}

.upload-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 8px;
  transition: transform 0.2s;
}

.upload-zone:hover .upload-icon-wrap {
  transform: translateY(-2px);
}

.upload-primary {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.upload-secondary {
  font-size: 14px;
  color: var(--text-2);
}

.upload-browse {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  pointer-events: all;
  font-size: 14px;
  font-family: inherit;
  transition: opacity 0.15s;
}

.upload-browse:hover { opacity: 0.8; }

.upload-formats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  letter-spacing: 0.08em;
}

/* URL row */

.url-row {
  padding: 32px 0 0;
}

.url-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-3);
  font-size: 13px;
}

.url-divider::before,
.url-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.url-field-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.url-field {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: not-allowed;
  opacity: 0.5;
  outline: none;
}

.url-submit {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  color: var(--text-3);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: not-allowed;
  opacity: 0.5;
}

.url-coming-soon {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(138, 92, 246, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* Bookmarklet callout */

.bookmarklet-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.bookmarklet-callout:hover {
  border-color: rgba(138, 92, 246, 0.3);
  background: rgba(138, 92, 246, 0.03);
  text-decoration: none;
}

.bc-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.bc-icon {
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.bc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}

.bc-title em {
  font-style: normal;
  color: var(--accent);
}

.bc-sub {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

.bc-arrow {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .bookmarklet-callout { flex-direction: column; align-items: flex-start; }
  .bc-arrow { align-self: flex-end; }
}

/* ─── Loading State ─────────────────────────────────────────────────────────── */

.state-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 80px 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-msg {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
}

/* ─── Results ───────────────────────────────────────────────────────────────── */

.results {
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.results-filename {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}

.btn-ghost {
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--font-body);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.btn-ghost:hover {
  background: var(--card);
  color: var(--text);
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  position: relative;
  bottom: -1px;
  border: 1px solid transparent;
  border-bottom: none;
}

.tab:hover {
  color: var(--text-2);
  background: var(--surface);
}

.tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 3px;
  padding: 1px 6px;
}

.tab-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

/* Tab panels */

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Swatch grid */

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.swatch {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  animation: swatchIn 0.35s ease both;
}

@keyframes swatchIn {
  from { opacity: 0; transform: scale(0.88) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.swatch:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  border-color: var(--border-mid);
}

.swatch:active {
  transform: scale(0.97);
}

.swatch-color {
  height: 72px;
  width: 100%;
}

.swatch-info {
  padding: 8px 10px;
}

.swatch-hex {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.04em;
}

.swatch-rgb {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-3);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.swatch-copy-hint {
  display: block;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.swatch:hover .swatch-copy-hint {
  opacity: 1;
}

/* Coming soon panel */

.coming-soon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
  gap: 12px;
}

.cs-glyph {
  font-size: 40px;
  color: var(--text-3);
  margin-bottom: 4px;
  line-height: 1;
}

.coming-soon-panel h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-2);
}

.coming-soon-panel p {
  font-size: 14px;
  color: var(--text-3);
  max-width: 400px;
  line-height: 1.65;
}

/* Export bar */

.export-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 24px 0 0;
  margin-top: 32px;
  border-top: 1px solid var(--border);
}

.export-label {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-right: 4px;
}

.export-btn {
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-2);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.export-btn:hover {
  color: #fff;
  border-color: transparent;
  background: var(--grad);
  box-shadow: 0 0 20px rgba(138, 92, 246, 0.25);
}

.export-btn.done {
  color: #fff;
  border-color: transparent;
  background: var(--grad);
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
  position: relative;
  z-index: 1;
}

.footer a {
  color: var(--text-3);
  transition: color 0.15s;
}

.footer a:hover {
  color: var(--text-2);
  text-decoration: none;
}

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

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--grad);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

@media (max-width: 600px) {
  .main { padding: 40px 16px 60px; }

  .hero { margin-bottom: 40px; }

  .hero-title { font-size: 38px; }

  .hero-sub { font-size: 15px; }

  .upload-zone { padding: 40px 16px; }

  .upload-primary { font-size: 16px; }

  .swatch-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }

  .swatch-color { height: 60px; }

  .export-bar {
    gap: 6px;
  }

  .export-btn {
    font-size: 12px;
    padding: 7px 12px;
  }

  .tabs { gap: 2px; }

  .tab { padding: 10px 12px; font-size: 12px; }

  .results-filename { max-width: 200px; }
}
