:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --text: #151a23;
  --muted: #657083;
  --line: #d9e0ea;
  --accent: #176b87;
  --accent-dark: #0f4f64;
  --accent-soft: #dff1f5;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #16794f;
  --shadow: 0 24px 70px rgba(28, 37, 54, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.workspace {
  width: min(1040px, 100%);
  background: var(--surface);
  border: 1px solid rgba(217, 224, 234, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2.5vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.status-pill {
  min-width: 164px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
}

.status-pill[data-state="ok"] {
  color: var(--success);
  background: #eef8f3;
  border-color: #c9ecdb;
}

.status-pill[data-state="ok"] .dot {
  background: var(--success);
}

.status-pill[data-state="missing"] {
  color: var(--warning);
  background: #fff8e8;
  border-color: #f3d68b;
}

.status-pill[data-state="missing"] .dot {
  background: var(--warning);
}

.conversion-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 0;
}

.upload-panel,
.settings-panel {
  padding: 32px;
}

.upload-panel {
  border-right: 1px solid var(--line);
}

.dropzone {
  min-height: 308px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  border: 1.5px dashed #a8b6c7;
  border-radius: 8px;
  background: var(--surface-muted);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.dropzone:hover,
.dropzone[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:active {
  transform: scale(0.998);
}

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

.dropzone-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
}

.dropzone-icon svg {
  width: 25px;
  height: 25px;
  display: block;
}

.dropzone-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.dropzone-title {
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 800;
}

.dropzone-file {
  max-width: 100%;
  color: var(--muted);
  overflow-wrap: anywhere;
  text-align: center;
}

.file-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 0;
}

.file-meta div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.file-meta dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.file-meta dd {
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 20px;
}

.field-row {
  display: grid;
  gap: 9px;
}

.field-row label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 42px 0 14px;
  border: 1px solid #bfc9d6;
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-weight: 700;
}

select:focus-visible,
.convert-button:focus-visible,
.download-link:focus-visible,
.secondary-button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(23, 107, 135, 0.22);
  outline-offset: 2px;
}

.quick-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
}

.quick-formats button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.quick-formats button[aria-pressed="true"] {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.convert-button,
.download-link,
.secondary-button {
  min-height: 52px;
  display: inline-grid;
  place-items: center;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.convert-button:hover,
.download-link:hover {
  background: var(--accent-dark);
}

.secondary-button {
  color: var(--accent);
  background: #eaf4f7;
  border: 1px solid #b9dce6;
}

.secondary-button:hover {
  background: #dff1f5;
}

.convert-button:disabled {
  color: #7d8898;
  background: #dce3ec;
  cursor: not-allowed;
}

.result-panel {
  min-height: 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.result-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-message {
  margin: 0;
  color: var(--text);
  font-weight: 800;
}

.result-message[data-state="error"] {
  color: var(--danger);
}

.result-message[data-state="success"] {
  color: var(--success);
}

.result-preview {
  grid-column: 1 / -1;
  max-height: 168px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #2c3442;
  font: 0.88rem/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.history-panel {
  padding: 22px 32px 28px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

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

.text-button {
  min-height: 32px;
  padding: 0 6px;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.history-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.history-list span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.history-list a {
  color: var(--accent);
  font-weight: 850;
  overflow-wrap: anywhere;
  text-align: right;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 18px;
    place-items: start center;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-panel {
    grid-template-columns: 1fr;
  }

  .result-actions {
    justify-content: stretch;
  }

  .result-actions > * {
    flex: 1;
  }

  .status-pill {
    width: 100%;
  }

  .conversion-layout {
    grid-template-columns: 1fr;
  }

  .upload-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .upload-panel,
  .settings-panel,
  .topbar,
  .result-panel,
  .history-panel {
    padding: 22px;
  }

  .dropzone {
    min-height: 240px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 0;
  }

  .workspace {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .file-meta {
    grid-template-columns: 1fr;
  }

  .history-list li {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-list a {
    text-align: left;
  }
}
