:root {
  --primary: #1c69d4;
  --primary-active: #0653b6;
  --primary-disabled: #d6d6d6;
  --ink: #262626;
  --body: #3c3c3c;
  --body-strong: #1a1a1a;
  --muted: #6b6b6b;
  --muted-soft: #9a9a9a;
  --hairline: #e6e6e6;
  --hairline-strong: #cccccc;
  --canvas: #ffffff;
  --surface-soft: #f7f7f7;
  --surface-card: #fafafa;
  --surface-strong: #ebebeb;
  --error-bg: #fff2f1;
  --error-border: #efb8b4;
  --error-text: #dc2626;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  --success: #22c55e;
}

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

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'BMW Type Next Latin', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 300;
  color: var(--body);
  background-color: var(--surface-soft);
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

/* ── Layout ────────────────────────────────── */

.app-shell {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.app-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
}

/* ── Hero ──────────────────────────────────── */

.hero {
  padding: 48px 48px 40px;
  border-bottom: 1px solid var(--hairline);
}

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

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.language-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(64px, 1fr));
  border: 1px solid var(--hairline-strong);
  background: var(--canvas);
  flex-shrink: 0;
}

.language-toggle__button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--hairline-strong);
  border-radius: 0;
  background: var(--canvas);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.language-toggle__button:last-child {
  border-right: 0;
}

.language-toggle__button[aria-pressed="true"] {
  background: var(--primary);
  color: #ffffff;
}

.language-toggle__button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.intro {
  max-width: 60ch;
  margin: 16px 0 0;
  font-size: 16px;
  font-weight: 300;
  line-height: 1.55;
  color: var(--muted);
}

/* ── Panels ────────────────────────────────── */

.drop-panel,
.processing-panel,
.result-panel {
  padding: 32px 48px;
}

.drop-panel {
  border-bottom: 1px solid var(--hairline);
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.panel-heading p {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1.55;
}

/* ── App description ───────────────────────── */

.app-description {
  border-bottom: 1px solid var(--hairline);
}

.app-description summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 48px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  list-style: none;
}

.app-description summary::-webkit-details-marker {
  display: none;
}

.app-description summary::after {
  content: "+";
  color: var(--primary);
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
}

.app-description[open] summary {
  border-bottom: 1px solid var(--hairline);
}

.app-description[open] summary::after {
  content: "-";
}

.app-description summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.app-description__content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 32px;
  padding: 24px 48px 28px;
  background: var(--canvas);
}

.app-description h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.app-description p,
.app-description ul {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.55;
}

.app-description ul {
  padding-left: 18px;
}

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

/* ── Drop Zone ─────────────────────────────── */

.drop-zone {
  margin-top: 24px;
  padding: 40px 24px;
  border: 2px dashed var(--hairline-strong);
  background: var(--surface-card);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--primary);
  background: var(--canvas);
  outline: none;
}

body[data-state="dragover"] .drop-zone {
  border-color: var(--primary);
  background: var(--canvas);
}

.drop-zone__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.drop-zone__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}

.drop-zone__text {
  margin: 8px 0 20px;
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
}

.drop-zone__hint {
  margin: 16px 0 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted-soft);
  letter-spacing: 0.5px;
}

.privacy-note,
.status-message,
.results-caption {
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1.55;
}

.privacy-note,
.status-message,
.error-message,
.info-message {
  margin: 16px 0 0;
}

#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Buttons ───────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 32px;
  border: 1px solid transparent;
  border-radius: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.button:disabled {
  background: var(--primary-disabled);
  border-color: var(--primary-disabled);
  color: var(--muted);
  cursor: not-allowed;
}

.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.button-primary:hover:not(:disabled),
.button-primary:focus-visible:not(:disabled) {
  background: var(--primary-active);
  border-color: var(--primary-active);
  outline: none;
}

.button-secondary {
  background: var(--canvas);
  border-color: var(--hairline-strong);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled),
.button-secondary:focus-visible:not(:disabled) {
  border-color: var(--ink);
  outline: none;
}

/* ── Status / Error messages ───────────────── */

.status-message:empty {
  display: none;
}

.error-message,
.info-message {
  padding: 12px 16px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 300;
  line-height: 1.55;
}

.error-message {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.info-message {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

/* ── Processing panel ──────────────────────── */

.processing-panel {
  display: grid;
  justify-items: center;
  gap: 16px;
  border-top: 1px solid var(--hairline);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--hairline-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

/* ── Result panel ──────────────────────────── */

.result-panel {
  border-top: 1px solid var(--hairline);
}

.details-card {
  min-width: 0;
}

.results-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.results-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.results-caption {
  margin: 8px 0 0;
}

.actions-compact {
  margin-top: 0;
  flex-shrink: 0;
}

/* ── Summary card ──────────────────────────── */

.summary-card {
  margin-top: 24px;
  padding: 0;
  border: 1px solid var(--hairline);
  background: var(--surface-card);
}

.summary-list {
  margin: 0;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 1fr);
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row dt {
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
}

.summary-row dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

/* ── Results table ─────────────────────────── */

.results-table-wrap {
  margin-top: 24px;
  overflow-x: auto;
  border: 1px solid var(--hairline);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: var(--canvas);
}

.results-table th,
.results-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

.results-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

.results-table td {
  font-size: 14px;
  font-weight: 300;
  color: var(--body);
}

.result-file {
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

.result-subtext {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted-soft);
  letter-spacing: 0.5px;
}

/* ── Status pills ──────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-waiting {
  background: var(--surface-strong);
  border-color: var(--hairline-strong);
  color: var(--muted);
}

.status-processing {
  background: #e8f0fc;
  border-color: #b3caef;
  color: var(--primary-active);
}

.status-optimized {
  background: #e9f8ef;
  border-color: #b9e3c6;
  color: #166534;
}

.status-already-optimized {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.status-failed,
.status-skipped {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

/* ── Actions ───────────────────────────────── */

.download-button {
  min-width: 0;
  padding: 0 16px;
  font-size: 13px;
}

.actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ── Keyframes ─────────────────────────────── */

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

/* ── Responsive ────────────────────────────── */

@media (max-width: 720px) {
  .app-shell {
    padding: 24px 16px 48px;
  }

  .hero,
  .drop-panel,
  .processing-panel,
  .result-panel {
    padding: 24px 20px;
  }

  .hero__topline {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }

  .language-toggle {
    width: 100%;
  }

  .app-description summary {
    padding: 14px 20px;
  }

  .app-description__content {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px;
  }

  .summary-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .summary-row dd {
    text-align: left;
  }

  .results-heading {
    flex-direction: column;
  }

  .actions-compact {
    width: 100%;
  }

  .actions-compact .button {
    flex: 1 1 200px;
  }
}
