/* ManyEdit - liquid glass theme with light and dark modes.
   The active theme is set on <html data-theme="light|dark"> by the inline script in each page. */

:root {
  --text: #1a1d2e;
  --muted: #4d5470;
  --accent: #4a5bf0;
  --accent-hover: #3746d6;
  --accent-soft: rgba(74, 91, 240, .14);
  --danger: #b8285a;
  --success: #17805a;
  --checker: rgba(120, 130, 160, .12);

  --glass: rgba(255, 255, 255, .36);
  --glass-strong: rgba(255, 255, 255, .6);
  --glass-edge: rgba(255, 255, 255, .75);
  --glass-shadow: 0 8px 32px rgba(40, 50, 110, .14), inset 0 1px 0 rgba(255, 255, 255, .8);
  --blur: blur(28px) saturate(180%);

  --bg-top: #eef1ff;
  --bg-mid: #f6eefe;
  --bg-bottom: #eafaf6;
  --blob-1: #c4b5ff;
  --blob-2: #9fe6ff;

  --radius: 24px;
  --radius-sm: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --text: #eef0fb;
  --muted: #b4bad4;
  --accent: #9aa7ff;
  --accent-hover: #b3bdff;
  --accent-soft: rgba(154, 167, 255, .18);
  --danger: #ff8fb1;
  --success: #6fe0a8;
  --checker: rgba(255, 255, 255, .05);

  --glass: rgba(30, 34, 58, .45);
  --glass-strong: rgba(30, 34, 58, .68);
  --glass-edge: rgba(255, 255, 255, .16);
  --glass-shadow: 0 10px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12);

  --bg-top: #0d1020;
  --bg-mid: #140f24;
  --bg-bottom: #0b1a1c;
  --blob-1: #4b3a9e;
  --blob-2: #1d5f7e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Segoe UI Variable", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bottom) 100%);
  background-color: var(--bg-top);
  position: relative;
  overflow-x: hidden;
}

/* Soft colour glows behind the glass. Kept faint so they add depth without overpowering the content. */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .35;
  pointer-events: none;
  animation: drift 30s ease-in-out infinite alternate;
}
body::before {
  width: 36vmax; height: 36vmax;
  left: -10vmax; top: -10vmax;
  background: radial-gradient(circle, var(--blob-1), transparent 70%);
}
body::after {
  width: 32vmax; height: 32vmax;
  right: -8vmax; bottom: -8vmax;
  background: radial-gradient(circle, var(--blob-2), transparent 70%);
  animation-duration: 36s;
  animation-delay: -12s;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(4vmax, 3vmax) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}

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

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

h1 { letter-spacing: -0.02em; }

/* Glass surface, used by header, cards, panels */
.card,
.tool-card,
.editor-side,
.editor-main,
.site-header,
.toolbar,
.crop-bar,
.file-row,
.swatch,
.dropzone {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
}

/* ---------- Header: floating glass pill ---------- */
.site-header {
  position: sticky;
  top: 12px;
  z-index: 20;
  margin: 12px 16px 0;
  border-radius: 999px;
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 10px 0 18px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo img { width: 28px; height: 28px; border-radius: 9px; }
.site-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.site-nav a:hover { background: var(--glass-strong); color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--glass-strong); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }

main { flex: 1; width: 100%; }

.container { max-width: 1200px; margin: 0 auto; padding: 32px 16px; }

