:root {
  --ink: #14213D;
  --paper: #FBF9F4;
  --card: #FFFFFF;
  --accent: #E3B23C;
  --accent-ink: #4A3907;
  --muted: #6B7280;
  --line: #E4DFD3;
  --danger: #B3261E;
  --danger-bg: #FBEAE9;
  --info-bg: #EFF3F8;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  line-height: 1.5;
}

h1, h2 {
  font-family: 'Fraunces', serif;
  margin: 0;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.topbar h1 { font-size: 2rem; font-weight: 600; }

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.key-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 6px;
}

.credits {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
  cursor: default;
}

.credits strong { color: var(--ink); }

.credits.credits-low strong { color: var(--danger); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-on { background: #3E8853; }
.dot-off { background: #C4C0B4; }

.link-btn {
  background: none;
  border: none;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
}

.key-panel, .search-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.key-row, .search-row { display: flex; gap: 10px; }

input[type="text"], input[type="password"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
  transition: opacity 0.15s ease;
}

button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.hint { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted); }

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.banner-error { background: var(--danger-bg); color: var(--danger); }
.banner-info { background: var(--info-bg); color: var(--ink); }

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
}

.tree-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.tree-header h2 { font-size: 1.25rem; font-weight: 600; }

.tree-hint {
  margin: 6px 0 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

#paaTree {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 0.95rem;
}

/* Restyle jsTree's default theme to match the app's palette */
#paaTree .jstree-anchor {
  color: var(--ink);
  height: auto;
  line-height: 1.4;
  padding: 4px 6px;
  white-space: normal;
}

#paaTree .jstree-checked > .jstree-anchor,
#paaTree .jstree-anchor.jstree-checked {
  background: rgba(227, 178, 60, 0.18);
  border-radius: 6px;
}

#paaTree .jstree-hovered { background: var(--paper); border-radius: 6px; }

.collected {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: sticky;
  top: 24px;
}

.collected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}

.collected-header h2 { font-size: 1.1rem; font-weight: 600; }

.collected-header button {
  background: var(--ink);
  color: var(--paper);
  padding: 6px 12px;
  font-size: 0.8rem;
}

.collected-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.collected-list li {
  font-size: 0.88rem;
  padding: 8px 10px;
  background: var(--paper);
  border-radius: 6px;
  border: 1px solid var(--line);
}

.empty-note { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
