/* Image64 — brutalist developer-workbench redesign
   mono type, hairlines, sharp corners, lime-on-ink (dark) / ink-on-paper (light) */
:root {
  --bg: #0b0b0b;
  --panel: #121212;
  --panel-2: #1a1a1a;
  --line: #2b2b2b;
  --line-strong: #3a3a3a;
  --text: #eaeaea;
  --muted: #8b8b8b;
  --accent: #c9f723;          /* electric lime */
  --accent-text: #0b0b0b;
  --hi: #c9f723;              /* focus / highlight */
  --ok: #7ee787;
  --danger: #ff5d5d;
  --shadow: 6px 6px 0 rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] {
  --bg: #eeebe1;
  --panel: #f9f7f0;
  --panel-2: #efede3;
  --line: #d5d1c2;
  --line-strong: #b9b4a2;
  --text: #191919;
  --muted: #6e6a5e;
  --accent: #191919;          /* ink */
  --accent-text: #f9f7f0;
  --hi: #b5e000;
  --ok: #2e7d32;
  --danger: #c62828;
  --shadow: 6px 6px 0 rgba(25, 25, 25, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
::selection { background: var(--hi); color: #0b0b0b; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
kbd {
  font-family: var(--mono); font-size: 0.72em;
  border: 1px solid var(--line-strong); border-radius: 0;
  padding: 1px 5px; background: var(--panel-2);
}

/* ------------------------------------------------------------------ nav */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: stretch; gap: 0;
  height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  padding: 0 18px; border-right: 1px solid var(--line);
}
.brand-mark {
  width: 26px; height: 26px; background: var(--accent); color: var(--accent-text);
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
}
.brand-name {
  font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tabs { display: flex; }
.tab {
  padding: 0 18px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  border-right: 1px solid var(--line);
  position: relative;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); background: var(--panel); }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--hi);
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 0 16px; }

.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid var(--line);
  font-size: 17px; line-height: 1; background: var(--panel);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
:root[data-theme="light"] .ic-moon { display: block; }
:root[data-theme="light"] .ic-sun { display: none; }
.ic-moon { display: none; }
.ic-sun { display: block; }

