:root {
  --bg: #10151a;
  --surface: #192027;
  --card: #222a31;
  --border: #36414a;
  --border-light: #53616b;
  --accent: #c2a36b;
  --accent-dark: #a9864f;
  --accent-dim: rgba(194,163,107,0.14);
  --success: #8fae9b;
  --success-dim: rgba(143,174,155,0.14);
  --error: #c08478;
  --text: #eee9dd;
  --text-muted: #b8c0bd;
  --text-dim: #78858a;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 3px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 17px;
  line-height: 1.5;
}

.app { max-width: 860px; margin: 0 auto; padding: 44px 20px 80px; }

/* ── Header ── */
.header { text-align: center; margin-bottom: 40px; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.logo-img { width: 52px; height: 52px; object-fit: contain; }

.logo h1 {
  font-family: 'Cinzel Decorative', Georgia, serif;
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-style: italic;
  letter-spacing: 0.06em;
}

.header-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

.orn-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-light), transparent);
}

.orn-sym { color: var(--accent); font-size: 0.8rem; opacity: 0.8; }

/* ── Upload ── */
.upload-zone {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 52px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
  position: relative;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.upload-zone:hover { border-color: var(--accent); }
.upload-zone:hover::before { opacity: 1; border-color: rgba(194,163,107,0.32); }
.upload-zone.drag-over { border-color: var(--accent); background: var(--accent-dim); }

.upload-icon {
  color: var(--text-dim);
  margin-bottom: 14px;
  transition: color 0.2s, transform 0.2s;
}

.upload-zone:hover .upload-icon { color: var(--accent); transform: translateY(-4px); }

.upload-text {
  font-family: 'Cinzel Decorative', Georgia, serif;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.upload-or { color: var(--text-dim); font-style: italic; font-size: 0.85rem; margin: 10px 0; }

.btn-browse {
  display: inline-block;
  padding: 8px 28px;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-xs);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-bottom: 14px;
}

.btn-browse:hover { background: var(--accent); color: var(--bg); }
.upload-hint { color: var(--text-dim); font-size: 0.82rem; font-style: italic; }

/* ── Panel ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 12px;
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-divider { height: 1px; background: var(--border); margin: 12px 0; }

.seg-tabs {
  display: flex;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
}

.seg-tab {
  padding: 6px 16px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.seg-tab + .seg-tab { border-left: 1px solid var(--border-light); }
.seg-tab.active { background: var(--accent); color: var(--bg); }
.seg-tab:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.04); }

.control-group { flex: 1; min-width: 200px; }

.control-label {
  display: block;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 7px;
  letter-spacing: 0.03em;
}

.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }

.quality-badge {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(194,163,107,0.32);
  letter-spacing: 0.02em;
}

.slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--border-light);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
  transition: box-shadow 0.15s;
}

.slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 5px rgba(194,163,107,0.22); }

.slider-hints { display: flex; justify-content: space-between; margin-top: 4px; }
.slider-hints span { font-size: 0.75rem; font-style: italic; color: var(--text-dim); }

.format-row { gap: 12px; }
.format-note { font-size: 0.8rem; font-style: italic; color: var(--text-dim); }

.size-input-row { display: flex; gap: 8px; }

.field-input {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 6px 10px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

.field-input:focus { border-color: var(--accent); }

.field-select {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 6px 8px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
}

.btn-compress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 22px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-xs);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 10px rgba(194,163,107,0.18);
}

.btn-compress:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.btn-compress:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Options row ── */
.options-row { gap: 14px; padding-top: 2px; }

.option-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.option-sep { width: 1px; height: 28px; background: var(--border-light); flex-shrink: 0; }

.toggle-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.toggle-wrap input[type="checkbox"] { display: none; }

.toggle-track {
  width: 34px;
  height: 18px;
  background: var(--border-light);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-wrap input:checked + .toggle-track { background: var(--accent); }
.toggle-wrap input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); background: var(--bg); }

.toggle-label { font-size: 0.88rem; font-style: italic; color: var(--text-muted); cursor: pointer; }

.resize-wrap { display: none; align-items: center; gap: 5px; }
.resize-wrap.active { display: flex; }
.field-sm { width: 72px; text-align: right; padding: 4px 8px; font-size: 0.9rem; }
.field-pre, .field-suf { font-size: 0.8rem; font-style: italic; color: var(--text-dim); }

.rename-wrap { display: flex; align-items: center; gap: 6px; }
.rename-field { width: 96px; font-size: 0.85rem; padding: 4px 8px; }
.rename-mid { font-size: 0.78rem; font-style: italic; color: var(--text-dim); white-space: nowrap; border: 1px dashed var(--border-light); padding: 3px 6px; border-radius: var(--radius-xs); }

.hidden { display: none !important; }

/* ── Images list ── */
.images-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }

