/* =========================================================
   AjustaPixel — styles.css
   1. Tokens  2. Base  3. Header/hero  4. Tool card  5. Stage
   6. Controls  7. Content  8. Ads  9. Footer/legal  10. Responsive
   ========================================================= */

/* 1. Tokens */
:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #f1eee9;
  --ink: #1a1726;
  --ink-2: #4b475a;
  --ink-3: #7c7889;
  --line: #e5e1da;
  --accent: #5b3fd6;
  --accent-ink: #ffffff;
  --accent-soft: #eee9ff;
  --warm: #ffb86b;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26, 23, 38, .05), 0 10px 30px rgba(26, 23, 38, .07);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", var(--font);
  --checker: repeating-conic-gradient(#e7e4ee 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121118;
    --surface: #1b1924;
    --surface-2: #23212e;
    --ink: #f1eff7;
    --ink-2: #bdb8cc;
    --ink-3: #8f8a9f;
    --line: #2f2c3b;
    --accent: #9b85ff;
    --accent-ink: #120d2b;
    --accent-soft: #2a2450;
    --warn: #f5b04a;
    --warn-soft: #2e2412;
    --bad: #f87171;
    --bad-soft: #331717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    --checker: repeating-conic-gradient(#2b2836 0% 25%, #1f1d29 0% 50%) 0 0 / 16px 16px;
  }
}

