:root {
  color-scheme: dark;
  --bg: #0e111a;
  --panel: rgba(24, 29, 43, 0.88);
  --panel-strong: #202638;
  --panel-soft: rgba(44, 52, 74, 0.66);
  --ink: #f3f0ff;
  --muted: #a8b0c8;
  --line: rgba(184, 195, 230, 0.16);
  --accent: #9be7d8;
  --accent-dark: #6ed1c4;
  --accent-ink: #102220;
  --violet: #cbb7ff;
  --rose: #ffb7c8;
  --danger: #ff9da7;
  --good: #a7f3c8;
  --soft: rgba(155, 231, 216, 0.14);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(203, 183, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(155, 231, 216, 0.16), transparent 30%),
    linear-gradient(160deg, #0e111a 0%, #121827 46%, #10131e 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  display: grid;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

.workspace,
.results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 7px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

p {
  color: var(--muted);
  margin-top: 6px;
}

.actions,
.export-actions,
.result-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

button {
  min-height: 38px;
  border: 1px solid rgba(184, 195, 230, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

#downloadCsv,
#copyDiscord {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
}

#downloadCsv:hover,
#copyDiscord:hover {
  background: var(--accent-dark);
}

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 420px;
}

.input-panel,
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px 22px;
}

.settings-panel {
  border-left: 1px solid var(--line);
  background: rgba(16, 20, 31, 0.62);
}

label,
.field span {
  color: #d7ddf1;
  font-size: 13px;
  font-weight: 650;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 11, 18, 0.72);
  color: var(--ink);
  outline: none;
}

textarea::placeholder,
input::placeholder {
  color: #737d9a;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}

#logInput {
  min-height: 350px;
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
  font-family: "Cascadia Mono", Consolas, monospace;
}

#startingInput {
  min-height: 96px;
  resize: vertical;
  padding: 10px;
  line-height: 1.35;
  font-family: "Cascadia Mono", Consolas, monospace;
}

select,
input {
  min-height: 38px;
  padding: 0 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.export-actions {
  align-items: stretch;
  flex-direction: column;
}

.toggle {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 8px;
  color: var(--ink);
  font-weight: 500;
}

.toggle input {
  accent-color: var(--accent);
  min-height: 18px;
}

.results {
  padding: 20px 22px 24px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(43, 50, 72, 0.92), rgba(30, 36, 53, 0.92));
}

.metric {
  display: block;
  font-size: 28px;
  font-weight: 750;
  line-height: 1;
  color: var(--violet);
}

.metric.warn {
  color: var(--danger);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.result-toolbar {
  justify-content: flex-end;
  margin-bottom: 14px;
}

.result-toolbar label {
  white-space: nowrap;
}

.table-section {
  margin-top: 22px;
}

.table-section h2 {
  margin-bottom: 10px;
}

.hint {
  margin-bottom: 10px;
  font-size: 13px;
}

.status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  margin-top: -4px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 18, 0.44);
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: rgba(37, 44, 64, 0.96);
  color: #c5cee7;
  font-size: 12px;
  text-transform: uppercase;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.035);
}

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

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

.positive {
  color: var(--good);
  font-weight: 700;
}

.negative {
  color: var(--danger);
  font-weight: 700;
}

.unmatched {
  display: grid;
  gap: 8px;
}

.unmatched-line {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: #d4d9ea;
  background: rgba(8, 11, 18, 0.62);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty {
  color: var(--muted);
  padding: 18px 12px;
  text-align: center;
}

@media (max-width: 860px) {
  .app {
    padding: 12px;
  }

  .topbar,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .panels,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .result-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
