/* ============================================================
   FotoDown — surface: OPERATE (alat kerja, bukan landing page)
   Palet: charcoal + satu aksen acid-lime. Tanpa gradient,
   tanpa blur, tanpa bayangan. Pemisah = garis 1px.
   ============================================================ */
:root {
  --bg: #121215;
  --bg-raise: #17171B;
  --panel: #1A1A1F;
  --line: #2A2A31;
  --line-soft: #222228;
  --ink: #EDEBE5;
  --ink-2: #A6A39C;
  --ink-3: #8B8880;   /* 4.9:1 di atas panel — AA untuk teks 10-11px */
  --accent: #C9F24E;
  --accent-dim: rgba(201, 242, 78, .14);
  --danger: #FF6B4A;
  --sans: ui-sans-serif, "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --rail: 304px;
}

* { box-sizing: border-box; }

/* kelas .btn/.thead punya display sendiri, jadi [hidden] perlu dipaksa */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.num { text-align: right; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------- masthead ---------------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raise);
  position: sticky; top: 0; z-index: 20;
}
.wordmark { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.wordmark b {
  font-family: var(--display); font-size: 15px; font-weight: 650;
  letter-spacing: -.015em; color: var(--ink);
}
.mark {
  width: 11px; height: 11px; align-self: center;
  background: var(--accent); border-radius: 2px;
  position: relative; flex: none;
}
.mark::after {
  content: ""; position: absolute; inset: 3px 3px auto auto;
  width: 4px; height: 4px; background: var(--bg); border-radius: 1px;
}
.tag { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.head-right { display: flex; align-items: center; gap: 10px; }

/* ---------------- shell ---------------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 56px - 45px);
}

/* ---------------- rail (controls) ---------------- */
.rail {
  border-right: 1px solid var(--line);
  padding: 18px 16px 24px;
  position: sticky; top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.group { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.group:last-of-type { border-bottom: 0; }

.lbl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.lbl {
  margin: 0 0 9px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-3);
}
.lbl-row .lbl { margin: 0; }
.lbl-note { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.val { font-size: 12px; color: var(--ink); }

/* option buttons — state lewat garis + warna teks, bukan gradient */
.opts { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.opts.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }

.opt {
  appearance: none; border: 0; cursor: pointer; text-align: left;
  background: var(--panel); color: var(--ink-2);
  font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums;
  padding: 8px 10px; min-height: 34px;
  transition: color .12s ease, background .12s ease, box-shadow .12s ease;
  display: flex; align-items: center; gap: 8px;
}
.opt:hover { color: var(--ink); background: #1E1E24; }
.opt.is-on {
  color: var(--accent);
  background: var(--accent-dim);
  outline: 1px solid rgba(201, 242, 78, .38);
  outline-offset: -1px;
}
.opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.opt-row { justify-content: space-between; font-family: var(--sans); font-size: 12.5px; }
.opt-row .fmt { font-family: var(--mono); font-weight: 600; letter-spacing: .02em; }
.opt-row .meta { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.opt-row.is-on .meta { color: rgba(201, 242, 78, .62); }

/* slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 2px 0 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--line); border-radius: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 2px;
  background: var(--accent); border: 0; margin-top: -4.5px;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 2px; background: var(--accent); border: 0;
}
input[type="range"]:disabled { opacity: .35; cursor: not-allowed; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-3); margin-top: 2px; }

input[type="number"] {
  width: 100%; padding: 8px 10px; min-height: 34px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 0;
  font-family: var(--mono); font-size: 12.5px;
}
input[type="number"]::placeholder { color: var(--ink-3); }
input[type="number"]:focus-visible { outline: 0; border-color: var(--accent); }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.hint {
  margin: 7px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-3);
  text-wrap: pretty;
}

/* totals */
.totals { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.tv { background: var(--panel); padding: 8px 9px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tv span { font-size: 12px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv small { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.tv-accent span { color: var(--accent); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 12px;
  font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .01em;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  border-radius: 0;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { color: var(--ink); border-color: #3A3A44; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-fill { background: var(--accent); color: #14160A; border-color: var(--accent); }
.btn-fill:hover { background: #D6FA6A; border-color: #D6FA6A; color: #14160A; }
.btn-fill:disabled { background: transparent; color: var(--ink-3); border-color: var(--line); cursor: not-allowed; }

.btn-line { border-color: #34343D; }
.btn-quiet { border-color: transparent; color: var(--ink-3); }
.btn-quiet:hover { color: var(--ink); background: #1C1C22; border-color: var(--line); }

/* ---------------- work column ---------------- */
.work { padding: 16px 16px 28px; min-width: 0; }

.drop {
  display: flex; align-items: center; gap: 11px;
  min-height: 54px; padding: 0 14px;
  border: 1px dashed #3A3A44;
  background: #16161A;
  cursor: pointer; user-select: none;
  transition: border-color .14s ease, background .14s ease;
}
.drop:hover { border-color: #55555F; }
.drop:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.drop.is-drag { border-color: var(--accent); background: var(--accent-dim); }
.plus {
  font-family: var(--mono); font-size: 15px; line-height: 1; color: var(--accent);
  border: 1px solid rgba(201, 242, 78, .4); width: 22px; height: 22px;
  display: grid; place-items: center; flex: none;
}
.drop-text { font-size: 12.5px; color: var(--ink-2); }
.drop-text b { color: var(--ink); font-weight: 600; }
.u { color: var(--ink); text-decoration: underline; text-decoration-color: rgba(237, 235, 229, .4); text-underline-offset: 3px; }
kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-2);
  border: 1px solid var(--line); padding: 1px 4px; margin-left: 2px; background: #1E1E24;
}

/* table header + rows */
.thead, .row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 78px 78px 104px 88px;
  gap: 12px; align-items: center;
}
.thead {
  padding: 10px 12px 9px; border-bottom: 1px solid var(--line);
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
  font-weight: 600;
}
.thead .num { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }

.rows { border-bottom: 1px solid var(--line); }
.row-item {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .12s ease;
  animation: rowIn .18s ease both;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: #17171C; }
@keyframes rowIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.cell-file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.thumb {
  width: 38px; height: 38px; object-fit: cover; flex: none;
  background: #0E0E11; border: 1px solid var(--line);
}
.fmeta { min-width: 0; }
.fname {
  margin: 0; font-size: 12.5px; color: var(--ink); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fstatus { margin: 1px 0 0; font-size: 10.5px; color: var(--ink-3); }
.row-item.is-done .fstatus { color: rgba(201, 242, 78, .8); }
.row-item.is-error .fstatus { color: var(--danger); }
.fmetric { display: none; margin: 1px 0 0; font-size: 10.5px; color: var(--ink-2); }

.out { color: var(--ink); }

.saved { display: flex; align-items: center; gap: 8px; }
.pct { font-size: 11.5px; color: var(--ink-3); min-width: 34px; }
.row-item.is-done .pct { color: var(--accent); }
.meter { flex: 1; height: 2px; background: var(--line); overflow: hidden; min-width: 22px; }
.meter i {
  display: block; height: 100%; width: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .3s ease;
}

.cell-act { display: flex; justify-content: flex-end; gap: 6px; }
.btn-save {
  border-color: rgba(201, 242, 78, .45); color: var(--accent);
  min-width: 72px; padding: 0 10px;
}
.btn-save:hover { background: var(--accent); color: #14160A; border-color: var(--accent); }
.retry { padding: 0 8px; font-size: 11.5px; }

/* empty state */
.empty { padding: 26px 12px 8px; }
.empty-title { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.empty .hint { max-width: 52ch; }
.empty .mono { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }

/* ---------------- footer ---------------- */
.foot {
  display: flex; justify-content: space-between; gap: 12px;
  max-width: 1240px; margin: 0 auto; padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em;
}
#swState.is-on { color: rgba(201, 242, 78, .75); }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  :root { --rail: 260px; }
  .thead, .row-item { grid-template-columns: minmax(0, 1fr) 70px 70px 92px 76px; }
  .thead .num:nth-child(2), .dims { display: none; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; border-left: 0; border-right: 0; }
  .rail {
    position: static; max-height: none; overflow: visible;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 14px 18px;
  }
  .work { padding: 14px 14px 24px; }
  .masthead { padding: 0 14px; }
  .tag { display: none; }

  .thead { display: none; }
  .row-item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "file act"
      "saved saved";
    gap: 6px 10px;
    padding: 10px 12px;
  }
  .cell-file { grid-area: file; }
  .cell-act { grid-area: act; align-self: start; }
  .saved { grid-area: saved; }
  .num.dims, .num.orig, .num.out { display: none; }
  .fmetric { display: block; }
  .thumb { width: 34px; height: 34px; }
  .pct { order: 2; min-width: 0; }
  .meter { order: 1; }
  .opts.grid2 { grid-template-columns: repeat(5, 1fr); }
  .opt { justify-content: center; padding: 8px 2px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* sharp hit targets on touch */
@media (hover: none) {
  .btn, .opt { min-height: 40px; }
}
