:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5f6f80;
  --line: #d6dee8;
  --soft-panel: #f9fbfd;
  --table-head: #e9eef5;
  --primary: #176c73;
  --primary-strong: #10545a;
  --primary-soft: #e3f4f5;
  --danger: #a12a2a;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101720;
  --panel: #17212d;
  --text: #e8edf3;
  --muted: #a5b3c3;
  --line: #304050;
  --soft-panel: #111b26;
  --table-head: #223142;
  --primary: #35a0ad;
  --primary-strong: #62bfca;
  --primary-soft: #14313c;
  --danger: #f2a0a0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 2.35rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.12rem;
}

section,
details {
  margin-top: 22px;
}

button,
input {
  font: inherit;
}

input[type="file"] {
  display: none;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 28px 0 10px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.intro,
#table-summary,
.notice {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.5;
}

.notice {
  margin-bottom: 14px;
}

.hero-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

#status {
  margin: 0;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}

#theme-toggle,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

button:not(:disabled):hover {
  border-color: var(--primary);
  color: var(--primary);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.upload-panel,
.settings,
.results,
details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.drop-zone {
  display: grid;
  width: 100%;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 2px dashed #8a94a6;
  border-radius: 8px;
  background: var(--soft-panel);
  color: var(--text);
}

.drop-zone span {
  font-weight: 700;
}

.drop-zone small,
.file-list {
  color: var(--muted);
}

.drop-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.file-list {
  margin-top: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft-panel);
  color: var(--text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.export-actions {
  margin-top: 0;
  justify-content: flex-end;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  min-width: 110px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  font-size: 0.85rem;
}

td {
  background: var(--panel);
  font-size: 0.9rem;
}

td[contenteditable="true"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--primary-soft);
}

pre {
  max-height: 520px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text);
  font: 0.85rem/1.45 "Courier New", monospace;
}

.empty-cell {
  color: var(--muted);
}

@media (max-width: 760px) {
  main {
    width: min(100% - 20px, 1180px);
    padding: 20px 0 36px;
  }

  .hero,
  .result-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-actions {
    justify-items: start;
  }

  #status {
    white-space: normal;
  }
}
