:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-top: #eef4fb;
  --bg-bottom: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #172033;
  --muted: #68758a;
  --border: #d9e1ec;
  --accent: #315f9f;
  --accent-soft: #e8f0fb;
  --danger: #b42318;
  --success: #166534;
  --shadow: 0 18px 45px rgba(24, 39, 75, 0.10);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-top: #111827;
  --bg-bottom: #0b1220;
  --panel: #111c2f;
  --panel-soft: #0f1a2b;
  --text: #e5eefc;
  --muted: #a5b4cf;
  --border: #24324a;
  --accent: #5b8cff;
  --accent-soft: #182846;
  --danger: #f87171;
  --success: #86efac;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(108, 160, 255, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(84, 210, 255, 0.14), transparent 24%),
    linear-gradient(155deg, var(--bg-top) 0%, var(--bg) 52%, var(--bg-bottom) 100%);
  color: var(--text);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.32;
  z-index: 0;
}

body::before {
  top: 4rem;
  right: -6rem;
  background: rgba(84, 210, 255, 0.22);
}

body::after {
  bottom: -6rem;
  left: -5rem;
  background: rgba(108, 160, 255, 0.18);
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1640px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 40px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(420px, 1fr);
  gap: 14px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: none;
  margin-bottom: 12px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
  font-weight: 800;
}

button {
  height: 58px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover {
  background: #264f87;
}

body[data-theme="dark"] button:hover {
  background: #7ca2ff;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.theme-toggle {
  min-width: 96px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

.theme-toggle:hover {
  background: var(--panel-soft);
}

#compareButton {
  min-width: 110px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

#compareButton:hover:not(:disabled) {
  background: var(--panel-soft);
}

#compareButton:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  background: var(--panel);
  color: var(--muted);
}

.calculator,
.tool-panel {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

body[data-theme="dark"] .calculator,
body[data-theme="dark"] .tool-panel {
  background: rgba(17, 28, 47, 0.9);
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
}

.drop-zone {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: border 160ms ease, box-shadow 160ms ease;
}

.drop-zone.dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(49, 95, 159, 0.14);
}

.drop-title,
.metric-label,
.toggle,
.pane-header {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.file-name {
  align-self: center;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1rem, 1.9vw, 1.35rem);
  font-weight: 800;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.summary-panel {
  overflow: hidden;
}

.summary-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.summary-state {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0;
}

.summary-content {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.metric {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1rem, 1.9vw, 1.35rem);
  font-weight: 800;
}

.diff-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 0 16px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

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

.diff-grid {
  display: grid;
  grid-template-columns: var(--left-pane-width, minmax(0, 1fr)) 14px minmax(0, 1fr);
  gap: 0;
  min-height: 0;
}

.diff-grid.resizing {
  cursor: ew-resize;
  user-select: none;
}

.diff-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.resize-divider {
  width: 14px;
  height: 100%;
  min-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: ew-resize;
  position: relative;
}

.resize-divider:hover,
.resize-divider:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  outline: none;
}

.resize-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 58px;
  border-inline: 1px solid var(--muted);
  transform: translate(-50%, -50%);
  opacity: 0.7;
}

.pane-header {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  overflow-wrap: anywhere;
}

.diff-lines {
  overflow: auto;
  background: var(--panel-soft);
  color: var(--text);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.diff-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  min-height: 26px;
  border-left: 4px solid transparent;
}

.diff-row.hidden-context {
  display: none;
}

.line-number {
  user-select: none;
  padding: 4px 10px;
  color: var(--muted);
  text-align: right;
  border-right: 1px solid var(--border);
}

.line-text {
  min-width: 0;
  padding: 4px 10px;
  white-space: pre;
}

.diff-row.added {
  border-left-color: var(--success);
  background: color-mix(in srgb, var(--success) 13%, var(--panel));
}

.diff-row.missing {
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
  color: var(--danger);
}

.diff-row.empty {
  background: color-mix(in srgb, var(--danger) 6%, var(--panel));
}

.diff-row.placeholder .line-text {
  color: var(--danger);
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-weight: 700;
}

@media (max-width: 820px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    align-items: stretch;
  }

  .hero-actions button {
    flex: 1;
  }

  .app-shell {
    width: min(100% - 20px, 1640px);
    padding: 24px 0;
    grid-template-rows: auto auto auto auto auto;
  }

  .upload-grid,
  .diff-grid,
  .summary-content {
    grid-template-columns: 1fr;
  }

  .diff-grid {
    --left-pane-width: minmax(0, 1fr);
    gap: 14px;
  }

  .resize-divider {
    display: none;
  }

  .diff-toolbar {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 14px;
  }

  .diff-pane {
    min-height: 380px;
  }
}