.image-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  transition: border-color 0.15s;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.image-card.done { border-color: rgba(143,174,155,0.32); }

.image-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  border: 1px solid var(--border-light);
  transition: opacity 0.15s;
}

.card-info { flex: 1; min-width: 0; }

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-sizes { display: flex; align-items: center; gap: 7px; font-size: 0.88rem; }
.size-original { color: #d97b6c; font-weight: 500; }
.size-arrow { color: var(--text-dim); font-size: 0.75rem; }
.size-compressed { color: var(--accent); font-style: italic; transition: color 0.3s; }
.size-compressed.done { color: #6dbf8c; font-style: normal; font-weight: 600; }

.card-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.status-badge {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.02em;
}

.badge-pending { background: rgba(104,88,64,0.25); color: var(--text-muted); }
.badge-compressing { background: var(--accent-dim); color: var(--accent); }
.badge-done { background: var(--success-dim); color: var(--success); }
.badge-error { background: rgba(196,106,106,0.12); color: var(--error); }

.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(194,163,107,0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-download {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(143,174,155,0.28);
  border-radius: var(--radius-xs);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-download:hover { background: rgba(143,174,155,0.2); transform: translateY(-1px); }

.btn-remove {
  position: absolute;
  top: 8px; right: 8px;
  width: 20px; height: 20px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.btn-remove:hover { color: var(--error); background: rgba(196,106,106,0.12); }

/* ── Actions bar ── */
.actions-bar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
}

.actions-summary { font-size: 0.92rem; font-style: italic; color: var(--text-muted); }
.actions-summary strong { color: var(--success); font-style: normal; }
.actions-buttons { display: flex; gap: 10px; }

.btn-ghost {
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover { border-color: var(--error); color: var(--error); }

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-xs);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── History ── */
.history-section {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.92rem;
  font-style: italic;
  cursor: pointer;
  transition: color 0.15s;
  text-align: left;
}

.history-toggle:hover { color: var(--text); }

.history-badge {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  font-style: normal;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid rgba(194,163,107,0.22);
}

.chevron { margin-left: auto; transition: transform 0.2s; color: var(--text-dim); }
.history-entries { border-top: 1px solid var(--border); }

.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  gap: 12px;
}

.history-entry:last-child { border-bottom: none; }

.history-date { color: var(--text-muted); font-style: italic; flex-shrink: 0; }
.history-detail { color: var(--text); }
/* ── Comparison modal ── */
.cmp-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cmp-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8,6,3,0.9);
}

.cmp-box {
  position: relative;
  z-index: 1;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px;
  max-width: 820px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.cmp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cmp-title {
  font-family: 'Cinzel Decorative', Georgia, serif;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.cmp-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.15s;
}

.cmp-close:hover { color: var(--error); }

.cmp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-dim);
  margin-bottom: 6px;
  padding: 0 2px;
}

.cmp-area {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: ew-resize;
  user-select: none;
  max-height: 62vh;
  background: #000;
}

.cmp-img {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
}

.cmp-before {
  position: absolute;
  top: 0; left: 0;
  clip-path: inset(0 50% 0 0);
}

.cmp-line {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255,255,255,0.9);
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
}

.cmp-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px; height: 36px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  cursor: ew-resize;
  z-index: 2;
}

.cmp-info {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  padding: 0 2px;
}

.cmp-info strong { color: var(--success); font-style: normal; }

.btn-compare {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(194,163,107,0.26);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-compare:hover { background: rgba(194,163,107,0.2); }

.intro-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-style: italic;
  margin-bottom: 20px;
  line-height: 1.7;
}

.intro-text strong { color: var(--text); font-style: normal; }

.features-section, .faq-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.features-section h2, .faq-section h2 {
  font-family: 'Cinzel Decorative', Georgia, serif;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 24px;
  text-align: center;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}

.feature-icon { font-size: 1.4rem; display: block; margin-bottom: 10px; }

.feature h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.feature p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

.guide-link-wrap { text-align: center; }

.guide-link {
  color: var(--accent);
  font-size: 0.9rem;
  font-style: italic;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.guide-link:hover { text-decoration: underline; }

.faq-list { display: flex; flex-direction: column; gap: 8px; }

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.faq-item summary {
  padding: 14px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; color: var(--accent); font-size: 1.1rem; font-weight: 400; }
.faq-item[open] summary::after { content: '−'; }
.faq-item[open] { border-color: var(--border-light); }

.faq-item p {
  padding: 0 18px 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.site-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 600px) {
  .logo h1 { font-size: 2.2rem; }
  .panel-row { flex-direction: column; align-items: stretch; }
  .btn-compress { justify-content: center; }
  .card-right { flex-direction: column; gap: 6px; align-items: flex-end; }
  .upload-zone { padding: 36px 20px; }
  .options-row { flex-direction: column; }
  .option-sep { display: none; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}
