:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-muted: #666e7d;
  --border: #e2e5ea;
  --accent: #2f6fed;
  --accent-weak: #eaf1ff;
  --accent-strong: #1d4ed8;
  --success-bg: #eafbf1;
  --success-text: #0f7a3d;
  --warn-bg: #fff8e6;
  --warn-text: #8a5a00;
  --warn-border: #f3dd9e;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #eef0f4;
    --text-muted: #97a0b3;
    --border: #2a2e38;
    --accent: #5b8def;
    --accent-weak: #1b2740;
    --accent-strong: #7ea6f5;
    --success-bg: #103322;
    --success-text: #4ade80;
    --warn-bg: #2a2210;
    --warn-text: #e8c260;
    --warn-border: #4a3d17;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 68px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0;
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.topnav-logo {
  display: block;
  height: 24px;
  width: auto;
}

.menu {
  position: relative;
}

.menu-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
}

.menu-btn span {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 16px;
  height: 1.5px;
  margin: -0.75px 0 0 -8px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.25s ease;
}

.menu-btn span:nth-child(1) {
  transform: translateY(-4px);
}

.menu-btn span:nth-child(2) {
  transform: translateY(3px);
}

.menu-btn[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg);
}

.menu-btn[aria-expanded="true"] span:nth-child(2) {
  transform: rotate(-45deg);
}

.menu-panel {
  position: absolute;
  top: 44px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  z-index: 10;
}

.menu-panel[hidden] {
  display: none;
}

.menu-panel a {
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.menu-panel a:hover {
  background: var(--accent-weak);
  color: var(--accent);
}

.hero {
  text-align: center;
  margin: 12px 0 28px;
}

.hero h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}

.subtitle strong {
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.combobox {
  position: relative;
}

.combobox input {
  width: 100%;
  font-size: 16px;
  padding: 12px 40px 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.combobox input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.combobox input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-btn:hover {
  background: var(--border);
}

.clear-btn[hidden] {
  display: none;
}

.options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.options li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.3;
}

.options li mark {
  background: var(--accent-weak);
  color: var(--accent-strong);
  border-radius: 3px;
}

.options li.active,
.options li:hover {
  background: var(--accent-weak);
}

.options li.empty {
  color: var(--text-muted);
  cursor: default;
}

.options li.empty:hover {
  background: transparent;
}

.reset-btn {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.reset-btn:hover {
  text-decoration: underline;
}

.result {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: rise 0.25s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-flow {
  display: flex;
  align-items: center;
  gap: 14px;
}

.result-block {
  flex: 1;
  min-width: 0;
}

.result-arrow {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
  /* the → glyph's arrowhead carries more visual weight on its right side,
     so its bounding box being centered still reads as shifted right;
     nudge left to compensate for that optical imbalance. */
  transform: translateX(-2px);
}

.result-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.result-block.old .result-tag {
  background: var(--border);
  color: var(--text-muted);
}

.result-block.new .result-tag {
  background: var(--success-bg);
  color: var(--success-text);
}

.result-block p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.result-block.old p {
  color: var(--text-muted);
}

.result-block.new p {
  color: var(--text);
  font-weight: 600;
}

.copy-btn {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.copy-btn:hover {
  background: var(--accent-strong);
}

.copy-btn.copied {
  background: var(--success-text);
}

.split-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  color: var(--warn-text);
  font-size: 13px;
  line-height: 1.5;
}

.status {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 20px 0 0;
}

.status.error {
  color: #dc2626;
}

.about {
  margin-top: 40px;
  padding-top: 8px;
}

.about h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 28px 0 10px;
  letter-spacing: -0.01em;
}

.about h2:first-child {
  margin-top: 0;
}

.about > p {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.6;
  margin: 0;
}

.faq-group {
  border: none;
}

.faq-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  list-style: none;
}

.faq-group > summary::-webkit-details-marker {
  display: none;
}

.faq-item {
  border-top: 1px solid var(--border);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after,
.faq-group > summary::after {
  content: "";
  display: inline-block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background-color: var(--text-muted);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='black'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m8.25 4.5 7.5 7.5-7.5 7.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='black'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m8.25 4.5 7.5 7.5-7.5 7.5'/%3E%3C/svg%3E");
}

.faq-item[open] summary::after,
.faq-group[open] > summary::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='black'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='black'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
}

.faq-item p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 16px;
}

.faq-item a {
  color: var(--accent);
  text-decoration: none;
}

.faq-item a:hover {
  text-decoration: underline;
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 13px 20px;
  background: var(--bg);
  text-align: center;
}

.footer p {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 6px;
}

.footer p:last-child {
  margin-bottom: 0;
}

.footer-credit {
  font-size: 13.5px !important;
  color: var(--text) !important;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.api-page h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 8px;
  letter-spacing: -0.02em;
}

.api-page > p.lede {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 32px;
}

.api-page h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 36px 0 4px;
  letter-spacing: -0.01em;
}

.api-page > p {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.endpoint {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}

.endpoint-path {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  flex-wrap: wrap;
}

.method-badge {
  display: inline-block;
  background: var(--accent-weak);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.endpoint-desc {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 10px 0 0;
}

.endpoint pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0 0;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
}

.endpoint pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
}

.endpoint .pre-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 14px 0 0;
}

.endpoint .pre-label:first-of-type {
  margin-top: 4px;
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 0;
  font-size: 13.5px;
}

.params-table th, .params-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.params-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.params-table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---- generic buttons (excel tool + reusable elsewhere) ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-link {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.btn-link:hover {
  text-decoration: underline;
}

/* ---- excel tool: dropzone ---- */

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.dropzone p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.dropzone-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-weak);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
}

.file-info .file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.file-info button:hover {
  color: var(--text);
}

.file-info[hidden] {
  display: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stack[hidden] {
  display: none;
}

/* ---- excel tool: mapping + select ---- */

.field select {
  width: 100%;
  font-size: 15px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field select:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* ---- excel tool: preview table ---- */

.preview-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.preview-table th, .preview-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.preview-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preview-table tr:last-child td {
  border-bottom: none;
}

/* ---- excel tool: progress ---- */

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.progress-label {
  margin: 8px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- excel tool: validation results ---- */

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.result-stat {
  text-align: center;
  padding: 14px 8px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.result-stat .num {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

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

.result-stat.ok {
  background: var(--success-bg);
  border-color: transparent;
}

.result-stat.ok .num {
  color: var(--success-text);
}

.result-stat.error .num {
  color: #dc2626;
}

.error-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 0;
}

.error-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.error-item:last-child {
  border-bottom: none;
}

.error-item strong {
  color: var(--text);
}

.error-more {
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 480px) {
  .page { padding: 0 16px 24px; }
  .hero h1 { font-size: 24px; }
  .api-page h1 { font-size: 22px; }
  .card { padding: 18px; }
  .result-flow { flex-direction: column; align-items: stretch; }
  .result-arrow { transform: rotate(90deg); align-self: center; }
  .endpoint { padding: 16px; }
  .params-table { font-size: 12.5px; }
  .mapping-grid { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: 1fr; }
}