.site-footer {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 16px;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  margin-left: auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}
.theme-toggle svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 56px 0 24px; }
.hero h1 {
  font-size: clamp(34px, 5.5vw, 56px);
  line-height: 1.2;
  margin: 0 0 14px;
  padding-bottom: .12em; /* room for descenders; the gradient clip would otherwise cut them off */
  font-weight: 700;
  background: linear-gradient(120deg, var(--text) 10%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--muted); font-size: 18px; margin: 0 auto; max-width: 560px; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  justify-content: center; /* auto-fit collapses empty columns; centre whatever is left */
  gap: 18px;
  margin-top: 28px;
}
.tool-card {
  position: relative;
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text);
  overflow: hidden;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), background .25s;
  display: block;
}
/* Specular sheen along the top edge of the glass */
.tool-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.5) 0%, rgba(255,255,255,0) 42%);
  pointer-events: none;
}
:root[data-theme="dark"] .tool-card::before { opacity: .12; }
/* Hover only lifts the card. The background stays the same so the colours don't shift on click. */
.tool-card:hover,
.tool-card:focus-visible {
  transform: translateY(-3px);
  text-decoration: none;
}
.tool-card .icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255,255,255,.7), var(--accent-soft));
  color: var(--accent);
  display: grid; place-items: center;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 6px 18px rgba(74,91,240,.16);
}
:root[data-theme="dark"] .tool-card .icon {
  background: linear-gradient(145deg, rgba(255,255,255,.12), var(--accent-soft));
}
.tool-card h2 { font-size: 19px; margin: 0 0 6px; font-weight: 650; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; }

.privacy-note {
  margin: 44px auto 0;
  max-width: 560px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Common controls ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 8px rgba(40,50,110,.08);
  transition: transform .15s, background .2s, box-shadow .2s;
}
.btn:hover { background: var(--glass); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(160deg, #6674f5, var(--accent));
  border-color: rgba(255,255,255,.4);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 6px 18px rgba(74,91,240,.3);
}
.btn.primary:hover { background: linear-gradient(160deg, #7784ff, var(--accent-hover)); }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; }
a.btn, a.btn:hover { text-decoration: none; }
.back-row { margin: 0 0 12px; }
.btn svg { width: 16px; height: 16px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
.btn-row.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }

label.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label.field > span { display: flex; justify-content: space-between; margin-bottom: 6px; }
label.field output { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="number"], select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-sm);
  background: var(--glass-strong);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  box-shadow: inset 0 1px 2px rgba(40,50,110,.06);
}
input[type="checkbox"] { accent-color: var(--accent); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }

h3 { font-size: 14px; }

/* ---------- Drop zone ---------- */
.dropzone {
  border: 1.5px dashed var(--glass-edge);
  border-radius: var(--radius);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: var(--glass-strong);
  transform: scale(1.005);
}
.dropzone h2 { margin: 14px 0 4px; font-size: 19px; font-weight: 650; }
.dropzone p { margin: 0; color: var(--muted); font-size: 14px; }
.dropzone svg { width: 44px; height: 44px; color: var(--accent); }
.dropzone input { display: none; }

/* ---------- Editor layout ---------- */
.editor {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 88px);
  flex: none;
}
.editor-side {
  border-radius: var(--radius);
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
}
.panel { border-bottom: 1px solid var(--glass-edge); padding-bottom: 16px; margin-bottom: 16px; }
.panel:last-child { border-bottom: 0; }
.panel h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 650;
  margin: 0 0 12px;
}

.editor-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
  border-radius: 0;
  border-width: 0 0 1px 0;
  background: transparent;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: none;
}
.toolbar .spacer { flex: 1; }
.toolbar .info { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
  position: relative;
}
.stage .dropzone { width: min(560px, 100%); background: var(--glass); }
.stage-inner { position: relative; display: inline-block; line-height: 0; }
.stage canvas {
  display: block;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(30, 40, 90, .22), 0 0 0 1px rgba(255,255,255,.5);
  background-color: var(--checker);
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.5) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.5) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.5) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.5) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  touch-action: none;
}