.user-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.user-chip b {
  font-family: var(--mono); color: var(--text); font-weight: 600; font-size: 11.5px;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------------------------ layout */
.page { width: 100%; max-width: 1200px; margin: 0 auto; padding: 26px 20px 48px; flex: 1; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .brand { padding: 0 12px; }
  .brand-name { display: none; }
  .tab { padding: 0 12px; }
}
@media (max-width: 480px) {
  .brand { padding: 0 9px; }
  .tab { padding: 0 8px; letter-spacing: 0.06em; font-size: 10.5px; }
  .nav-right { padding: 0 8px; gap: 6px; }
  .btn-sm { padding: 5px 8px; letter-spacing: 0.04em; }
  .user-chip b { max-width: 90px; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0 18px 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px; margin: 0 -18px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.card-head h2 {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 .num { color: var(--hi); }
:root[data-theme="light"] .card-head h2 .num {
  color: var(--text); background: var(--hi); padding: 0 4px;
}
.hint { font-size: 11.5px; color: var(--muted); font-family: var(--mono); letter-spacing: 0.02em; }

/* ------------------------------------------------------------------ buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
  white-space: nowrap;
}
.button:active { transform: translate(1px, 1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { color: var(--text); }
.btn-secondary:hover { border-color: var(--text); }
.btn-success { background: transparent; color: var(--ok); border-color: var(--ok); }
.btn-success:hover { background: var(--ok); color: var(--bg); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn-sm { padding: 5px 11px; font-size: 10.5px; }
.btn-block { width: 100%; }
.button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ------------------------------------------------------------------ dropzone */
.dropzone {
  position: relative;
  border: 1px dashed var(--line-strong);
  padding: 36px 18px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
  margin-bottom: 14px;
}
.dropzone::before, .dropzone::after {
  content: ""; position: absolute; width: 14px; height: 14px; transition: inherit;
}
.dropzone::before { top: -1px; left: -1px; border-top: 2px solid var(--hi); border-left: 2px solid var(--hi); }
.dropzone::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--hi); border-right: 2px solid var(--hi); }
.dropzone:hover, .dropzone.active, .dropzone:focus-visible {
  border-color: var(--hi); color: var(--text); outline: none;
}
.dz-title {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 10px; color: var(--text);
}
.dz-sub { font-size: 12px; margin-top: 4px; }

.src-row { display: flex; gap: 8px; flex-wrap: wrap; }
.camera-panel { margin-top: 14px; }
.camera-panel video { width: 100%; margin-bottom: 10px; background: #000; border: 1px solid var(--line); }

/* ------------------------------------------------------------------ options */
.opts { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.opts.disabled { opacity: 0.45; pointer-events: none; }
.opts-head {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.opt-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.opt-label {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  min-width: 64px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
}
.opt-label span { color: var(--text); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); }
.seg button {
  padding: 6px 15px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--muted); border-right: 1px solid var(--line-strong);
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: var(--accent-text); }

#quality { flex: 1; min-width: 140px; accent-color: var(--hi); }
#quality-row.hidden { display: none; }

.resize-grid { display: flex; align-items: center; gap: 8px; }
.resize-grid input[type="number"] {
  width: 90px; padding: 7px 9px;
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text);
  font-family: var(--mono); font-size: 12.5px; border-radius: 0;
}
.resize-grid input[type="number"]:focus { outline: none; border-color: var(--hi); }
.resize-grid .x { color: var(--muted); font-family: var(--mono); }
.lock {
  display: grid; place-items: center; width: 31px; height: 31px;
  border: 1px solid var(--line-strong); color: var(--muted); cursor: pointer;
}
.lock input { display: none; }
.lock:has(input:checked) { color: var(--accent-text); border-color: var(--accent); background: var(--accent); }
:root[data-theme="light"] .lock:has(input:checked) { background: var(--hi); color: var(--text); border-color: var(--text); }

.preset-row { display: flex; gap: 0; border: 1px solid var(--line); width: max-content; }
.chip {
  padding: 5px 14px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--muted); border-right: 1px solid var(--line);
}
.chip:last-child { border-right: none; }
.chip:hover { color: var(--accent-text); background: var(--accent); }
:root[data-theme="light"] .chip:hover { background: var(--hi); color: var(--text); }

/* ------------------------------------------------------------------ inputs */
.mono-area {
  width: 100%; min-height: 130px; resize: vertical;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 0;
  color: var(--text); font-family: var(--mono); font-size: 11.5px;
  padding: 10px; line-height: 1.55; word-break: break-all; margin-bottom: 12px;
}
.mono-area:focus { outline: none; border-color: var(--hi); }
.out-area { min-height: 96px; max-height: 180px; margin: 14px 0 0; }

/* ------------------------------------------------------------------ output */
.out-empty { text-align: center; color: var(--muted); padding: 48px 16px 40px; font-size: 13px; }
.out-empty svg { opacity: 0.45; margin-bottom: 10px; }
.out-empty .button { margin-top: 16px; }

.preview-wrap {
  display: grid; place-items: center; padding: 16px;
  background:
    conic-gradient(color-mix(in srgb, var(--muted) 15%, transparent) 90deg, transparent 90deg 180deg,
      color-mix(in srgb, var(--muted) 15%, transparent) 180deg 270deg, transparent 270deg) 0 0/16px 16px,
    var(--panel-2);
  border: 1px solid var(--line);
}
.preview-wrap img { max-width: 100%; max-height: 320px; }

.stats {
  display: flex; flex-wrap: wrap;
  border: 1px solid var(--line); border-bottom: none;
  margin: 14px 0 0; font-family: var(--mono);
}
.stat {
  font-size: 11px; color: var(--muted); letter-spacing: 0.03em;
  padding: 6px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  flex: 1 0 auto; text-align: center;
}
.stat b { color: var(--text); font-weight: 700; }
.stat.good b { color: var(--ok); }
.stat.bad b { color: var(--danger); }

.copy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ------------------------------------------------------------------ library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 12px; }
.lib-item {
  border: 1px solid var(--line); overflow: hidden;
  background: var(--panel-2); cursor: pointer;
  transition: border-color 0.12s, transform 0.1s, box-shadow 0.1s;
  text-align: left;
}
.lib-item:hover {
  border-color: var(--line-strong);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--hi) 55%, transparent);
}
.lib-thumb {
  height: 110px; display: grid; place-items: center; overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    conic-gradient(color-mix(in srgb, var(--muted) 13%, transparent) 90deg, transparent 90deg 180deg,
      color-mix(in srgb, var(--muted) 13%, transparent) 180deg 270deg, transparent 270deg) 0 0/14px 14px;
}
.lib-thumb img { max-width: 100%; max-height: 110px; object-fit: contain; }
.lib-meta { padding: 8px 10px 6px; }
.lib-name {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-sub {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 6px;
}
.lib-actions { display: flex; gap: 0; border-top: 1px solid var(--line); margin-top: 6px; }
.lib-actions button {
  flex: 1; font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 6px 4px; border-right: 1px solid var(--line);
}
.lib-actions button:last-child { border-right: none; }
.lib-actions button:hover { background: var(--accent); color: var(--accent-text); }
:root[data-theme="light"] .lib-actions button:hover { background: var(--hi); color: var(--text); }
.lib-actions button.danger:hover { color: #fff; background: var(--danger); }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 75%, transparent); backdrop-filter: blur(2px);
}
.modal {
  width: min(400px, calc(100vw - 32px)); background: var(--panel);
  border: 1px solid var(--line-strong); padding: 20px; box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.field { display: block; margin-bottom: 12px; }
.field span {
  display: block; font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  margin-bottom: 5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
}
.field input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 0;
  background: var(--panel-2); color: var(--text); font-size: 14px;
}
.field input:focus { outline: none; border-color: var(--hi); }
.auth-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }
.auth-switch { margin-top: 14px; font-size: 12.5px; color: var(--muted); text-align: center; }
.auth-switch a { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-color: var(--hi); text-underline-offset: 3px; }

/* ------------------------------------------------------------------ toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--hi);
  padding: 10px 14px; box-shadow: var(--shadow);
  font-family: var(--mono); font-size: 12px; max-width: 360px;
  animation: toast-in 0.18s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ footer */
.foot {
  border-top: 1px solid var(--line);
  padding: 10px 20px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
}

.hidden { display: none !important; }
