/* tools.css — shared look for /tools (the hub) and the in-browser image tools
   (image-compressor, image-converter, crop-image, watermark-image, color-palette-extractor,
   image-upscaler). Small on purpose: these pages don't load the 4,500-line app style.css.
   The nav + footer styles are injected by nav.js; the light-theme overrides for them live
   at the bottom of this file. Theme = <html data-theme="dark|light">, same 'ms_theme'
   localStorage key as the rest of the site, set by an inline script in each page's <head>. */

:root {
  --bg: #09090b;
  --bg-2: #0f0f12;
  --surface: rgba(255,255,255,0.045);
  --surface-2: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.10);
  --border-hi: rgba(255,255,255,0.18);
  --text: #f5f5f7;
  --text-2: rgba(245,245,247,0.74);
  --text-3: rgba(245,245,247,0.54);
  --accent: #e8734a;
  --accent-hover: #f0845d;
  --accent-soft: rgba(232,115,74,0.12);
  --accent-line: rgba(232,115,74,0.32);
  --on-accent: #ffffff;
  --good: #4ade80;
  --good-soft: rgba(74,222,128,0.12);
  --warn: #fbbf24;
  --bad: #f87171;
  --checker-a: #d4d4d9;
  --checker-b: #e6e6ea;
  --shadow: 0 18px 50px rgba(0,0,0,0.45);
  --r: 14px;
  --r-sm: 9px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #fafaf9;
  --bg-2: #f3f2ef;
  --surface: #ffffff;
  --surface-2: #f1f0ed;
  --border: rgba(28,25,23,0.11);
  --border-hi: rgba(28,25,23,0.22);
  --text: #1c1917;
  --text-2: rgba(28,25,23,0.76);
  --text-3: rgba(28,25,23,0.56);
  --accent: #c2410c;
  --accent-hover: #a8380a;
  --accent-soft: rgba(194,65,12,0.08);
  --accent-line: rgba(194,65,12,0.30);
  --good: #15803d;
  --good-soft: rgba(21,128,61,0.10);
  --warn: #a16207;
  --bad: #b91c1c;
  --checker-a: #ffffff;
  --checker-b: #ebeae6;
  --shadow: 0 18px 50px rgba(28,25,23,0.12);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
img, canvas, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.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; }

