/* Applied AI Mind Map — Chart-table layout & styling */
:root {
  --paper: #eef1f4;
  --paper-dot: rgba(23, 38, 58, 0.08);
  --surface: #ffffff;
  --surface-hover: #f6f8fa;
  --ink: #17263a;
  --muted: #5b6b7e;
  --line: #cfd7e0;
  --accent: #b7791f;
  --accent-soft: rgba(183, 121, 31, 0.12);
  --shadow: 0 8px 24px rgba(16, 24, 34, 0.12);
  --font-display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1720;
    --paper-dot: rgba(230, 236, 242, 0.07);
    --surface: #17212e;
    --surface-hover: #1f2c3c;
    --ink: #e6ecf2;
    --muted: #9aa9ba;
    --line: #2a394b;
    --accent: #e0a94a;
    --accent-soft: rgba(224, 169, 74, 0.15);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0f1720;
  --paper-dot: rgba(230, 236, 242, 0.07);
  --surface: #17212e;
  --surface-hover: #1f2c3c;
  --ink: #e6ecf2;
  --muted: #9aa9ba;
  --line: #2a394b;
  --accent: #e0a94a;
  --accent-soft: rgba(224, 169, 74, 0.15);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.015em;
}

.stats-pill {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
}

#search {
  width: 100%;
  font: 400 13.5px var(--font-body);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 32px 6px 11px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 1.5;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  list-style: none;
  margin: 0;
  padding: 4px;
  z-index: 40;
}

.search-results[hidden] {
  display: none;
}

.search-results li {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.search-results li:hover,
.search-results li.active {
  background: var(--surface-hover);
}

.search-results .sr-topic {
  font-weight: 600;
  font-size: 13.5px;
  display: block;
}

.search-results .sr-path {
  font-size: 11.5px;
  color: var(--muted);
  display: block;
}

.search-results .sr-note {
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

.search-results .sr-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px;
  cursor: default;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.btn-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.btn-group button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

.btn-group button:last-child {
  border-right: 0;
}

button {
  font: 500 12.5px var(--font-body);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
}

button:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

button:focus-visible,
.crumb:focus-visible,
.kid-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Main workspace */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

#map {
  flex: 1;
  min-width: 0;
  height: 100%;
  background-color: var(--paper);
  background-image: radial-gradient(var(--paper-dot) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Detail aside */
aside {
  width: 340px;
  flex: none;
  overflow-y: auto;
  padding: 16px 18px 20px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.crumb {
  background: transparent;
  border: 0;
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.crumb:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.crumb-sep {
  opacity: 0.5;
  user-select: none;
}

.node-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 4px;
}

.count-meta {
  font-size: 12px;
  color: var(--muted);
}

#note {
  margin: 2px 0 4px;
  color: var(--ink);
}

.node-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.node-actions button {
  font-size: 12px;
  padding: 4px 9px;
}

.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 6px 0 0;
}

#kids {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kid-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: normal;
}

.kid-btn:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.kid-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.kid-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
}

.kid-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* MindElixir node typography */
me-tpc {
  font-family: var(--font-body);
  cursor: pointer;
}

me-root me-tpc {
  font-family: var(--font-display);
  font-weight: 700;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }
  main {
    flex-direction: column;
    min-height: calc(100vh - 110px);
  }
  #map {
    min-height: 55vh;
  }
  aside {
    width: auto;
    max-height: 44vh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .controls {
    margin-left: 0;
  }
  .search-wrap {
    max-width: none;
    order: 3;
    flex-basis: 100%;
  }
}