/* 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font); overflow-x: hidden; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
kbd { font: 600 12px/1 var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; background: var(--surface); }

/* 3. Header / hero */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.header-in { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 800 18px/1 var(--display); letter-spacing: -.01em; }
.logo b { color: var(--accent); font-weight: 800; }
.top-nav { display: flex; gap: 20px; }
.top-nav a { color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.top-nav a:hover { color: var(--ink); }
.hero { padding: 24px 0 14px; }
.hero h1 { font: 800 clamp(26px, 4.2vw, 44px)/1.08 var(--display); letter-spacing: -.025em; }
.hero .sub { margin: 8px 0 0; color: var(--ink-2); max-width: 760px; font-size: clamp(15px, 1.6vw, 17px); }

/* 4. Tool card */
.noscript { background: var(--warn-soft); color: var(--warn); padding: 14px; border-radius: var(--radius-sm); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 22px; align-items: start;
}
.stage-col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.controls { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.drop {
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 16px; background: var(--accent-soft);
  min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 24px; cursor: pointer; color: var(--accent); transition: background .15s, border-color .15s;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.drop.is-over { outline: 4px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.drop-t { font: 700 19px/1.2 var(--display); color: var(--ink); }
.drop-s { color: var(--ink-2); font-size: 14px; }
.drop .btn { margin-top: 6px; pointer-events: none; }
.drop-f { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }
.card[data-state="ready"] .drop { display: none; }
.card:not([data-state="ready"]) .editor { display: none; }

.alert { border-radius: 12px; padding: 12px 14px; font-size: 14.5px; background: var(--bad-soft); color: var(--bad); }
.alert strong { display: block; margin-bottom: 2px; }

.result { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 2px 0; }
.result-info { display: flex; flex-direction: column; line-height: 1.3; }
.result-info strong { font: 800 20px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.result-info span { color: var(--ink-3); font-size: 13.5px; }
.result-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.warns li { font-size: 13.5px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }

/* 5. Stage */
.editor { display: flex; flex-direction: column; gap: 6px; }
.stage-wrap { display: flex; justify-content: center; align-items: center; background: var(--surface-2); border-radius: 14px; padding: 14px; min-height: 200px; }
.stage { position: relative; background: var(--checker); box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 6px 18px rgba(0, 0, 0, .12); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.stage.is-drag { cursor: grabbing; }
.stage canvas { width: 100%; height: 100%; }
.stage:focus-visible { outline-offset: 4px; }
.stage-hint { margin: 0; text-align: center; font-size: 12.5px; color: var(--ink-3); }

/* 6. Controls */
.g-h { font: 700 15px/1.2 var(--display); letter-spacing: .01em; margin-bottom: 10px; color: var(--ink); }
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fmt { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 10px; text-align: left; display: grid; grid-template-columns: 26px 1fr; column-gap: 9px; align-items: center; color: var(--ink); min-width: 0; }
.fmt-shape { grid-row: span 2; justify-self: center; border: 2px solid currentColor; border-radius: 3px; color: var(--ink-3); }
.fmt b { font-size: 13.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmt small { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { min-width: 0; }
.fmt:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.fmt.is-on { border-color: var(--accent); background: var(--accent-soft); }
.fmt.is-on .fmt-shape { color: var(--accent); }
.fmt-note { margin: 8px 0 0; font-size: 13px; color: var(--ink-3); min-height: 1em; }
.fmt-note:empty { display: none; }
.custom { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; margin-top: 10px; }
.swap { height: 44px; width: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 0; }

.field { display: block; margin: 10px 0 0; min-width: 0; }
.custom .field { margin: 0; }
.lbl { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.lbl small { font-weight: 400; color: var(--ink-3); }
.lbl output { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="number"] { width: 100%; height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 0 12px; font-size: 16px; }
input[type="number"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
input[type="range"]:disabled { opacity: .45; }
.hint { font-size: 13px; color: var(--ink-3); margin: 8px 0 0; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-b { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg-b.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg-b:disabled { opacity: .45; cursor: not-allowed; }
.row-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.bgs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bg-b { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 2px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; }
.bg-b.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.bg-b:disabled, .bg-b.is-disabled { opacity: .4; cursor: not-allowed; }
.bg-i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .15); display: block; }
.bg-blur { background: linear-gradient(135deg, #f7a8c4, #9ad0ff, #ffe08a); filter: blur(1.5px); }
.bg-tr { background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 8px 8px; }
.bg-b input[type="color"] { width: 24px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.bg-b input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.bg-b input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0, 0, 0, .15); border-radius: 6px; }
.bg-b input[type="color"]::-moz-color-swatch { border: 1px solid rgba(0, 0, 0, .15); border-radius: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 15px; border: 1.5px solid transparent; text-decoration: none; white-space: nowrap; transition: transform .08s, filter .15s, border-color .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { height: 52px; padding: 0 22px; font-size: 16.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.link-b { border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; padding: 6px 0; }

.privacy { margin: 14px 0 0; font-size: 14px; color: var(--ink-2); background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }

/* 7. Content */
.section { padding: 44px 0 8px; }
.sec-h { font: 800 clamp(22px, 2.8vw, 30px)/1.15 var(--display); letter-spacing: -.02em; margin-bottom: 14px; }
.lead { color: var(--ink-2); max-width: 820px; margin: 0 0 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.sizes { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 620px; }
.sizes th, .sizes td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.sizes th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); background: var(--surface-2); }
.sizes tr:last-child td { border-bottom: 0; }
.sizes td:nth-child(3) { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag.oficial { background: var(--accent-soft); color: var(--accent); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.steps h3 { font-size: 17px; margin-bottom: 6px; }
.steps p { margin: 0; color: var(--ink-2); font-size: 15px; }
.prose { max-width: 820px; }
.prose h3 { font-size: 18px; margin: 22px 0 6px; }
.prose p { color: var(--ink-2); margin: 0 0 10px; }
.faq { display: grid; gap: 10px; max-width: 860px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 18px; }
.faq summary { cursor: pointer; padding: 16px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--accent); flex: none; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 16px; color: var(--ink-2); }

/* 8. Ads (empty placeholders) */
.ad-slot { border: 1.5px dashed color-mix(in srgb, var(--ink-3) 50%, transparent); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--ink-3); }
.ad-slot span { font: 600 11px/1 var(--font); letter-spacing: .16em; text-transform: uppercase; opacity: .8; }
.ad-leaderboard { margin: 26px auto 0; max-width: 728px; min-height: 90px; }
.ad-incontent { margin: 36px auto 0; max-width: 336px; min-height: 280px; }
.ad-footer { margin: 44px auto 0; max-width: 728px; min-height: 90px; }

/* 9. Footer / legal */
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); padding: 28px 0 36px; font-size: 14px; color: var(--ink-2); }
.footer-in { display: grid; gap: 10px; }
.footer-in p { margin: 0; }
.footer-in nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-in nav a { color: var(--ink-2); }
.fine { font-size: 12px; color: var(--ink-3); }
.legal { max-width: 780px; padding: 32px 0; }
.legal h1 { font: 800 32px/1.15 var(--display); margin-bottom: 16px; }
.legal h2 { font-size: 20px; margin: 26px 0 8px; }
.legal p, .legal li { color: var(--ink-2); }
.todo { background: var(--warn-soft); color: var(--warn); padding: 2px 6px; border-radius: 6px; font-weight: 600; }

/* 10. Responsive */
@media (max-width: 899px) {
  .steps { grid-template-columns: 1fr; }
  /* Phone/tablet: flatten both columns so the format row sits above the
     drop zone and the download button right under the preview. */
  .card { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .card > * , .stage-col > *, .controls > * { min-width: 0; max-width: 100%; }
  .stage-col, .controls { display: contents; }
  .group-format { order: 1; }
  .drop, .editor { order: 2; }
  .alert { order: 3; }
  .result { order: 4; }
  .warns { order: 5; }
  .group-fit { order: 6; }
  .group-out { order: 7; }
  .group-format .g-h { display: none; }
  .formats { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .fmt { flex: 0 0 auto; width: 168px; scroll-snap-align: start; }
  .drop { min-height: 230px; }
  .group-fit, .group-out { border-top: 1px solid var(--line); padding-top: 14px; }
}
@media (max-width: 640px) {
  .top-nav { display: none; }
  .hero { padding: 14px 0 10px; }
  .hero h1 { font-size: 25px; }
  .hero .sub { font-size: 14.5px; margin-top: 6px; }
  .stage-wrap { padding: 8px; }
  .result { gap: 8px; }
  .result-actions, .result-actions .btn-lg { width: 100%; }
  .bgs { grid-template-columns: repeat(5, 1fr); }
}
