@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Mono:wght@300;400;500&display=swap');

/* ── DARK MODE (default) ── */
:root {
  --font-sans: 'Syne', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'Fira Mono', 'Consolas', monospace;
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.15);
  --text: #f0f0f5;
  --text-muted: #6b6b80;
  --text-dim: #3a3a50;
  --accent: #7c6aff;
  --accent2: #ff6a9b;
  --accent3: #6affdb;
  --accent-glow: rgba(124,106,255,0.15);
  --success: #4ade80;
  --warning: #fbbf24;
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --noise-opacity: 0.4;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --header-bg: rgba(10,10,15,0.85);
  --checker-a: #1a1a24;
  --checker-b: #111118;
}

/* ── LIGHT MODE ── */
:root[data-theme="light"],
[data-theme="light"] {
  --bg: #f4f4f8;
  --bg2: #ffffff;
  --bg3: #ebebf2;
  --border: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.18);
  --text: #0d0d18;
  --text-muted: #7070888;
  --text-muted: #70708a;
  --text-dim: #b0b0c8;
  --accent: #6253e1;
  --accent2: #e8437a;
  --accent3: #00c8a8;
  --accent-glow: rgba(98,83,225,0.10);
  --success: #16a34a;
  --warning: #d97706;
  --noise-opacity: 0.15;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.08);
  --header-bg: rgba(244,244,248,0.88);
  --checker-a: #e8e8f0;
  --checker-b: #f4f4f8;
}

/* ── OS-LEVEL PREFERENCE (fallback when no data-theme set) ── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #f4f4f8;
    --bg2: #ffffff;
    --bg3: #ebebf2;
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.18);
    --text: #0d0d18;
    --text-muted: #70708a;
    --text-dim: #b0b0c8;
    --accent: #6253e1;
    --accent2: #e8437a;
    --accent3: #00c8a8;
    --accent-glow: rgba(98,83,225,0.10);
    --success: #16a34a;
    --warning: #d97706;
    --noise-opacity: 0.15;
    --shadow-card: 0 2px 16px rgba(0,0,0,0.08);
    --header-bg: rgba(244,244,248,0.88);
    --checker-a: #e8e8f0;
    --checker-b: #f4f4f8;
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

/* ── NOISE OVERLAY ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: var(--noise-opacity);
}

/* ── HEADER ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #ffffff; /* always white — never inherit --text */
  flex-shrink: 0;
}

.logo span { color: var(--accent); }

nav {
  display: flex;
  gap: 0;
  flex: 1;
  flex-wrap: wrap;
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 500;
  padding: .35rem .7rem;
  border-radius: 6px;
  transition: var(--transition);
  white-space: nowrap;
}

nav a:hover { color: var(--text); background: var(--bg3); }
nav a.active { color: var(--accent); background: var(--accent-glow); }

.nav-badge {
  font-size: 0.65rem;
  background: var(--accent);
  color: white;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  margin-left: 0.3rem;
  vertical-align: middle;
  font-family: var(--font-mono);
}

/* ── THEME TOGGLE ── */
.theme-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .35rem .6rem;
  color: var(--text-muted);
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  outline: none;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* Sun/Moon icon swap */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: opacity 0.2s, transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* Dark mode → show moon, hide sun */
:root[data-theme="dark"] .icon-sun,
:root:not([data-theme="light"]) .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

/* Light mode → show sun, hide moon */
:root[data-theme="light"] .icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}
:root[data-theme="light"] .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* OS fallback */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
  :root:not([data-theme]) .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
}

/* ── HERO ── */
.hero {
  text-align: center;
  padding: 5rem 2rem 3rem;
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
  opacity: 0.8;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin-bottom: 1rem;
}

.hero h1 .grad {
  background: linear-gradient(135deg, var(--accent), var(--accent2) 50%, var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
  font-weight: 400;
}

/* ── TOOL GRID (homepage) ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.tool-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: block;
  box-shadow: var(--shadow-card);
}

.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--card-color, var(--accent)), transparent 60%);
  opacity: 0;
  transition: var(--transition);
}

.tool-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.tool-card:hover::before { opacity: 0.06; }

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  /* tint background only — don't touch element opacity so the emoji stays visible */
  background: color-mix(in srgb, var(--card-color, var(--accent)) 18%, transparent);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  position: relative;
}

