/* =========================================================================
   Tokens
   ========================================================================= */
:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --border-strong: #cfd4e3;
  --text: #14172a;
  --muted: #5b6178;
  --faint: #868ca3;
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef0ff;
  --ok: #0f9d58;
  --warn: #b45309;
  --danger: #d33a3a;
  --shadow: 0 1px 2px rgba(16, 20, 40, .05), 0 8px 24px -12px rgba(16, 20, 40, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0d0f17;
  --surface: #151824;
  --surface-2: #1c2030;
  --border: #262c3d;
  --border-strong: #39405a;
  --text: #e8eaf2;
  --muted: #a2a9bf;
  --faint: #79809a;
  --brand: #7c7bff;
  --brand-hover: #9694ff;
  --brand-soft: #1e1f3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .7);
}

/* =========================================================================
   Base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

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

img, svg, canvas { display: block; max-width: 100%; }
svg { width: 100%; height: 100%; }
a { color: var(--brand); text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
h1, h2, h3 { line-height: 1.22; letter-spacing: -.018em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 1.05rem + .9vw, 1.6rem); }
h3 { font-size: 1.05rem; }
code { font-family: var(--mono); font-size: .875em; background: var(--surface-2); padding: .12em .38em; border-radius: 5px; }

main { flex: 1; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }
.section { padding-block: clamp(2rem, 5vw, 3.5rem); }
.lede { color: var(--muted); font-size: clamp(1rem, .95rem + .3vw, 1.14rem); max-width: 68ch; }

.skiplink { position: absolute; left: -9999px; top: 0; background: var(--brand); color: #fff; padding: 10px 16px; z-index: 200; border-radius: 0 0 8px 0; }
.skiplink:focus { left: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { display: flex; align-items: center; gap: 20px; height: 62px; }

.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.02em; font-size: 1.06rem; }
.logo__mark { width: 26px; height: 26px; color: var(--brand); flex: none; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav > a { color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 500; padding: 8px 11px; border-radius: 8px; }
.nav > a:hover { color: var(--text); background: var(--surface-2); }

.dropdown { position: relative; }
.dropdown > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: .92rem; font-weight: 500; color: var(--muted); padding: 8px 11px; border-radius: 8px;
}
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary:hover { color: var(--text); background: var(--surface-2); }
.dropdown[open] > summary { color: var(--text); background: var(--surface-2); }
.dropdown > summary svg { width: 14px; height: 14px; flex: none; transition: transform .16s; }
.dropdown[open] > summary svg { transform: rotate(180deg); }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; list-style: none; margin: 0;
  display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 2px;
  max-height: 70vh; overflow: auto;
}
.menu__item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.menu__item:hover { background: var(--surface-2); }
.menu__item.is-active { background: var(--brand-soft); color: var(--brand); }
.menu__icon { width: 17px; height: 17px; flex: none; color: var(--faint); }
.menu__item:hover .menu__icon, .menu__item.is-active .menu__icon { color: var(--brand); }

.themebtn { flex: none; width: 36px; height: 36px; padding: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; color: var(--muted); cursor: pointer; }
.themebtn:hover { color: var(--text); border-color: var(--border-strong); }
.themebtn__moon { display: none; }
html[data-theme="dark"] .themebtn__sun { display: none; }
html[data-theme="dark"] .themebtn__moon { display: block; }

@media (max-width: 700px) {
  .nav > a { display: none; }
  .menu { grid-template-columns: 1fr; position: fixed; left: 12px; right: 12px; top: 66px; }
}

/* =========================================================================
   Layout
   ========================================================================= */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; padding-block: 28px 56px; align-items: start; }
.layout__main { min-width: 0; }
.layout__side { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } .layout__side { display: none; } }

.crumbs { font-size: .85rem; color: var(--faint); margin-bottom: 12px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.layout__main h1 { margin-bottom: 10px; }
.layout__main > .lede { margin-bottom: 22px; }

.grid { display: grid; gap: 14px; }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* =========================================================================
   Hero + home
   ========================================================================= */
.hero { padding-block: clamp(2.5rem, 7vw, 5rem) clamp(1.5rem, 4vw, 2.5rem); text-align: center; background: radial-gradient(80% 120% at 50% -20%, var(--brand-soft), transparent 65%); }
.hero__eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; font-weight: 700; color: var(--brand); margin-bottom: 14px; }
.hero h1 { max-width: 16ch; margin-inline: auto; }
.hero .lede { margin: 16px auto 0; }
.hero__cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }

