:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --line: #e2e5e0;
  --line-strong: #cfd4cc;
  --text: #17201c;
  --muted: #5f6b65;
  --faint: #8b958f;
  --accent: #0e7c66;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3ee;
  --good: #11865f;
  --bad: #c2352b;
  --bad-soft: #fbeceb;
  --warn: #9a6400;
  --shadow: 0 1px 2px rgb(16 24 20 / 0.06), 0 8px 24px rgb(16 24 20 / 0.06);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #161c19;
    --surface-2: #1d2521;
    --line: #27312c;
    --line-strong: #34403a;
    --text: #e7ece9;
    --muted: #a0aca6;
    --faint: #75817b;
    --accent: #2fb594;
    --accent-ink: #06231b;
    --accent-soft: #163b31;
    --good: #3cc996;
    --bad: #f0776d;
    --bad-soft: #3a1f1d;
    --warn: #e0a940;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: 96px;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- üst çubuk */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-name { font-size: 17px; letter-spacing: -0.01em; }
.brand-name b { font-weight: 700; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab { border: 0; background: transparent; padding: 6px 16px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.server-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.server-dot.ok { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.server-dot.bad { background: var(--bad); }

/* ---------- düğmeler */
.btn { border: 1px solid var(--line-strong); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.icon-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
kbd { font: 12px var(--mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- seçenekler */
.options { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: flex-start; margin: 22px 0 16px; }
.opt-group { display: flex; flex-direction: column; gap: 6px; }
.opt-group#formatGroup { flex-basis: 100%; }
.opt-group#formatGroup > .seg { align-self: flex-start; }
.opt-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button small { font-weight: 500; font-size: 11px; opacity: 0.8; margin-left: 2px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg-sm button { padding: 4px 10px; font-size: 13px; }
.quality { display: flex; align-items: center; gap: 10px; }
.quality input { width: 180px; accent-color: var(--accent); }
.quality output { font: 600 14px var(--mono); min-width: 2.5ch; }
.size-inputs { display: flex; align-items: center; gap: 8px; }
.size-inputs select, .size-inputs input { height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 0 10px; }
.size-inputs input { width: 100px; }
.size-inputs .x { color: var(--faint); }
.opt-checks { flex-direction: row; gap: 18px; align-self: flex-end; height: 40px; align-items: center; }
.check { display: flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; color: var(--muted); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.bg-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 4px; cursor: pointer; }
.bg-pick input { width: 30px; height: 26px; border: 1px solid var(--line); border-radius: 6px; padding: 0; background: none; }

/* ---------- bırakma alanı */
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); text-align: center; padding: 48px 20px; transition: border-color 0.15s, background 0.15s; }
.drop:focus-visible, .drop.hover { border-color: var(--accent); background: var(--accent-soft); }
.drop.compact { padding: 16px 20px; }
.drop.compact .drop-icon, .drop.compact .drop-formats { display: none; }
.drop.compact .drop-title { font-size: 15px; margin: 0 0 2px; }
.drop-icon { width: 46px; height: 46px; color: var(--accent); }
.drop-title { font-size: 19px; font-weight: 650; margin: 8px 0 4px; }
.drop-sub { margin: 0; color: var(--muted); }
.drop-formats { margin: 14px 0 0; font-size: 12px; color: var(--faint); letter-spacing: 0.04em; }
.drag-overlay { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); backdrop-filter: blur(2px); pointer-events: none; }
.drag-overlay div { background: var(--surface); padding: 18px 28px; border-radius: 14px; font-weight: 700; font-size: 18px; box-shadow: var(--shadow); border: 2px solid var(--accent); }
body.dragging .drag-overlay { display: grid; }

/* ---------- liste */
.results { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-head, .row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 118px 84px 84px 150px 112px; align-items: center; gap: 12px; padding: 0 16px; }
.list-head { height: 38px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.row { min-height: 60px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.thumb { width: 44px; height: 44px; border-radius: 8px; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; font: 600 10px var(--mono); color: var(--faint); text-transform: uppercase; overflow: hidden; border: 1px solid var(--line); }
.thumb.checker { background-image: conic-gradient(var(--surface-2) 25%, var(--surface) 0 50%, var(--surface-2) 0 75%, var(--surface) 0); background-size: 10px 10px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.name { min-width: 0; }
.name .fn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.name .sub { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.name .sub.err { color: var(--bad); white-space: normal; }
.fmt { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.fmt .arrow { color: var(--faint); margin: 0 3px; }
.size { font-size: 14px; }
.size.after { font-weight: 650; }
.gain { display: flex; align-items: center; gap: 10px; }
.gain .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.gain .bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; width: 0; transition: width 0.4s ease; }
.gain .pct { font: 650 14px var(--mono); min-width: 52px; text-align: right; color: var(--good); }
.gain.neg .pct { color: var(--bad); }
.gain.neg .bar i { background: var(--bad); }
.gain.zero .pct { color: var(--faint); }
.actions { display: flex; justify-content: flex-end; gap: 2px; }
.actions .icon-btn { width: 32px; height: 32px; font-size: 15px; display: grid; place-items: center; }
.actions .icon-btn svg { width: 17px; height: 17px; }
.actions .icon-btn:disabled { opacity: 0.3; cursor: default; background: none; }
.state { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.row.error { background: var(--bad-soft); }
.badge { display: inline-block; font: 600 11px var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- özet çubuğu */
.summary { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.summary-inner { display: flex; align-items: center; gap: 16px; min-height: 68px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.summary-text { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.summary-text span { color: var(--muted); }
.summary-text .sum-saved { color: var(--good); font-weight: 700; }
.summary-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- pencereler */
.modal { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.modal::backdrop { background: rgb(8 12 10 / 0.55); backdrop-filter: blur(2px); }
.modal.small { width: min(420px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-body input[type=password] { width: 100%; height: 40px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 0 12px; background: var(--bg); }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; }
.form-error { color: var(--bad); font-size: 14px; margin: 8px 0 0; }

.compare { width: min(1280px, calc(100vw - 24px)); height: calc(100vh - 48px); display: none; flex-direction: column; }
.compare[open] { display: flex; }
.cmp-tools { display: flex; align-items: center; gap: 8px; }
.cmp-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.cmp-stage { position: relative; flex: 1; min-height: 0; min-width: 0; overflow: hidden; background: conic-gradient(var(--surface-2) 25%, var(--surface) 0 50%, var(--surface-2) 0 75%, var(--surface) 0) 0 0 / 16px 16px; }
.cmp-stage.zoomed { overflow: auto; cursor: grab; }
.cmp-stage.zoomed.panning { cursor: grabbing; }
.cmp-canvas { position: relative; margin: auto; user-select: none; }
.cmp-stage:not(.zoomed) .cmp-canvas { position: absolute; inset: 0; margin: auto; }
.cmp-canvas img { display: block; width: 100%; height: 100%; image-rendering: auto; }
.cmp-stage.pixel .cmp-canvas img { image-rendering: pixelated; }
.cmp-before { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 50% 0 0); }
.cmp-before img { width: 100%; height: 100%; }
.cmp-handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35); cursor: ew-resize; }
.cmp-handle span { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgb(0 0 0 / 0.35); }
.cmp-handle span::before { content: "‹ ›"; position: absolute; inset: 0; display: grid; place-items: center; color: #222; font-weight: 700; font-size: 15px; letter-spacing: 2px; }
.cmp-handle::after { content: ""; position: absolute; inset: 0 -14px; }
.cmp-tag { position: absolute; top: 12px; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 6px; background: rgb(0 0 0 / 0.62); color: #fff; pointer-events: none; font-variant-numeric: tabular-nums; }
.cmp-tag.left { left: 12px; }
.cmp-tag.right { right: 12px; }
.cmp-hint { margin: 0; padding: 8px 20px; font-size: 12.5px; color: var(--faint); border-top: 1px solid var(--line); }

.api-doc h3 { font-size: 14px; margin: 18px 0 6px; }
.api-doc h3:first-child { margin-top: 0; }
.api-doc p, .api-doc li { color: var(--muted); font-size: 14px; }
.api-doc pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow: auto; font: 12.5px/1.55 var(--mono); margin: 6px 0 0; position: relative; }
.api-doc code { font: 12.5px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.api-doc pre code { background: none; padding: 0; }
.api-doc table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.api-doc td, .api-doc th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.api-doc th { color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.copy-btn { position: absolute; top: 6px; right: 6px; }

/* ---------- bildirimler */
.toasts { position: fixed; right: 16px; bottom: 84px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: rise 0.2s ease; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- dar ekran */
@media (max-width: 860px) {
  .list-head { display: none; }
  .row { grid-template-columns: 48px minmax(0, 1fr) auto; grid-template-areas: "t n a" "t f g"; padding: 10px 14px; row-gap: 4px; }
  .row > .thumb { grid-area: t; align-self: start; }
  .row > .name { grid-area: n; }
  .row > .actions { grid-area: a; }
  .row > .fmt { grid-area: f; }
  .row > .size { display: none; }
  .row > .gain, .row > .state { grid-area: g; }
  .gain .bar { display: none; }
  .gain .pct { min-width: 0; }
  .topbar-inner { gap: 12px; }
  .brand-name { display: none; }
  .summary-actions { margin-left: 0; width: 100%; }
  .summary-actions .btn { flex: 1; }
  body { padding-bottom: 150px; }
  .toasts { bottom: 150px; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  .quality input { width: 130px; }
  .tab { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition: none !important; }
}