.tool-card-icon-inner {
  position: absolute;
  font-size: 1.4rem;
  opacity: 1;
}

.tool-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.tool-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.tool-card-arrow {
  position: absolute;
  top: 1.75rem;
  right: 1.75rem;
  color: var(--text-dim);
  transition: var(--transition);
}

.tool-card:hover .tool-card-arrow { color: var(--text-muted); transform: translate(2px,-2px); }

/* ── CONVERTER PAGE ── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 2rem 4rem;
  position: relative;
  z-index: 1;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 0.4rem;
}

.page-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-muted); }

/* ── CONVERTER LAYOUT ── */
.converter-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}

@media (max-width: 860px) {
  .converter-layout { grid-template-columns: 1fr; }
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  background: var(--bg2);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: var(--transition);
}

.upload-zone:hover .upload-icon { border-color: var(--accent); background: var(--accent-glow); }

.upload-label { font-size: 0.9rem; font-weight: 600; }
.upload-sub { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }

/* ── PREVIEW AREA ── */
.preview-area {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.preview-area.visible { display: flex; }

.preview-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.preview-panel { display: flex; flex-direction: column; gap: 0.5rem; }

.preview-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preview-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.preview-img-wrap {
  border-radius: 8px;
  overflow: hidden;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 0 0 / 16px 16px;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.preview-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg3);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.preview-meta span { display: flex; justify-content: space-between; }
.preview-meta span em { color: var(--text); font-style: normal; }

/* ── SIDEBAR ── */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }

.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: background var(--transition), border-color var(--transition);
}

.panel-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── FORM ELEMENTS ── */
label.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

select, input[type=range] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.825rem;
  padding: 0.625rem 0.875rem;
  outline: none;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b80' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.25rem;
}

select:focus, select:hover { border-color: var(--accent); }

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

/* ── SWAP BUTTON ── */
.swap-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.swap-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1rem;
}

.swap-btn:hover { border-color: var(--accent); color: var(--accent); transform: rotate(180deg); }

.swap-line { flex: 1; height: 1px; background: var(--border); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
  padding: 0.875rem;
  font-size: 0.9rem;
  box-shadow: 0 0 24px var(--accent-glow);
}

.btn-primary:hover { background: #6b59ee; box-shadow: 0 0 32px rgba(124,106,255,0.3); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg2); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

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

/* ── PROGRESS ── */
.progress-wrap {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-wrap.visible { display: flex; }

.progress-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── STATUS BADGE ── */
.status {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
}

.status.visible { display: flex; }
.status.success { background: rgba(74,222,128,0.1); color: var(--success); border: 1px solid rgba(74,222,128,0.2); }
.status.error { background: rgba(255,100,100,0.1); color: #ff6464; border: 1px solid rgba(255,100,100,0.2); }
.status.loading { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(124,106,255,0.2); }

/* ── COLOR SWATCHES ── */
.swatch-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.swatch:hover { transform: scale(1.15); border-color: var(--border-hover); }

.swatch-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.swatch:hover .swatch-tooltip { opacity: 1; }

/* ── INFO BOX ── */
.info-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.info-box strong { color: var(--text); font-weight: 600; }

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg3);
  border-radius: 10px;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
}

.tab {
  flex: 1;
  padding: 0.5rem;
  border-radius: 7px;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tab.active { background: var(--bg2); color: var(--text); }
.tab:hover:not(.active) { color: var(--text); }

/* ── DIVIDER ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--border);
  padding: 3rem 2rem;
  margin-top: 4rem;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; }
}

.footer-brand p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.6;
  max-width: 220px;
}

.footer-col h4 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.footer-col ul a {
  font-size: 0.825rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: var(--transition);
}

.footer-col ul a:hover { color: var(--text-muted); }

.footer-bottom {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ── SPINNER ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.5s ease both; }
.fade-up-1 { animation-delay: 0.05s; }
.fade-up-2 { animation-delay: 0.1s; }
.fade-up-3 { animation-delay: 0.15s; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .header-inner { padding: 0; }
  nav a span { display: none; }
  .preview-comparison { grid-template-columns: 1fr; }
  .hero { padding: 3rem 1rem 2rem; }
  .page-wrap { padding: 1.5rem 1rem 3rem; }
}
