:root {
  --bg: #f6f8f9;
  --surface: #ffffff;
  --text: #15191c;
  --muted: #5d6870;
  --line: #e1e6e9;
  --accent: #09b1ba;
  --accent-ink: #067e85;
  --accent-soft: #e3f7f8;
  --danger: #c53b3b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 8px 24px rgba(16, 24, 32, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1315;
    --surface: #171c1f;
    --text: #e8edef;
    --muted: #97a3aa;
    --line: #283035;
    --accent: #2cc6cf;
    --accent-ink: #5fd8df;
    --accent-soft: #11292b;
    --danger: #ef6b6b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); }
h1, h2 { line-height: 1.2; letter-spacing: -.01em; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.logo b { color: var(--accent-ink); }
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  box-shadow: inset 0 0 0 6px var(--accent), inset 0 0 0 20px #fff;
}
.nav { display: flex; gap: 20px; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav a:hover { color: var(--text); }

.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 24px 0 96px; color: var(--muted); font-size: .9rem; }
.footer-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.side-col { padding-top: 24px; }
.sticky { position: sticky; top: 16px; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-col { display: none; }
}

/* Hero */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); margin: 0 0 12px; }
.accent { color: var(--accent-ink); }
.lede { color: var(--muted); font-size: 1.1rem; margin: 0; max-width: 60ch; }

/* Tool */
.tool {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 24px 0;
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 40px 16px; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.dz-icon { width: 44px; height: 44px; color: var(--accent); }
.dropzone strong { font-size: 1.15rem; }
.dropzone span { color: var(--muted); font-size: .95rem; }

.file-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.file-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; font-size: .95rem;
}
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .fmeta { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.file-list .ferr { color: var(--danger); font-size: .85rem; }
.file-list .remove {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.file-list .remove:hover { background: var(--bg); color: var(--text); }

.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(.95); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }

.status { margin-top: 12px; color: var(--muted); font-size: .95rem; min-height: 1.4em; }
.status.error { color: var(--danger); }

.result { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 20px; }
.result-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.result-head h2 { margin: 0; font-size: 1.3rem; }
.result-actions { display: flex; gap: 10px; }
.hint { color: var(--muted); font-size: .9rem; margin: 12px 0 16px; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.previews figure { margin: 0; }
.previews canvas {
  width: 100%; height: auto; background: #fff; border-radius: 6px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.previews figcaption { color: var(--muted); font-size: .8rem; margin-top: 6px; text-align: center; }

/* Content */
.content { margin: 40px 0; }
.content h2 { font-size: 1.5rem; }
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: 8px; }
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 8px 0 0; }

/* Ad slots. Sizes match standard IAB units so layout doesn't jump when ads load.
   Hidden until a manual ad unit is placed inside and the slot gets class "filled";
   while running AdSense Auto ads only, Google places ads itself. */
.ad:not(.filled) { display: none !important; }
.ad {
  display: flex; align-items: center; justify-content: center; margin: 16px auto;
  background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(127,127,127,.06) 10px 20px);
  border: 1px dashed var(--line); border-radius: 8px; color: var(--muted);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; overflow: hidden;
}
.ad.filled { background: none; border: 0; }
.ad-leaderboard { max-width: 728px; min-height: 90px; }
.ad-inline { max-width: 728px; min-height: 250px; }
.ad-sky { width: 300px; min-height: 600px; margin: 0; }
.ad-anchor { display: none; }

@media (max-width: 760px) {
  .ad-leaderboard { min-height: 100px; max-width: 320px; }
  .ad-inline { max-width: 336px; min-height: 280px; }
  .ad-anchor {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 10;
    min-height: 60px; border-radius: 0; background-color: var(--surface); border-width: 1px 0 0;
  }
  .nav { display: none; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Tool page content */
.trust { margin: 14px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }
.content section { margin-bottom: 36px; }
.content p, .content li { max-width: 72ch; }
.symptoms li { margin-bottom: 6px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; background: var(--bg); }
tr:last-child td { border-bottom: 0; }

/* Hub */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tool-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--accent); }
.tool-card span { color: var(--muted); font-size: .92rem; }

/* Image tools */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-top: 16px; }
.img-grid:empty { display: none; }
.img-card { position: relative; margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.img-view {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(#e9eced 25%, #fff 0 50%, #e9eced 0 75%, #fff 0) 0 0 / 16px 16px;
}
.img-view img, .img-view canvas { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.img-card.done .img-view img { display: none; }
.img-card figcaption { display: grid; gap: 4px; padding: 8px 10px 10px; font-size: .82rem; }
.img-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-state { color: var(--muted); }
.img-state.error { color: var(--danger); }
.img-card .remove {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.btn-small { min-height: 34px; padding: 0 12px; font-size: .85rem; background: var(--accent-soft); color: var(--accent-ink); }
.btn-small:hover { filter: brightness(.97); }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.output-options { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.seg { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; border: 0; padding: 0; margin: 0; }
.seg legend { font-weight: 600; margin-bottom: 6px; padding: 0; width: 100%; }
.seg label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.seg input[type="color"] { width: 32px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }

/* Forms / calculators */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; font-size: .92rem; }
.field > span { font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select {
  width: 100%; min-height: 44px; padding: 0 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.input-unit { position: relative; }
.input-unit input { padding-left: 26px; }
.input-unit::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.form-section { margin-top: 18px; }
.form-section h3 { font-size: 1rem; margin: 0 0 10px; }
.fee-note { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }

.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.good b { color: #128a4a; }
.stat.bad b { color: var(--danger); }
.breakdown { margin-top: 16px; }
.breakdown td:last-child, .breakdown th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown .total td { font-weight: 700; }
@media (prefers-color-scheme: dark) {
  .stat.good b { color: #4fd18b; }
  .img-view { background: conic-gradient(#2a3034 25%, #1e2427 0 50%, #2a3034 0 75%, #1e2427 0) 0 0 / 16px 16px; }
}
.compare tr.current td { background: var(--accent-soft); font-weight: 600; }
.compare td:nth-child(2), .compare th:nth-child(2) { text-align: right; }
.dim-table td.warn { color: #b26a00; font-weight: 600; }
@media (prefers-color-scheme: dark) { .dim-table td.warn { color: #f0b04a; } }

/* No manual sidebar ad: single centered column (leaves room for Auto ads side rails). */
.layout:not(:has(.ad-sky.filled)) { grid-template-columns: minmax(0, 820px); justify-content: center; }
.layout:not(:has(.ad-sky.filled)) .side-col { display: none; }