/* ── Page frame ─────────────────────────────────────────── */
.tw { width: 100%; max-width: 1180px; margin: 0 auto; padding: 44px 24px 40px; }
.tw-narrow { max-width: 980px; }
.t-crumbs { font-size: 14px; color: var(--text-3); margin-bottom: 14px; }
.t-crumbs a { color: var(--text-2); text-decoration: none; }
.t-crumbs a:hover { color: var(--accent); }
.t-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.t-title { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; }
.t-sub { font-size: 17px; color: var(--text-2); line-height: 1.55; margin-top: 10px; max-width: 680px; }
.t-trust { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.t-trust svg { color: var(--good); flex-shrink: 0; }

.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; line-height: 1.3; white-space: nowrap; vertical-align: middle; }
.badge-new { background: var(--accent); color: var(--on-accent); }
.badge-free { background: var(--good-soft); color: var(--good); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
.t-title .badge { margin-left: 10px; position: relative; top: -4px; }

.theme-btn {
  width: 40px; height: 40px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--border-hi); background: var(--surface); color: var(--text-2); cursor: pointer; transition: color .15s, border-color .15s;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn .i-sun { display: none; }
[data-theme="light"] .theme-btn .i-sun { display: block; }
[data-theme="light"] .theme-btn .i-moon { display: none; }

/* ── Drop zone ──────────────────────────────────────────── */
.dz {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 220px; padding: 34px 20px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border-hi); border-radius: var(--r); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.dz:hover, .dz.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz input[type=file] { display: none; }
.dz-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.dz-title { font-size: 19px; font-weight: 700; }
.dz-sub { font-size: 15px; color: var(--text-2); }
.dz-btn { margin-top: 6px; }
.dz.compact { min-height: 0; padding: 14px 18px; display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 2px; justify-items: start; align-items: center; text-align: left; }
.dz.compact .dz-icon { width: 40px; height: 40px; border-radius: 11px; grid-row: 1 / 3; }
.dz.compact .dz-title { font-size: 15px; }
.dz.compact .dz-sub { font-size: 13.5px; }
.dz.compact .dz-btn { display: none; }

/* ── Controls ───────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; }
.ctrls { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 18px 28px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--text-3); }
.sel, .inp {
  height: 42px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-hi); background: var(--bg);
  color: var(--text); font-size: 15px; font-weight: 500; min-width: 0;
}
.sel { padding-right: 34px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23999' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.sel:focus, .inp:focus { outline: none; border-color: var(--accent); }
.inp[type=color] { width: 46px; padding: 4px; cursor: pointer; }
.sw-row { display: flex; align-items: center; gap: 8px; height: 42px; }
.sw { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-hi); cursor: pointer; padding: 0; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { min-width: 44px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type=range] { accent-color: var(--accent); width: 190px; height: 28px; cursor: pointer; }

.seg { display: inline-flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border-hi); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 8px 13px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent; font-size: 15px; font-weight: 650; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-hi); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.spacer { flex: 1; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0; }
.bar-note { font-size: 14px; color: var(--text-2); }
.bar-note strong { color: var(--text); }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* ── Result cards ───────────────────────────────────────── */
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.rc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.rc-thumb { position: relative; aspect-ratio: 4 / 3; background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 18px 18px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.rc-thumb img, .rc-thumb canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.rc-thumb button { position: absolute; inset: 0; border: 0; background: none; cursor: zoom-in; }
.rc-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rc-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-meta { font-size: 13.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rc-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.rc-actions .btn { flex: 1; }
.rc-actions .btn-icon { flex: 0 0 auto; }
.rc-status { font-size: 13px; color: var(--text-3); }
.pill-save { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--good-soft); color: var(--good); }

/* ── Editor layout (crop-image, watermark-image, color-palette-extractor, image-upscaler) ── */
.ed-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; margin-top: 16px; align-items: start; }
.ed-main { min-width: 0; }
.ed-stage { display: flex; justify-content: center; align-items: center; min-height: 260px; padding: 16px; border-radius: var(--r); border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 20px 20px; }
.ed-stage canvas { max-width: 100%; }
.ed-strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 4px; }
.ed-thumb { flex: 0 0 64px; height: 64px; border-radius: 10px; border: 2px solid transparent; background: var(--surface-2); padding: 3px; cursor: pointer; overflow: hidden; }
.ed-thumb img { width: 100%; height: 100%; object-fit: contain; transition: transform .15s; }
.ed-thumb[aria-current="true"] { border-color: var(--accent); }
.ed-side { display: flex; flex-direction: column; gap: 20px; }
.ed-check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text-2); cursor: pointer; }
.ed-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.ed-actions { display: flex; flex-direction: column; gap: 8px; }
.ed-count { font-size: 13.5px; color: var(--text-3); text-align: center; }
.ed-side input[type=range] { width: 100%; flex: 1; }
.ed-side .range-row { width: 100%; }
@media (max-width: 900px) { .ed-wrap { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .ed-stage { padding: 8px; min-height: 200px; } }

/* ── Post-result CTA into the studio ───────────────────── */
.cta-box { display: none; margin-top: 26px; padding: 18px 20px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid var(--accent-line); align-items: center; gap: 16px; flex-wrap: wrap; }
.cta-box.show { display: flex; }
.cta-box .cta-txt { flex: 1; min-width: 220px; }
.cta-box strong { display: block; font-size: 16px; }
.cta-box span { font-size: 14.5px; color: var(--text-2); }

/* ── Compare modal (before / after slider) ─────────────── */
.cmp-back { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.78); display: flex; align-items: center; justify-content: center; padding: 20px; }
.cmp { background: var(--bg); border: 1px solid var(--border-hi); border-radius: var(--r); width: min(1000px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.cmp-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.cmp-head strong { color: var(--text); }
.cmp-stage { position: relative; flex: 0 0 auto; height: min(72vh, 720px); overflow: hidden; background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 20px 20px; touch-action: none; cursor: ew-resize; user-select: none; }
.cmp-stage:focus-visible { outline: none; }
.cmp-zw { position: absolute; inset: 0; transform-origin: var(--ox, 50%) var(--oy, 50%); transform: scale(var(--z, 1)); transition: transform .18s ease; }
.cmp-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.cmp-stage .cmp-after { clip-path: inset(0 0 0 var(--cutl, 50%)); }
.cmp-zoom[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.cmp-line { position: absolute; top: 0; bottom: 0; left: var(--cut, 50%); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); pointer-events: none; }
.cmp-knob { position: absolute; top: 50%; left: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; background: #fff; color: #111; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.cmp-tag { position: absolute; top: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; font-size: 12.5px; font-weight: 700; pointer-events: none; }
.cmp-tag.l { left: 12px; } .cmp-tag.r { right: 12px; }

/* ── Toast ──────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 1100; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14.5px; font-weight: 600; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── How-to / FAQ copy ─────────────────────────────────── */
.tool-content { max-width: 760px; margin: 64px auto 0; padding-top: 44px; border-top: 1px solid var(--border); }
.tool-content h2 { font-size: 23px; font-weight: 700; letter-spacing: -0.015em; margin: 36px 0 12px; }
.tool-content h2:first-child { margin-top: 0; }
.tool-content h3 { font-size: 17px; font-weight: 650; margin: 22px 0 6px; }
.tool-content p, .tool-content li { font-size: 16px; color: var(--text-2); line-height: 1.7; }
.tool-content p + p { margin-top: 10px; }
.tool-content ul, .tool-content ol { margin: 10px 0 12px; padding-left: 22px; }
.tool-content li { margin-bottom: 5px; }
.tool-content strong { color: var(--text); }

.more-tools { max-width: 760px; margin: 48px auto 0; }
.more-tools-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.more-tools-title { font-size: 13px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.more-tools-all { font-size: 14.5px; font-weight: 600; text-decoration: none; }
.more-tools-all:hover { text-decoration: underline; }
.more-tools-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.more-tool-link { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); font-size: 15px; font-weight: 650; transition: border-color .15s; }
.more-tool-link:hover { border-color: var(--accent-line); }
.more-tool-link span { font-size: 13.5px; font-weight: 400; color: var(--text-2); }

@media (max-width: 720px) {
  .tw { padding: 28px 16px 32px; }
  .t-title { font-size: 27px; }
  .t-sub { font-size: 16px; }
  .more-tools-grid { grid-template-columns: 1fr 1fr; }
  .ctrls { gap: 16px; }
  .ctrls > .field { flex: 1 1 100%; }
  input[type=range] { width: 100%; flex: 1; }
  .range-row { width: 100%; }
  .rgrid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .rc-body { padding: 10px; }
  .rc-actions { flex-wrap: wrap; }
  .rc-actions:has(.cmp-btn) .btn-primary { order: -1; flex: 1 1 100%; }
  .panel { padding: 16px; }
  .dz { min-height: 180px; }
}
@media (max-width: 380px) {
  .rgrid { grid-template-columns: 1fr; }
}

/* ── Light theme for the shared nav + footer (nav.js injects dark-only rules) ── */
[data-theme="light"] .site-nav { background: rgba(250,250,249,0.96); border-bottom-color: rgba(28,25,23,0.09); }
[data-theme="light"] .nav-name { color: #1c1917; }
[data-theme="light"] .nav-link, [data-theme="light"] .nav-sub-btn { color: rgba(28,25,23,0.72); }
[data-theme="light"] .nav-link:hover, [data-theme="light"] .nav-sub-btn:hover,
[data-theme="light"] .nav-sub-wrap.open .nav-sub-btn, [data-theme="light"] .nav-sub-wrap:hover .nav-sub-btn { color: #1c1917; }
[data-theme="light"] .nav-sub-menu, [data-theme="light"] .nav-dropdown { background: #fff; border-color: rgba(28,25,23,0.12); box-shadow: 0 20px 50px rgba(28,25,23,0.14); }
[data-theme="light"] .nav-sub-item:hover, [data-theme="light"] .nav-drop-item:hover { background: rgba(28,25,23,0.05); }
[data-theme="light"] .nav-sub-name { color: #1c1917; }
[data-theme="light"] .nav-sub-desc { color: rgba(28,25,23,0.6); }
[data-theme="light"] .nav-sub-divider { background: rgba(28,25,23,0.08); }
[data-theme="light"] .nav-drop-item { color: rgba(28,25,23,0.75); }
[data-theme="light"] .nav-hamburger span { background: rgba(28,25,23,0.7); }
[data-theme="light"] .nav-mobile-close { color: rgba(28,25,23,0.7); }
[data-theme="light"] .site-footer { border-top-color: rgba(28,25,23,0.10); }
[data-theme="light"] .footer-col-title { color: rgba(28,25,23,0.72); }
[data-theme="light"] .footer-col a, [data-theme="light"] .footer-help { color: rgba(28,25,23,0.62); }
[data-theme="light"] .footer-col a:hover, [data-theme="light"] .footer-help a { color: #1c1917; }
[data-theme="light"] .footer-bottom { border-top-color: rgba(28,25,23,0.08); }
[data-theme="light"] .footer-copy, [data-theme="light"] .footer-help-sep { color: rgba(28,25,23,0.5); }
@media (max-width: 940px) {
  [data-theme="light"] .nav-links { background: #fafaf9; border-bottom-color: rgba(28,25,23,0.1); }
  [data-theme="light"] .nav-links .nav-link { color: rgba(28,25,23,0.85); }
  [data-theme="light"] .nav-sub-btn { color: rgba(28,25,23,0.45); }
  [data-theme="light"] .nav-sub-name { color: rgba(28,25,23,0.82); }
  [data-theme="light"] .nav-sub-menu { background: none; box-shadow: none; }
}
