:root {
  color-scheme: light;
  --bg: #e7edf3;
  --surface: #f6f8fb;
  --raised: #ffffff;
  --text: #122033;
  --muted: #3d4c60;
  --border: #c3ced8;
  --border-strong: #5c6b7e;
  --accent: #173e6b;
  --accent-hover: #102c4e;
  --accent-active: #0b203a;
  --on-accent: #f4f8ff;
  --success: #0e5a36;
  --warning: #7a3e00;
  --danger: #8c1d33;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
  --text-sm: 0.9375rem;
  --text-body: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.375rem;
  --text-xl: 1.75rem;
  --text-2xl: 2.25rem;
  --leading: 1.5;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --radius-sm: 6px;
  --radius-md: 14px;
  --shadow: 0 1px 2px rgba(18, 32, 51, 0.06), 0 10px 28px rgba(18, 32, 51, 0.08);
  --shadow-hover: 0 2px 4px rgba(18, 32, 51, 0.08), 0 16px 36px rgba(18, 32, 51, 0.12);
  --ring: 3px solid var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10161d;
    --surface: #1a222c;
    --raised: #222b37;
    --text: #e8eef6;
    --muted: #c5d0dc;
    --border: #3c4a5c;
    --border-strong: #7d8da0;
    --accent: #b7d0f5;
    --accent-hover: #d4e4fa;
    --accent-active: #96b8e6;
    --on-accent: #0e1a2b;
    --success: #8ee0b5;
    --warning: #f0c27a;
    --danger: #ffb4c0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.4), 0 18px 40px rgba(0, 0, 0, 0.45);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: var(--leading);
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5);
}

h1,
h2,
p {
  margin: 0;
  min-width: 0;
}

h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.job {
  margin-top: var(--space-2);
  max-width: 62ch;
}

.privacy {
  margin-top: var(--space-3);
  max-width: 62ch;
  font-weight: 600;
}

form {
  margin-top: var(--space-6);
}

.field + .field {
  margin-top: var(--space-5);
}

label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
}

input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--text);
  font: inherit;
}

input[type="text"] {
  padding: 12px var(--space-4);
}

input[type="text"]:hover {
  border-color: var(--text);
}

input[type="file"] {
  padding: var(--space-2);
}

input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

input[type="file"]::file-selector-button:hover {
  background: var(--bg);
  border-color: var(--text);
}

input[type="file"]::file-selector-button:active {
  background: var(--border);
}

.field-files.is-drag input[type="file"] {
  outline: var(--ring);
  outline-offset: 2px;
}

.hint {
  margin-top: var(--space-2);
  max-width: 65ch;
  color: var(--muted);
  font-size: var(--text-sm);
}

.count {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
}

#merge {
  margin-top: var(--space-6);
  min-height: 44px;
  padding: 12px var(--space-5);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

#merge:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

#merge:active {
  background: var(--accent-active);
  border-color: var(--accent-active);
}

#merge:disabled {
  opacity: 1;
  cursor: wait;
}

#result {
  margin-top: var(--space-7);
  overflow-wrap: anywhere;
}

#result.is-empty,
#result.is-loading,
#result.is-error {
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--surface);
}

#result.is-empty {
  border: 1px dashed var(--border-strong);
}

#result.is-empty p:first-child,
#result.is-loading p {
  font-weight: 600;
}

#result.is-empty p + p {
  margin-top: var(--space-2);
}

#result.is-loading {
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
}

#result.is-error {
  border: 1px solid var(--border);
  border-left: 6px solid var(--danger);
}

#result.is-error [role="alert"] {
  color: var(--danger);
  font-weight: 600;
  white-space: pre-wrap;
}

#result.is-success {
  padding: 0;
  border: 0;
  background: transparent;
}

.report {
  animation: report-in 180ms ease;
}

.report-title {
  margin-bottom: var(--space-4);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.2;
}

.report p,
.ticket-columns {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line-note + .line-note {
  margin-top: var(--space-4);
}

.line-tag,
.line-kept,
.line-count,
.line-none {
  font-weight: 600;
}

.line-tag {
  margin-top: var(--space-4);
}

.line-kept {
  margin-top: var(--space-5);
  font-size: var(--text-2xl);
  line-height: 1.2;
}

.line-count,
.line-none {
  margin-top: var(--space-2);
}

.save-hint {
  margin-top: var(--space-5);
  font-size: var(--text-body);
}

.tickets {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.ticket {
  min-width: 0;
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--raised);
  box-shadow: var(--shadow);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.ticket:has(a:hover),
.ticket:has(a:focus-visible) {
  box-shadow: var(--shadow-hover);
}

.ticket:has(a:active) {
  transform: translateY(1px);
}

.ticket a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-4) var(--space-5) var(--space-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.ticket a:hover,
.ticket a:focus-visible {
  text-decoration: underline;
}

.ticket-columns {
  margin: 0;
  padding: 0 var(--space-5) var(--space-4);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 600;
}

.file-section {
  min-width: 0;
  margin-top: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-left: 6px solid var(--success);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.file-section[data-status="Skipped"] {
  border-left-color: var(--danger);
}

.file-section p + p {
  margin-top: var(--space-2);
}

.file-section p {
  font-size: var(--text-body);
}

.line-file {
  font-family: var(--mono);
  font-weight: 600;
}

.line-status,
.line-rows,
.line-reason {
  font-weight: 600;
}

.file-section[data-status="Read"] .line-status {
  color: var(--success);
}

.file-section[data-status="Skipped"] .line-status,
.line-reason {
  color: var(--danger);
}

.line-warning,
.line-row-warning {
  color: var(--warning);
}

:focus-visible {
  outline: var(--ring);
  outline-offset: 2px;
}

@media (max-width: 639px) {
  main {
    padding: var(--space-6) var(--space-4);
  }

  #merge {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes report-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --raised: #ffffff;
    --text: #122033;
    --muted: #3d4c60;
    --border: #c3ced8;
    --border-strong: #5c6b7e;
    --accent: #173e6b;
    --on-accent: #f4f8ff;
    --success: #0e5a36;
    --warning: #7a3e00;
    --danger: #8c1d33;
  }

  body {
    background: #fff;
    color: #122033;
  }

  .ticket,
  .file-section {
    box-shadow: none;
    print-color-adjust: exact;
  }
}
