/* ==========================================================================
   QR Code Generator — style.css
   Vanilla CSS, no framework, no build step. Light/dark editor.
   ========================================================================== */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #2563eb;
  --danger: #dc2626;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 8px 24px rgba(17, 24, 39, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1c1f24;
  --surface-2: #23262c;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #2f333a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

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

/* ---------- App bar ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-bar__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.app-bar__logo {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff; font-size: 13px;
}
.app-bar__actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn--sm { padding: 6px 10px; font-size: 13px; }
.btn--icon { padding: 8px 10px; line-height: 1; }
.btn--ghost-danger { border-color: transparent; color: var(--danger); background: transparent; }
.btn--ghost-danger:hover { background: rgba(220, 38, 38, .1); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(380px, 500px) 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
}
.editor {
  display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: 72px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding-right: 4px;
}

/* ---------- Editor group heading ---------- */
.editor__group {
  flex: none;
  margin: 8px 0 -4px 2px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); opacity: .75;
}
.editor__group:first-child { margin-top: 0; }

/* ---------- Panels ---------- */
.panel {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel > summary {
  list-style: none; cursor: pointer;
  padding: 12px 14px;
  font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); user-select: none;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "+"; float: right; font-size: 15px; }
.panel[open] > summary::after { content: "\2212"; }
.panel__body { padding: 4px 14px 16px; }

/* ---------- Fields ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--full { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field--check { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; }
.field--check > span { color: var(--text); font-weight: 500; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 1px; border-color: var(--accent);
}
input[type="color"] { padding: 4px; height: 38px; }
input[type="file"] { padding: 6px; background: transparent; border-style: dashed; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }

.hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
/* A hint that closes a field must not crowd the next one */
.field > .hint:last-child { margin-bottom: 16px; }
.hint--warn { color: var(--danger); font-weight: 600; }

