:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1f2328;
  --text-secondary: #656d76;
  --border: #d0d7de;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --green-dim: #1a7f37;
  --red: #cf222e;
  --red-dim: #cf222e;
  --yellow: #9a6700;
  --radius: 8px;
  --accent-focus: rgba(9,105,218,0.15);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --green-dim: #238636;
  --red: #f85149;
  --red-dim: #da3633;
  --yellow: #d29922;
  --accent-focus: rgba(88,166,255,0.15);
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ===== Header ===== */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.icon-button svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-button:hover { border-color: var(--accent); color: var(--accent); }

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.intro p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.language-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.language-button svg { width: 16px; height: 16px; stroke: currentColor; }
.language-button:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Single Query ===== */
form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

label {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

input[type="text"] {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus);
}
input[type="text"]::placeholder { color: var(--text-secondary); }

button[type="submit"], #batch-check-button {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--green-dim);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
button[type="submit"]:hover:not(:disabled), #batch-check-button:hover:not(:disabled) {
  background: var(--green);
}
button:disabled { opacity: 0.5; cursor: wait; }

/* ===== Single Result ===== */
#result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
}

dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
}
dt { color: var(--text-secondary); font-weight: 500; }
dd { font-weight: 600; word-break: break-word; }

.age-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.age-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.age-toggle svg { width: 14px; height: 14px; stroke: currentColor; }
.age-toggle:hover { border-color: var(--accent); color: var(--accent); }

.status {
  min-height: 1.2em;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.status.error { color: var(--red); }
.status.success { color: var(--green); }

.hint {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footnote {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

.hidden { display: none; }

/* ===== Loading ===== */
@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

.skeleton {
  display: inline-block;
  height: 1em;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
  min-width: 80px;
}

.skeleton.wide { min-width: 200px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

button .spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* ===== Batch Section ===== */
.batch-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.batch-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.batch-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.batch-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.batch-input-area {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.batch-input-area label,
.batch-output-col label,
.batch-log-area label {
  position: static;
  width: auto; height: auto;
  padding: 0; margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.batch-output-col label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.batch-output-col label::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}

.batch-output-col:first-child label::before { background: var(--green); }
.batch-output-col:last-child label::before { background: var(--yellow); }

textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 400px;
  transition: border-color 0.15s;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus);
}
textarea::placeholder { color: var(--text-secondary); }
textarea[readonly] { cursor: default; resize: none; }

.batch-output-area {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  gap: 12px;
}

.batch-output-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.batch-output-col textarea {
  min-height: 400px;
}

.copy-btn, .batch-output-col button {
  align-self: flex-end;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.copy-btn:hover, .batch-output-col button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Log ===== */
.batch-log-area {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.batch-log {
  width: 100%;
  min-height: 100px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.batch-log .log-line { padding: 1px 0; }
.batch-log .log-error { color: var(--red); }
.batch-log .log-success { color: var(--green); }

#batch-status {
  margin-top: 10px;
}

/* ===== Export ===== */
.batch-export-area {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.export-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.export-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  main { padding: 24px 16px; }
  h1 { font-size: 1.4rem; }
  .batch-layout { flex-direction: column; }
  .batch-input-area { flex: 1 1 0; }
  .batch-output-area { flex-direction: column; }
  textarea { min-height: 200px; }
  .batch-output-col textarea { min-height: 200px; }
  form { flex-wrap: wrap; }
  button[type="submit"] { width: 100%; }
}
