:root {
  --bg: #f6f7f9;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --brand: #2364aa;
  --brand-dark: #174a7f;
  --ok: #12715b;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  padding: 10px 14px;
}

button:hover {
  background: var(--brand-dark);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.api-field {
  display: grid;
  gap: 6px;
  width: min(480px, 40vw);
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav {
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav.active,
.nav:hover {
  background: #e8f1fb;
  color: var(--brand-dark);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  min-height: 680px;
}

.hidden {
  display: none !important;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.grid-form button {
  grid-column: span 2;
}

.book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.book-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.book-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 20px;
}

.stack {
  display: grid;
  gap: 14px;
}

.card-form {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.card-form h3 {
  margin: 0;
  font-size: 16px;
}

.tree {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 360px;
}

.tree-item {
  padding: 8px 0 8px var(--indent);
  border-bottom: 1px solid #edf0f5;
}

.tree-id {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.hint {
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.csv-input {
  width: 100%;
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.result {
  min-height: 96px;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.2);
}

@media (max-width: 900px) {
  .topbar,
  .layout,
  .split,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .layout {
    display: grid;
  }

  .api-field {
    width: 100%;
  }
}