.form-block { margin-top: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #14181f; color: #fff;
  padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Range inputs ---------- */
.field input[type="range"] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.field input[type="color"] { width: 100%; height: 38px; padding: 2px; cursor: pointer; }

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Segmented control — one row, one active choice */
.seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg-row button {
  appearance: none;
  flex: 1 1 auto;
  min-width: 54px;
  padding: 7px 8px;
  font-size: 13px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-row button:hover { color: var(--text); }
.seg-row button.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(17, 24, 39, .12);
}
[data-theme="dark"] .seg-row button.is-active { background: #2a2f3a; }

.linklike {
  appearance: none; background: none; border: 0; padding: 0;
  font: inherit; font-weight: 600; color: var(--accent);
  cursor: pointer; text-decoration: underline;
}

/* ---------- Results column ---------- */
.results { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 44px 24px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--surface-2); }
.dropzone--slim { padding: 12px 16px; }
.dropzone--slim .dropzone__icon { display: inline-block; margin: 0 6px 0 0; font-size: 15px; vertical-align: -2px; }
.dropzone--slim .dropzone__sub { display: inline; }
.dropzone__icon { display: block; font-size: 26px; color: var(--muted); margin-bottom: 8px; }
.dropzone__title { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.dropzone__sub { margin: 0; color: var(--muted); font-size: 13px; }
.dropzone__privacy {
  margin: 14px 0 0; font-size: 12px; color: var(--muted);
  padding-top: 12px; border-top: 1px solid var(--border);
}

/* ---------- Summary bar ---------- */
.summary {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.summary__main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.summary__main b { font-size: 15px; }
.summary__main span { color: var(--muted); font-variant-numeric: tabular-nums; }
.summary__saved { font-weight: 700; color: #16a34a; font-variant-numeric: tabular-nums; }
[data-theme="dark"] .summary__saved { color: #4ade80; }

/* ---------- File list ---------- */
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.file-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.file-thumb {
  width: 64px; height: 64px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
  background:
    linear-gradient(45deg, #e8eaee 25%, transparent 25%, transparent 75%, #e8eaee 75%),
    linear-gradient(45deg, #e8eaee 25%, transparent 25%, transparent 75%, #e8eaee 75%) 6px 6px,
    #fff;
  background-size: 12px 12px;
}

.file-info { min-width: 0; }
.file-name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-meta {
  margin-top: 3px;
  font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; gap: 4px 8px;
}
.file-meta .arrow { opacity: .55; }
.file-meta .new-size { color: var(--text); font-weight: 600; }

.file-actions { display: flex; align-items: center; gap: 6px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge--good { background: rgba(22, 163, 74, .12); color: #15803d; }
.badge--flat { background: rgba(107, 114, 128, .14); color: var(--muted); }
.badge--worse { background: rgba(234, 88, 12, .13); color: #c2410c; }
.badge--busy { background: rgba(37, 99, 235, .12); color: var(--accent); }
.badge--error { background: rgba(220, 38, 38, .12); color: var(--danger); }
[data-theme="dark"] .badge--good { background: rgba(34, 197, 94, .16); color: #4ade80; }
[data-theme="dark"] .badge--worse { background: rgba(251, 146, 60, .16); color: #fdba74; }
[data-theme="dark"] .badge--error { background: rgba(248, 113, 113, .16); color: #fca5a5; }

.file-row--error { border-color: rgba(220, 38, 38, .4); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .editor { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 560px) {
  .file-row { grid-template-columns: 48px minmax(0, 1fr); }
  .file-thumb { width: 48px; height: 48px; }
  .file-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .app-bar { flex-wrap: wrap; }
}

.btn.is-active { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }

.fmt-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
  margin-right: 2px;
}

.row-explain { color: var(--muted); font-style: italic; }

/* ---------- Help modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  background: rgba(15, 18, 22, .55);
  overflow-y: auto;
}
.modal__card {
  width: 100%; max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 { margin: 0; font-size: 16px; }
.modal__body { padding: 4px 20px 22px; }
.modal__lead { color: var(--muted); }
.modal__body h3 {
  margin: 18px 0 6px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.modal__body p { margin: 6px 0; }
.modal__body ul { margin: 6px 0; padding-left: 18px; }
.modal__body li { margin: 4px 0; }
.modal__body b { color: var(--text); }

/* ---------- Armed (two-click) button ---------- */
.btn--armed { border-color: var(--danger); color: var(--danger); }

/* ---------- Before/after compare ---------- */
.modal__card--wide { max-width: 900px; }
.compare {
  position: relative;
  width: 100%;
  max-height: 62vh;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, #e8eaee 25%, transparent 25%, transparent 75%, #e8eaee 75%),
    linear-gradient(45deg, #e8eaee 25%, transparent 25%, transparent 75%, #e8eaee 75%) 8px 8px,
    #fff;
  background-size: 16px 16px;
}
.compare__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  user-select: none; -webkit-user-drag: none;
}
.compare__img--before { clip-path: inset(0 50% 0 0); }
.compare__divider {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; background: var(--accent);
  transform: translateX(-1px);
  pointer-events: none;
}
.compare__divider span {
  position: absolute; top: 50%; left: 50%;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.compare__tag {
  position: absolute; bottom: 10px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(20, 24, 31, .82); color: #fff;
  font-size: 12px; font-weight: 600;
}
.compare__tag--l { left: 10px; }
.compare__tag--r { right: 10px; }
.compare__tag b { font-weight: 700; margin-left: 4px; }
#cmpRange { width: 100%; margin: 12px 0 0; accent-color: var(--accent); }
.file-thumb { cursor: zoom-in; }

/* iOS-style on/off switch — restyles the native checkbox, no markup change */
.field--check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 40px; height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  position: relative; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.field--check input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s;
}
.field--check input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.field--check input[type="checkbox"]:checked::before { transform: translateX(16px); }
.field--check input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-theme="dark"] .field--check input[type="checkbox"]::before { background: #e8eaed; }

