:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --text: #c0caf5;
  --accent: #7aa2f7;
  --green: #9ece6a;
  --red: #f7768e;
  --border: #414868;
}

body.light-mode {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --text: #172033;
  --accent: #2f6bf2;
  --green: #1d7f4f;
  --red: #b63546;
  --border: #d7dcea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.header {
  background: var(--surface);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  vertical-align: middle;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.theme-toggle {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.9rem;
}

.tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.panel {
  display: none;
  padding: 1rem 0;
}

.panel.active {
  display: block;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.2rem;
  color: var(--accent);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-title-row h2 {
  margin-bottom: 0;
}

.help-toggle {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.help-toggle:hover {
  border-color: var(--accent);
}

.help-box {
  margin: 0.45rem 0 0.85rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.86rem;
  line-height: 1.45;
}

.panel textarea {
  width: 100%;
  padding: 0.75rem;
  margin: 0.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}

.panel label {
  display: block;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.panel input[type="number"],
.panel select {
  margin-left: 0.5rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

/* File input: native input hidden, trigger styled like other buttons */
.file-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  cursor: default;
}

.file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-btn {
  display: inline-block;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.file-btn:hover {
  border-color: var(--accent);
  background: var(--border);
}

.panel input[type="checkbox"] {
  margin-right: 0.5rem;
}

.actions {
  margin: 1rem 0;
}

.panel button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.panel button:hover {
  filter: brightness(1.1);
}

.encode-source-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--border);
}

.panel button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.panel-hint {
  font-size: 0.8125rem;
  color: #9aa5ce;
  margin: 0.35rem 0 0.85rem;
  line-height: 1.45;
}

.panel-hint strong {
  color: var(--text);
  font-weight: 600;
}

.status {
  font-size: 0.9rem;
  margin: 0.5rem 0;
  min-height: 1.5em;
}

.runtime {
  font-size: 0.85rem;
  margin: 0.2rem 0 0.25rem;
  color: var(--text);
  opacity: 0.85;
}

.status.error {
  color: var(--red);
}

.status.ok {
  color: var(--green);
}

.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.85rem;
  max-height: 300px;
  overflow: auto;
}

.preview {
  margin-top: 1rem;
}

.preview img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.progress-wrap {
  margin-top: 0.75rem;
}

.progress-bar {
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.2s ease;
}

.progress-fill.indeterminate {
  width: 30% !important;
  animation: progress-indeterminate 1s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { margin-left: 0; }
  50% { margin-left: 70%; }
  100% { margin-left: 0; }
}

.log-output {
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  margin: 0;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Hide Barcode: metrics comparison panel (like reference image) */
.metrics-comparison-panel {
  margin-top: 1.25rem;
  background: #ddeeff;
  border: 1px solid #4a6fa5;
  border-radius: 8px;
  padding: 1rem;
}

.metrics-comparison-inner {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.5rem;
}

@media (max-width: 560px) {
  .metrics-comparison-inner {
    grid-template-columns: 1fr;
  }
}

.metrics-panel-title {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.metrics-panel-title-with-icon::before {
  content: "▤ ";
  color: var(--accent);
}

.metrics-quality-col .metrics-line {
  margin: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text);
}

.metrics-subsection {
  margin-bottom: 0.75rem;
}

.metrics-subtitle {
  margin: 0 0 0.25rem 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.metrics-subtitle.metrics-advanced {
  color: #6b21a8;
}

.metrics-subtitle.metrics-differences {
  color: #b91c1c;
}

.metrics-details {
  margin: 0;
  padding-left: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
}

.metrics-thumb {
  display: block;
  max-width: 120px;
  max-height: 120px;
  width: auto;
  height: auto;
  border: 1px solid #4a6fa5;
  border-radius: 4px;
  margin-bottom: 0.35rem;
}

/* Mobile: iOS Safari often blocks programmatic download after async fetch; show image to tap-and-hold save */
.hb-save-hint {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f0f4fa;
  border: 1px solid #c5d4e8;
  border-radius: 8px;
}

.hb-save-hint-text {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.hb-stego-save-preview {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border: 1px solid #4a6fa5;
  border-radius: 6px;
  background: #fff;
}
