:root {
  color-scheme: dark;
  --bg: #030508;
  --bg-elevated: #06090e;
  --surface: #0b0f16;
  --surface-2: #0f141d;
  --surface-3: #131a26;
  --line: #1d2431;
  --line-strong: #2b3446;
  --text: #eceff5;
  --muted: #99a1b3;
  --accent: #596170;
  --accent-2: #4b5260;
  --ok: #22c55e;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f3f7;
  --bg-elevated: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --surface-3: #eceff5;
  --line: #d7dfef;
  --line-strong: #c2cee5;
  --text: #1d253d;
  --muted: #5f6d8d;
  --accent: #6d7585;
  --accent-2: #5e6675;
  --ok: #1faa54;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% -8%, #11141a 0%, #080a0e 32%, var(--bg) 100%);
  letter-spacing: 0.01em;
}

.layout {
  width: min(1240px, 100% - 24px);
  margin: 20px auto;
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #0c1118 0%, #0a0e15 100%);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.hero-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 11px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: #3b4453;
  background: #171c25;
}

h1 {
  margin: 8px 0 8px;
  font-size: clamp(22px, 2.3vw, 32px);
  line-height: 1.12;
}

.sub {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.badge {
  margin: 0;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: #b3bac8;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.01);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 10px;
}

.editor-left,
.editor-right {
  border: 1px solid #171d2a;
  border-radius: 10px;
  background: #090d14;
  padding: 12px;
}

h2,
h3,
h4 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.drop {
  border: 1px dashed #3a4250;
  border-radius: 12px;
  min-height: 136px;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  color: #d5dbe6;
  margin-bottom: 12px;
  padding: 16px;
  background: linear-gradient(180deg, #12161e 0%, #0c1118 100%);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop:hover {
  border-color: #596272;
  background: linear-gradient(180deg, #171d28 0%, #101620 100%);
}

.quality-presets {
  margin-top: 4px;
}

#qualityPresetTitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.ghost {
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: #131923;
  color: #d9dde7;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chip:hover,
.ghost:hover {
  border-color: #404958;
  background: #181f2a;
}

.quality-chip.active {
  border-color: #566071;
  background: #232a36;
  color: #f1f3f7;
}

.hint.compact {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

#qualityLabel {
  display: inline;
  margin: 0;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
}

.range-wrap {
  display: block;
  margin-top: 10px;
}

input[type="range"] {
  accent-color: var(--accent-2);
}

.check {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions-row {
  margin-top: 11px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions-row .primary {
  width: 100%;
}

.primary {
  border: 1px solid #3b4352;
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #353d4b 0%, #2a313d 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease;
}

.primary:hover {
  filter: brightness(1.05);
}

.ghost-primary {
  border-color: #313846;
  background: #1c2431;
}

.ghost-primary:hover {
  background: #242d3c;
}

.download {
  margin-top: 10px;
  display: inline-flex;
  text-decoration: none;
  color: #dde1ea;
  font-size: 13px;
  font-weight: 600;
}

.status {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status.muted {
  opacity: 0.92;
}

#upsizeGuard {
  color: #a7f3d0;
}

.top-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 1px;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0f141d;
  color: #c6ccda;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}

.tab.active {
  border-color: #3c4861;
  background: #181f2d;
  color: #e9edf6;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
  gap: 10px;
}

.info,
.about {
  padding: 14px;
}

.stats {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0f151f;
  padding: 10px;
}

.stats span {
  font-size: 11px;
  color: var(--muted);
}

.stats b {
  display: block;
  margin-top: 7px;
  font-size: 14px;
}

.about #footerBadge {
  margin-bottom: 10px;
}

.about #aboutTitle {
  margin: 0 0 10px;
  text-align: left;
}

.about #aboutText {
  margin: 0 0 12px;
  line-height: 1.36;
  font-size: 14px;
  text-align: left;
}

.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.history-card {
  padding: 14px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid var(--line);
  background: #0f151f;
  border-radius: 9px;
  padding: 10px;
}

.history-item-meta {
  color: var(--muted);
  font-size: 12px;
}

.history-item strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.history-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  padding: 12px;
  font-size: 13px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 10, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1018;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  padding: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-grid {
  display: grid;
  gap: 10px;
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.site-footer {
  margin-top: 18px;
  border-top: 1px solid #141926;
  background: #05070b;
  padding: 34px 12px 30px;
}

.site-footer-inner {
  width: min(1240px, 100%);
  margin: 0 auto;
  display: grid;
  justify-items: center;
  gap: 18px;
}

.site-footer-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-footer-logo img {
  width: 76px;
  height: 86px;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 8px rgba(176, 154, 105, 0.18));
}

.site-footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.site-footer-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 200px;
  border: 1px solid #2a3242;
  border-radius: 10px;
  background: #151a23;
  color: #f3f7ff;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.site-footer-btn:hover {
  border-color: #3b4760;
  background: #1b2230;
}

@media (max-width: 1000px) {
  .editor-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .panel-head {
    flex-direction: column;
  }

  .row,
  .actions-row,
  .stats {
    grid-template-columns: 1fr;
  }

  .site-footer-btn {
    width: 100%;
    min-width: 0;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding-top: 24px;
  }
}
