:root {
  --bg: #ffffff;
  --fg: #161616;
  --muted: #6b6b6b;
  --line: #d9d9d9;
  --surface: #f5f5f5;
  --accent: #161616;
  --accent-fg: #ffffff;
  --ok: #1a7f37;
  --warn: #9a5b00;
  --err: #b42318;
  --focus: #2563eb;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #ececec;
    --muted: #9a9a9a;
    --line: #353535;
    --surface: #1b1b1b;
    --accent: #ececec;
    --accent-fg: #121212;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --focus: #60a5fa;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 16px 64px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 { margin: 0 0 4px; font-size: 1.25rem; line-height: 1.3; font-weight: 600; }
h3 { margin: 32px 0 8px; font-size: 0.9375rem; font-weight: 600; }

p { margin: 0 0 12px; }

.lead { margin-bottom: 28px; color: var(--muted); }
.muted { color: var(--muted); }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- зона загрузки ---- */

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 176px;
  padding: 24px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.drop:hover,
.drop.is-dragover {
  border-color: var(--fg);
  background: var(--surface);
}

.drop:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.drop-title { font-size: 1.125rem; font-weight: 600; }
.drop-hint { color: var(--muted); }

main[data-state="done"] .drop {
  min-height: 0;
  padding: 14px 24px;
}

main[data-state="done"] .drop-title { font-size: 1rem; }
main[data-state="done"] .drop-hint { display: none; }

/* ---- состояния ---- */

.busy { margin-top: 16px; color: var(--muted); }

.message { margin-top: 16px; }
.message.error { color: var(--err); }
.message.ok { color: var(--ok); }
.message.warn { color: var(--warn); }

.result { margin-top: 32px; }
.file-name { margin-bottom: 4px; overflow-wrap: anywhere; }
.result .message { margin-top: 12px; }

.warnings {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--warn);
  font-size: 0.9375rem;
}

/* ---- выбор формата ---- */

.formats {
  margin: 24px 0 20px;
  padding: 0;
  border: 0;
}

.formats legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.format {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  cursor: pointer;
}

.format input {
  flex: none;
  margin: 5px 0 0;
  accent-color: var(--accent);
}

.format input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.format-title { display: block; font-weight: 500; }
.format-hint { display: block; color: var(--muted); font-size: 0.875rem; }

/* ---- кнопка ---- */

.btn {
  display: inline-block;
  padding: 12px 24px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { opacity: 0.88; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (max-width: 480px) {
  .btn { width: 100%; }
}

/* ---- предпросмотр ---- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  white-space: nowrap;
}

th, td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

tbody tr:last-child td { border-bottom: 0; }

th { color: var(--muted); font-weight: 500; background: var(--surface); }

.num { text-align: right; font-variant-numeric: tabular-nums; }

td.cut {
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.pos { color: var(--ok); }

/* ---- подвал ---- */

footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

footer p:last-child { margin-bottom: 0; }