/* Crop overlay */
.crop-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; overflow: hidden; border-radius: 10px; }
.crop-stage canvas { display: block; }
.crop-layer { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.crop-layer[hidden] { display: none; }
.crop-box {
  position: absolute;
  /* Accent outline with a dark halo, so the edge shows on both white and dark parts of an image */
  border: 2px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 0 0 9999px rgba(15, 18, 40, .45);
  cursor: move;
  background-image:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.45) calc(33.33% - .5px), rgba(255,255,255,.45) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.45) calc(66.66% - .5px), rgba(255,255,255,.45) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.45) calc(33.33% - .5px), rgba(255,255,255,.45) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255,255,255,.45) calc(66.66% - .5px), rgba(255,255,255,.45) calc(66.66% + .5px), transparent calc(66.66% + .5px));
}
.crop-layer:not(.has-box) .crop-box { display: none; }
.crop-handle {
  position: absolute;
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .4);
}
.crop-handle[data-h="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle[data-h="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle[data-h="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle[data-h="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }

.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.filter-grid .btn { padding: 7px 4px; font-size: 12px; }

.hidden { display: none !important; }

.crop-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 0;
  border-width: 0 0 1px 0;
  background: var(--accent-soft);
  font-size: 13px;
  box-shadow: none;
}
.crop-bar select { width: auto; border-radius: 999px; }
.crop-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.crop-field input { width: 76px; padding: 5px 8px; }

/* ---------- Converter list ---------- */
.two-col { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.card { border-radius: var(--radius); padding: 20px; }
.file-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.file-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 14px;
  align-items: center;
  border-radius: 18px;
  padding: 10px;
}
.file-row img { width: 60px; height: 60px; object-fit: cover; border-radius: 12px; background: var(--checker); }
.file-row .name { font-size: 14px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-row .meta .good { color: var(--success); font-weight: 600; }
.file-row .meta .bad { color: var(--danger); font-weight: 600; }
.file-row .actions { display: flex; gap: 6px; }

/* ---------- Palette ---------- */
.palette-stage { position: relative; line-height: 0; }
.palette-stage canvas {
  max-width: 100%;
  max-height: 70vh;
  cursor: crosshair;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(30, 40, 90, .22), 0 0 0 1px rgba(255,255,255,.5);
}
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.swatch {
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  color: var(--text);
  transition: transform .2s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch .chip { height: 60px; box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.swatch .code { padding: 7px 10px; font-size: 13px; font-family: ui-monospace, Consolas, monospace; }
.picked { display: flex; gap: 14px; align-items: center; }
.picked .chip {
  width: 60px; height: 60px; border-radius: 18px;
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 6px 18px rgba(30,40,90,.2);
}
.picked code { font-size: 14px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--text);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .dropzone:hover, .dropzone.over, .tool-card:hover { transform: none; }
}

/* ---------- Ads, consent banner, legal pages ---------- */
.ad-slot {
  max-width: 980px;
  margin: 28px auto;
  padding: 10px;
  min-height: 100px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  text-align: center;
}
.ad-slot[hidden] { display: none; }
.ad-slot::before {
  content: "Advertisement";
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.consent {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 18px;
  z-index: 150;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  font-size: 14px;
}
.consent p { margin: 0; flex: 1 1 260px; }

.legal-links {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.legal-links a { color: var(--muted); }
.legal-links a[aria-current="page"] { color: var(--text); }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }
.link-btn[hidden] { display: none; }

.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  line-height: 1.65;
}
.prose h1 { margin: 0 0 6px; font-size: 32px; }
.prose h2 { font-size: 19px; margin: 28px 0 8px; }
.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 22px; }
.prose .updated { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.wave-wrap { border-radius: 14px; background: var(--glass-strong); padding: 8px; }
.wave-wrap canvas { width: 100%; height: 160px; display: block; }

.placeholder {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 500;
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .site-header { margin: 8px 8px 0; top: 8px; }
  .site-header .inner { gap: 12px; padding-right: 6px; }
  .editor { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; padding: 8px; }
  .editor-side { order: 2; overflow: visible; }
  .editor-main { order: 1; }
  .stage { min-height: 50vh; padding: 16px; }
  .two-col { grid-template-columns: 1fr; }
  .hero { padding-top: 36px; }
}
