:root {
  --bg: #F7F7F4;
  --surface: #FFFFFF;
  --ink: #16181D;
  --muted: #667085;
  --line: #E6E4DE;
  --accent: #0D7A4F;
  --accent-soft: rgba(13, 122, 79, 0.09);
  --warn-bg: #FBF6E7;
  --warn-ink: #8A6D1F;
  --drop: #0D7A4F;
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 8px 24px rgba(22, 24, 29, 0.05);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0F1115;
  --surface: #171A20;
  --ink: #E8EAED;
  --muted: #9AA3AF;
  --line: #262B33;
  --accent: #34C98A;
  --accent-soft: rgba(52, 201, 138, 0.1);
  --warn-bg: rgba(203, 158, 45, 0.12);
  --warn-ink: #D9B25C;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; }

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
}

.col { max-width: 760px; margin: 0 auto; padding: 40px 24px 96px; }

header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
h1 { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.tagline { color: var(--muted); font-size: 14px; margin-top: 2px; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.3s ease, color 0.15s ease;
}
.icon-btn:hover { color: var(--ink); transform: rotate(180deg); }


.paste-wrap { position: relative; }
#input {
  width: 100%;
  min-height: 200px;
  padding: 20px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.paste-wrap.dragging #input { border-color: var(--drop); border-style: dashed; }
.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(2px);
  color: var(--drop);
  font-weight: 600;
  font-size: 17px;
  pointer-events: none;
}

.row { display: flex; align-items: center; gap: 16px; margin-top: 14px; }

button {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  height: 38px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:active { transform: scale(0.97); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.55;
  padding-left: 4px;
}
.btn-primary { background: var(--ink); color: var(--bg); font-weight: 600; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary.copied { background: var(--accent); color: #fff; }
.btn-primary[disabled] { opacity: 0.6; cursor: wait; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); }

.example {
  background: none;
  border: none;
  padding: 0;
  height: auto;
  color: var(--muted);
  font-weight: 400;
}
.example:hover { color: var(--accent); }


#output, #cite { margin-top: 36px; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.summary { font-family: var(--mono); font-size: 12.5px; color: var(--accent); margin-bottom: 14px; }
.summary .conf {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 99px;
  padding: 1px 9px;
  margin-left: 8px;
  font-weight: 600;
}


.steps { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 7px; }
.steps li {
  display: flex;
  gap: 9px;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0;
  transform: translateX(-6px);
  animation: step-in 0.22s ease forwards;
}
.steps li::before { content: "✓"; color: var(--accent); font-weight: 600; }
.steps li.warn::before { content: "⚠"; color: var(--warn-ink); }
.steps li.warn { color: var(--warn-ink); }
@keyframes step-in { to { opacity: 1; transform: none; } }

.skeleton { display: grid; gap: 10px; padding: 8px 0; }
.skeleton i {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, var(--bg) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
.skeleton i:nth-child(2) { width: 72%; }
.skeleton i:nth-child(3) { width: 48%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

#table-picker {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  padding: 9px 12px;
  margin-bottom: 16px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#tabs, #style-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); }
#tabs button, #style-tabs button {
  background: none;
  border: none;
  border-radius: 0;
  height: auto;
  padding: 9px 2px 11px;
  color: var(--muted);
  font-weight: 400;
  font-size: 13.5px;
  box-shadow: inset 0 -2px 0 transparent;
}
#tabs button[aria-pressed="true"], #style-tabs button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}
#tabs button:hover, #style-tabs button:hover { color: var(--ink); }

#result {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  padding: 20px 0;
  overflow-x: auto;
  white-space: pre;
}


.table-scroll { overflow-x: auto; padding: 4px 0 8px; }
.table-preview {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.table-preview th, .table-preview td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-preview th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface);
  position: sticky;
  top: 0;
}
.table-preview tbody tr:nth-child(even) { background: var(--accent-soft); }
.table-preview tbody tr:hover { background: var(--accent-soft); }
.table-preview tbody tr:last-child td { border-bottom: none; }


.copyas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.copyas-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  height: auto;
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.copyas-btn small {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 500;
}
.copyas-btn b { font-size: 13.5px; font-weight: 600; }
.copyas-btn:hover { border-color: var(--accent); }
.copyas-btn.copied { border-color: var(--accent); background: var(--accent-soft); }
.copyas-btn.copied b { color: var(--accent); }
.copyas-btn.copied small { color: var(--accent); }
.copyas-btn.copied b::after { content: " ✓"; }
.copyas-btn.ghost { background: transparent; box-shadow: none; }

#warnings:not(:empty) { margin-top: 20px; display: grid; gap: 8px; }
.warning {
  font-size: 13px;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 9px 13px;
}

#error {
  margin-top: 36px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
  color: var(--warn-ink);
  font-size: 14px;
  animation: rise 0.35s ease both;
}

#cite { border-top: 1px solid var(--line); padding-top: 22px; }
#citation { font-size: 15px; line-height: 1.65; padding: 20px 0; max-width: 60ch; }
.row.actions button { height: 38px; }

#bib:not(:empty) { margin-top: 24px; }
#bib h2 { font-family: var(--mono); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.bib-item { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 14px; }
.bib-item span { flex: 1; }
.bib-item button {
  background: none; border: none; height: auto; padding: 0 4px;
  color: var(--muted); font-weight: 400;
}
.bib-item button:hover { color: var(--warn-ink); }

.foot { margin-top: 64px; font-size: 12.5px; color: var(--muted); text-align: center; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .col { padding: 24px 16px 64px; }
  .copyas { display: grid; grid-template-columns: 1fr 1fr; }
  .row { flex-wrap: wrap; }
}

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