.toolcard { display: flex; align-items: center; gap: 13px; padding: 15px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s; }
.toolcard:hover { border-color: var(--brand); transform: translateY(-2px); color: var(--text); }
.toolcard__icon { flex: none; width: 40px; height: 40px; padding: 9px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); }
.toolcard__body { min-width: 0; flex: 1; }
.toolcard__name { display: block; font-weight: 650; font-size: .97rem; }
.toolcard__desc { display: block; font-size: .845rem; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.toolcard__arrow { flex: none; width: 18px; height: 18px; color: var(--faint); }
.toolcard:hover .toolcard__arrow { color: var(--brand); }

.feature { padding: 20px; }
.feature h3 { margin-bottom: 7px; }
.feature p { color: var(--muted); font-size: .93rem; }

.linklist { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; }
.linklist a { text-decoration: none; }
.linklist a::before { content: "→ "; color: var(--faint); }

/* =========================================================================
   Buttons + form controls
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .93rem; line-height: 1;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s;
}
.btn--lg { padding: 14px 24px; font-size: 1rem; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-hover); color: #fff; }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { padding: 7px 12px; font-size: .82rem; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .fieldset > legend { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
input[type="text"], input[type="number"], select {
  font: inherit; font-size: .93rem; padding: 9px 11px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text);
}
input[type="color"] { width: 44px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: .9rem; cursor: pointer; }

.segment { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.segment button { font: inherit; font-size: .86rem; font-weight: 550; padding: 7px 13px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.segment button:hover { color: var(--text); }
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* =========================================================================
   Tool
   ========================================================================= */
.tool { padding: 18px; }
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: clamp(28px, 6vw, 48px) 20px; text-align: center; cursor: pointer;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone__icon { width: 38px; height: 38px; margin: 0 auto 12px; color: var(--brand); }
.dropzone__title { font-weight: 650; font-size: 1.05rem; }
.dropzone__hint { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.dropzone .link { color: var(--brand); text-decoration: underline; }

.tool__files { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.filerow { display: flex; align-items: center; gap: 11px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.filerow__thumb { width: 42px; height: 42px; flex: none; border-radius: 7px; object-fit: cover; background: var(--border); }
.filerow__meta { min-width: 0; flex: 1; }
.filerow__name { font-size: .88rem; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filerow__sub { font-size: .78rem; color: var(--muted); }
.filerow__act { display: flex; gap: 4px; flex: none; }
.iconbtn { width: 30px; height: 30px; padding: 7px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; color: var(--muted); cursor: pointer; }
.iconbtn:hover { color: var(--brand); border-color: var(--brand); }
.iconbtn[disabled] { opacity: .35; cursor: not-allowed; }

.tool__options { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); display: grid; gap: 16px; }
.optrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.opthead { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.opthint { font-size: .8rem; color: var(--faint); }

.tool__actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.tool__progress { margin-top: 16px; }
.bar { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar__fill { height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .18s; }
.tool__progress-text { font-size: .85rem; color: var(--muted); margin-top: 7px; }
.tool__error { margin-top: 14px; padding: 11px 13px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 10%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); font-size: .89rem; }

.tool__results { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.results__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.results__title { font-weight: 700; font-size: 1.02rem; }
.results__summary { font-size: .85rem; color: var(--muted); }
.results__list { display: flex; flex-direction: column; gap: 8px; }
.delta { font-weight: 650; }
.delta--good { color: var(--ok); }
.delta--bad { color: var(--warn); }

.tool__stage { margin-top: 16px; }

.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.badge { font-size: .76rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 5px 10px; border-radius: 99px; }

/* crop stage */
.cropstage { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.cropstage img { display: block; max-width: 100%; }
.cropbox { position: absolute; border: 1px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5); cursor: move; }
.cropbox::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(to right, rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 33.33% 33.33%; pointer-events: none; }
.crophandle { position: absolute; width: 14px; height: 14px; background: #fff; border: 1px solid rgba(0,0,0,.3); border-radius: 3px; }
.crophandle[data-h="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
.crophandle[data-h="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
.crophandle[data-h="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
.crophandle[data-h="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }
.crophandle[data-h="n"] { left: 50%; top: -7px; margin-left: -7px; cursor: ns-resize; }
.crophandle[data-h="s"] { left: 50%; bottom: -7px; margin-left: -7px; cursor: ns-resize; }
.crophandle[data-h="w"] { left: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.crophandle[data-h="e"] { right: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }

/* position 3x3 picker */
.posgrid { display: grid; grid-template-columns: repeat(3, 34px); grid-auto-rows: 34px; gap: 4px; }
.posgrid button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; cursor: pointer; padding: 0; }
.posgrid button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); }

/* palette swatches */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: var(--surface); text-align: left; padding: 0; font: inherit; }
.swatch__chip { height: 68px; }
.swatch__meta { padding: 8px 10px; }
.swatch__hex { font-family: var(--mono); font-size: .85rem; font-weight: 600; }
.swatch__sub { font-size: .72rem; color: var(--muted); }

/* exif table */
.metatable { width: 100%; border-collapse: collapse; font-size: .85rem; }
.metatable th, .metatable td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.metatable th { color: var(--muted); font-weight: 600; width: 40%; }
.metatable td { font-family: var(--mono); font-size: .8rem; word-break: break-word; }
.pill { display: inline-block; font-size: .72rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; }
.pill--warn { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.pill--ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* =========================================================================
   Prose / FAQ
   ========================================================================= */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 2.2rem; margin-bottom: .6rem; }
.prose h3 { margin-top: 1.4rem; margin-bottom: .35rem; }
.prose p, .prose ul, .prose ol { color: var(--muted); margin-bottom: .9rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.prose strong { color: var(--text); }
.steps li { margin-bottom: .55rem; }
.bigmail { font-size: 1.15rem; font-weight: 600; font-family: var(--mono); }

.faq { display: flex; flex-direction: column; gap: 8px; }
.faq__item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.faq__item > summary { cursor: pointer; padding: 13px 15px; font-weight: 600; font-size: .95rem; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq__item > summary::-webkit-details-marker { display: none; }
.faq__item > summary::after { content: "+"; color: var(--faint); font-weight: 400; font-size: 1.3rem; line-height: 1; flex: none; }
.faq__item[open] > summary::after { content: "\2212"; }
.faq__a { padding: 0 15px 14px; }
.faq__a p { color: var(--muted); font-size: .92rem; margin: 0; }

.related { margin-top: 2.6rem; }
.related h2 { margin-bottom: .9rem; }

.sidenav { padding: 14px; }
.sidenav__title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 9px; }
.sidenav ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.sidenav a { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .875rem; }
.sidenav a svg { width: 16px; height: 16px; flex: none; color: var(--faint); }
.sidenav a:hover { background: var(--surface-2); color: var(--text); }
.sidenav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidenav a[aria-current="page"] svg { color: var(--brand); }

.notfound { text-align: center; }
.notfound .grid { text-align: left; margin-top: 24px; }

/* =========================================================================
   Ads
   ========================================================================= */
.adbox { display: block; margin-block: 28px; text-align: center; }
.adbox__label { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .14em; color: var(--faint); margin-bottom: 5px; }
.adbox--sidebar { margin-block: 0; }
.adbox.is-sticky { position: sticky; top: 78px; }
.adbox--placeholder {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  color: var(--faint); font-size: .78rem; font-family: var(--mono);
  display: grid; place-items: center; background: var(--surface-2);
}
.adbox--placeholder.adbox--inContent { min-height: 250px; }
.adbox--placeholder.adbox--sidebar { min-height: 600px; }
.adbox--placeholder.adbox--footer { min-height: 100px; margin-bottom: 0; }
@media (max-width: 1000px) { .adbox--sidebar { display: none; } }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; }
.site-footer__inner { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; padding-block: 40px 28px; }
.site-footer__brand p { color: var(--muted); font-size: .88rem; margin-top: 11px; max-width: 42ch; }
.site-footer h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 10px; }
.site-footer ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.site-footer a { color: var(--muted); text-decoration: none; font-size: .88rem; }
.site-footer a:hover { color: var(--brand); }
.site-footer__legal { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: .82rem; }
@media (max-width: 780px) { .site-footer__inner { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .site-footer__inner { grid-template-columns: 1fr; } }

/* =========================================================================
   Toast
   ========================================================================= */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: .88rem; font-weight: 550; z-index: 300; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; }
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
