:root {
  --content-width: 970px;
  --color-bg: #fdfdfd;
  --color-surface: #ffffff;
  --color-primary: #2a73d9;
  --color-primary-hover: #2160b8;
  --color-dark: #38404b;
  --color-dark-hover: #2a3039;
  --color-danger: #d44d3b;
  --color-success: #1a7030;
  --color-savings: #2e7d32;
  --color-accent: #d1580a;
  --color-text: #333333;
  --color-text-light: #666666;
  --color-border: #e0e0e0;
  --color-border-subtle: #f2f2f2;
  --shadow-card: 0 5px 16px -2px rgba(42, 115, 217, 0.2);
  --radius-sm: 6px;
  --radius-md: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 15px;
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 12px 0;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-dark);
  font-size: 1.15rem;
}

.brand__text strong {
  color: var(--color-primary);
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar__nav a {
  color: var(--color-text-light);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.topbar__nav a:hover {
  color: var(--color-primary);
}

.topbar__badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-success);
  background: #edf7ef;
  border: 1px solid #cce7d2;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Hero */
.hero {
  text-align: center;
  padding: 28px 0 18px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 2em;
  font-weight: 700;
  color: var(--color-dark);
}

.hero__subtitle {
  margin: 0 auto 12px;
  max-width: 660px;
  color: var(--color-text-light);
}

.hero__steps {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text-light);
}

.hero__steps li + li {
  margin-top: 4px;
}

/* Main App Card */
.app-card,
.comparison-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar--top {
  margin-bottom: 14px;
}

.toolbar--bottom {
  margin-top: 14px;
}

.toolbar__group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.queue-summary,
.total-savings {
  font-size: 0.9rem;
  color: var(--color-text-light);
  font-weight: 600;
}

.total-savings {
  color: var(--color-savings);
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.875em;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn--success {
  background: var(--color-success);
  color: #fff;
}

.btn--success:hover:not(:disabled) {
  background: #145826;
}

.btn--dark {
  background: var(--color-dark);
  color: #fff;
}

.btn--dark:hover:not(:disabled) {
  background: var(--color-dark-hover);
}

.btn--ghost {
  background: #fff;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--color-border-subtle);
}

.btn--full {
  width: 100%;
}

/* Dropzone */
.dropzone {
  position: relative;
  min-height: 225px;
  border: 2px dashed #c7d9f2;
  border-radius: var(--radius-md);
  background: #fafcff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  outline: none;
}

.dropzone.is-dragover {
  border-color: var(--color-primary);
  background: #eef5ff;
}

.dropzone__empty {
  text-align: center;
  pointer-events: none;
}

.dropzone__title {
  margin: 10px 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-dark);
}

.dropzone__hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--color-text-light);
}

/* Carousel & File Cards */
.carousel {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.files-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 6px 28px;
  width: 100%;
  scrollbar-width: thin;
}

.carousel__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 28px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.94);
  color: var(--color-dark);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.carousel__nav--prev {
  left: 0;
}

.carousel__nav--next {
  right: 0;
}

.file-card {
  flex: 0 0 163px;
  width: 163px;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.file-card:hover {
  border-color: #9dc0ef;
}

.file-card.is-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(42, 115, 217, 0.18);
}

.file-card__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(56, 64, 75, 0.82);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.file-card__remove:hover {
  background: var(--color-danger);
}

.file-card__preview {
  width: 100%;
  height: 98px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

.file-card__preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-card__name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card__meta {
  font-size: 0.75rem;
  color: var(--color-text-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.file-card__savings {
  font-weight: 700;
  color: var(--color-savings);
}

.file-card__savings--error {
  color: var(--color-danger);
}

.file-card__action {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.74rem;
}

/* Comparison Panel */
.comparison__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.comparison__title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.comparison__filename {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}

.format-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: #edf3fc;
  color: var(--color-primary);
}

.comparison__stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
}

.stat-pill {
  background: var(--color-border-subtle);
  padding: 4px 9px;
  border-radius: 4px;
  color: var(--color-dark);
}

.savings-pill {
  background: #edf7ef;
  color: var(--color-savings);
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 4px;
}

.comparison__workspace {
  display: grid;
  grid-template-columns: 1fr 168px;
  gap: 16px;
  align-items: stretch;
}

.canvas-stage {
  position: relative;
  height: 410px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
  cursor: grab;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eeeeee 25%, transparent 25%),
    linear-gradient(-45deg, #eeeeee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eeeeee 75%),
    linear-gradient(-45deg, transparent 75%, #eeeeee 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.canvas-stage:active {
  cursor: grabbing;
}

#comparisonCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.split-thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  margin-left: -1.5px;
  background: var(--color-primary);
  cursor: ew-resize;
  z-index: 4;
}

.split-thumb__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.canvas-label {
  position: absolute;
  top: 10px;
  z-index: 3;
  background: rgba(56, 64, 75, 0.78);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
}

.canvas-label--left {
  left: 10px;
}

.canvas-label--right {
  right: 10px;
}

.canvas-controls {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 3px 6px;
}

.frame-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.78rem;
}

.frame-controls input {
  width: 46px;
  padding: 2px 4px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-align: center;
  font-size: 0.78rem;
}

.mini-btn {
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-dark);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn:hover {
  background: var(--color-border-subtle);
}

.zoom-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 42px;
  text-align: center;
}

.comp-spinner {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #d4e3f8;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Settings Sidebar */
.settings-sidebar {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  background: #fafafa;
}

.settings-sidebar__group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.settings-sidebar__label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-dark);
}

.vertical-slider-wrap {
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vertical-slider {
  width: 155px;
  transform: rotate(-90deg);
  accent-color: var(--color-primary);
  cursor: pointer;
}

.settings-sidebar__input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.number-input {
  width: 68px;
  padding: 5px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
}

.unit-label {
  font-size: 0.82rem;
  color: var(--color-text-light);
}

.settings-sidebar__hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--color-text-light);
  text-align: center;
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--color-dark);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toast--error {
  background: var(--color-danger);
}

/* Info & FAQ Sections */
.info-section {
  margin: 28px 0;
}

.info-section h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
  color: var(--color-dark);
}

.info-grid {
  display: grid;
  gap: 14px;
}

.info-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.info-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.info-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--color-primary);
}

.info-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text-light);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.faq-item summary {
  font-weight: 700;
  color: var(--color-dark);
  cursor: pointer;
}

.faq-item p {
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: var(--color-text-light);
}

@media (max-width: 760px) {
  .info-grid--3,
  .info-grid--2 {
    grid-template-columns: 1fr;
  }

  .topbar__nav {
    display: none;
  }
}

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  padding: 14px 0;
  font-size: 0.84rem;
  color: var(--color-text-light);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 760px) {
  .comparison__workspace {
    grid-template-columns: 1fr;
  }

  .vertical-slider-wrap {
    height: 36px;
  }

  .vertical-slider {
    width: 100%;
    transform: none;
  }
}

@media (max-width: 555px) {
  .container {
    padding: 0 8px;
  }

  .hero h1 {
    font-size: 1.55em;
  }

  .canvas-stage {
    height: 300px;
  }
}
