*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f2ed; --surface: #edeae3; --surface2: #e4e0d8;
  --border: #d4cfc5; --border2: #c4bfb4;
  --ink: #1a1814; --ink2: #4a4640; --ink3: #8a8480;
  --accent: #c84b2f; --gold: #b8962e;
  --mono: 'DM Mono', monospace; --sans: 'Outfit', sans-serif;
}
body { background: var(--bg); color: var(--ink); font-family: var(--sans); min-height: 100vh; }
.app { max-width: 680px; margin: 0 auto; padding: 40px 20px 60px; }
.header { margin-bottom: 20px; }
.wordmark { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.wordmark-main { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.2em; color: var(--accent); text-transform: uppercase; }
.wordmark-sep { width: 20px; height: 1px; background: var(--border2); align-self: center; }
.wordmark-sub { font-family: var(--mono); font-size: 10px; color: var(--ink3); letter-spacing: 0.1em; }
.headline { font-size: clamp(24px, 4vw, 36px); font-weight: 300; line-height: 1.2; letter-spacing: -0.02em; }
.headline strong { font-weight: 600; color: var(--accent); }

.drop-zone { border: 1.5px solid var(--border2); border-radius: 2px; background: var(--surface); padding: 44px 32px; text-align: center; cursor: pointer; position: relative; transition: border-color 0.2s, background 0.2s; }
.drop-zone::after { content: ''; position: absolute; inset: 4px; border: 1px dashed var(--border); border-radius: 1px; pointer-events: none; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: #f0ece4; }
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop-icon { width: 36px; height: 36px; margin: 0 auto 12px; opacity: 0.3; }
.drop-label { font-size: 15px; color: var(--ink2); margin-bottom: 5px; }
.drop-label strong { font-weight: 600; color: var(--ink); }
.drop-hint { font-family: var(--mono); font-size: 11px; color: var(--ink3); }

.upload-progress { margin-top: 20px; display: none; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 6px; }
.progress-label-text { font-family: var(--mono); font-size: 11px; color: var(--ink3); }
.progress-label-pct { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.progress-track { height: 2px; background: var(--border); border-radius: 1px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 1px; transition: width 0.1s linear; width: 0%; }

.processing-bar { margin-top: 16px; display: none; }
.processing-label { font-family: var(--mono); font-size: 11px; color: var(--ink3); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
.resolution-track { display: flex; gap: 4px; }
.res-pip { flex: 1; height: 2px; background: var(--border); border-radius: 1px; transition: background 0.4s; }
.res-pip.ready { background: var(--accent); }

.results { margin-top: 24px; display: none; animation: fadeUp 0.4s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.results-meta { font-family: var(--mono); font-size: 10px; color: var(--ink3); margin-bottom: 12px; }

/* ── Image strip (v1 style) ── */
.preview-strip {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}
.preview-thumb {
  flex: 1;
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  background: var(--surface2);
  border-right: 1px solid var(--border);
}
.preview-thumb:last-child { border-right: none; }
.preview-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity 0.4s;
}
.preview-thumb img.loaded { opacity: 1; }
.res-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.preview-thumb.ready .res-skeleton { display: none; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.res-label {
  position: absolute; bottom: 4px; left: 4px;
  font-family: var(--mono); font-size: 9px;
  background: rgba(0,0,0,0.65); color: #e8ff80;
  padding: 2px 5px; border-radius: 1px;
}

/* ── Link rows — badge | CDN url [copy] | SHORT url [copy] ── */
.link-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 2px; background: var(--surface); margin-bottom: 4px; }
.link-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 1px;
  flex-shrink: 0; width: 56px; text-align: center; white-space: nowrap;
}
.badge-thumb { background: #f0ece0; color: #7a6820; border: 1px solid #d4c870; }
.badge-sm    { background: #e8f4e8; color: #2a6a2a; border: 1px solid #8ccc8c; }
.badge-md    { background: #e8eef8; color: #2a3a7a; border: 1px solid #8cacd4; }
.badge-lg    { background: #f4e8e8; color: #7a2a2a; border: 1px solid #d48c8c; }


.link-urls-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.url-line { display: flex; align-items: center; gap: 6px; padding: 5px 10px; }
.url-line + .url-line { border-top: 1px solid var(--border); }
.url-val { font-family: var(--mono); font-size: 11px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }


.short-badge {
  font-family: var(--mono); font-size: 9px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 1px; font-size: 8px; flex-shrink: 0;
  background: var(--gold); color: #fff;
}

/* ── Download / View / Copy — unified height, fixed widths ── */
.download-btn, .view-btn, .copy-btn {
  background: none; border: 1px solid var(--border2); color: var(--ink2);
  border-radius: 1px; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
  height: 22px; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); padding: 0;
}
.download-btn:hover, .view-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: #2a6a2a; color: #2a6a2a; }
.copy-btn:disabled { opacity: 0.3; cursor: default; }
.download-btn.disabled, .view-btn.disabled { opacity: 0.3; pointer-events: none; }
.download-btn { width: 26px; font-size: 13px; text-decoration: none; }
.view-btn     { width: 26px; }
.view-btn svg { width: 13px; height: 13px; display: block; }
.copy-btn     { width: 52px; font-size: 10px; letter-spacing: 0.04em; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; cursor: pointer;
}
.modal-overlay.open { display: flex; }
.modal-img {
  max-width: 90vw; max-height: 90vh;
  object-fit: contain; border-radius: 2px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.modal-close {
  position: absolute; top: 16px; right: 20px;
  font-family: var(--mono); font-size: 20px; color: #fff;
  cursor: pointer; opacity: 0.7; line-height: 1;
}
.modal-close:hover { opacity: 1; }

.error-msg { margin-top: 14px; padding: 10px 14px; border: 2px solid #c0392b; border-radius: 2px; background: #f4e8e8; font-family: var(--mono); font-size: 11px; color: #5a0000; display: none; }
.reset-btn { margin-top: 20px; width: 100%; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; background: none; border: 1px solid var(--border2); color: var(--ink3); padding: 9px; border-radius: 2px; cursor: pointer; transition: all 0.15s; display: none; }
.reset-btn:hover { border-color: var(--accent); color: var(--accent); }
.footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.footer-text { font-family: var(--mono); font-size: 10px; color: var(--ink3); }
.footer-stack { display: flex; gap: 6px; }
.stack-tag { font-family: var(--mono); font-size: 9px; color: var(--ink3); padding: 2px 5px; border: 1px solid var(--border2); border-radius: 1px; }

/* ── Auth bar (header) ───────────────────────────────────── */
.header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.header-bar .wordmark { margin-bottom: 0; }
.auth-bar { display: flex; align-items: center; gap: 10px; }
.auth-email { font-family: var(--mono); font-size: 10px; color: var(--ink3); }
.auth-signin-btn { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; background: none; border: 1px solid var(--border2); color: var(--ink2); padding: 4px 10px; border-radius: 1px; cursor: pointer; transition: all 0.15s; }
.auth-signin-btn:hover { border-color: var(--accent); color: var(--accent); }
.auth-signout-btn { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; background: none; border: 1px solid var(--border2); color: var(--ink3); padding: 4px 10px; border-radius: 1px; cursor: pointer; transition: all 0.15s; }
.auth-signout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Auth modal ──────────────────────────────────────────── */
.auth-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 999; }
.auth-overlay.open { display: flex; }
.auth-modal { background: var(--bg); border: 1px solid var(--border2); border-radius: 2px; padding: 32px 28px; width: 100%; max-width: 360px; position: relative; }
.auth-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-family: var(--mono); font-size: 14px; color: var(--ink3); cursor: pointer; line-height: 1; }
.auth-close:hover { color: var(--ink); }
.auth-title { font-family: var(--sans); font-size: 18px; font-weight: 500; color: var(--ink); margin-bottom: 18px; }
.auth-subtitle { font-family: var(--mono); font-size: 11px; color: var(--ink3); margin-bottom: 14px; line-height: 1.5; }
.auth-err { font-family: var(--mono); font-size: 11px; color: #5a0000; background: #f4e8e8; border: 1px solid #c0392b; border-radius: 1px; padding: 7px 10px; margin-bottom: 12px; display: none; }
.auth-input { display: block; width: 100%; font-family: var(--mono); font-size: 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--border2); border-radius: 1px; padding: 9px 11px; margin-bottom: 10px; outline: none; transition: border-color 0.15s; }
.auth-input:focus { border-color: var(--accent); }
.auth-input-code { letter-spacing: 0.3em; font-size: 16px; text-align: center; }
.auth-submit { width: 100%; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; background: var(--accent); border: none; color: #fff; padding: 10px; border-radius: 1px; cursor: pointer; margin-top: 4px; transition: opacity 0.15s; }
.auth-submit:hover { opacity: 0.88; }
.auth-submit:disabled { opacity: 0.45; cursor: default; }
.auth-switch { font-family: var(--mono); font-size: 10px; color: var(--ink3); margin-top: 14px; text-align: center; }
.auth-link { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ── Password field with unmask toggle ───────────────────── */
.auth-pw-wrap { position: relative; margin-bottom: 10px; }
.auth-pw-wrap .auth-input { margin-bottom: 0; padding-right: 38px; }
.pw-toggle { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); background: none; border: none; padding: 0; cursor: pointer; line-height: 1; opacity: 0.45; transition: opacity 0.15s; }
.pw-toggle svg { width: 16px; height: 16px; display: block; border-radius: 3px; }
.pw-toggle:hover { opacity: 0.75; }
.pw-toggle.pw-visible { opacity: 1; }
