:root {
  --ink: #262730;
  --muted: #6b7280;
  --line: #d9dce3;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #2c82c9;
  --accent-soft: #eaf2fb;
  --ok: #1e7e34;
  --warn: #8a6d3b;
  --err: #d93025;
  /* Multi-script stack: Noto families are unicode-range webfonts loaded in
     index.html; the browser walks the list per glyph, so Cyrillic, Gujarati,
     Hebrew, Arabic etc. render consistently instead of falling back to
     whatever system fonts happen to be installed. */
  --font-stack:
    "Noto Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", "Noto Sans Arabic",
    "Noto Sans Hebrew", "Noto Sans Thai", "Noto Sans Armenian", "Noto Sans Georgian",
    "Noto Sans Tamil", "Noto Sans Telugu", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-stack);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}
header, main, footer { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
header { padding-top: 1.5rem; }
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
footer { padding: 2rem 1rem 3rem; color: var(--muted); font-size: 0.85rem; }

.hidden { display: none !important; }
.status { color: var(--muted); font-size: 0.9rem; min-height: 1.2em; }

/* Search */
.search-bar { display: flex; gap: 0.5rem; margin: 1rem 0 0.4rem; }
.search-bar input[type="search"] {
  flex: 1; padding: 0.6rem 0.8rem; font-size: 1rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card);
}
.search-bar button, .details button, .own-layout button {
  padding: 0.6rem 1.1rem; font-size: 0.95rem; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.search-bar button:hover, .details button:hover, .own-layout button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: wait; }

/* Results: list + side preview */
.results { display: flex; gap: 10px; margin-top: 0.75rem; align-items: stretch; }
.list-pane {
  width: 40%; min-width: 230px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; overflow-y: auto; max-height: 520px;
}
.item { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid #f0f2f5; }
.item:last-child { border-bottom: none; }
.item:hover, .item.hovered { background: var(--accent-soft); }
.item.selected { background: #d7e7f8; }
.item .label { font-weight: 600; }
.item .sub { font-size: 0.78rem; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 1px; }
.tag {
  font-size: 0.65rem; padding: 1px 7px; border-radius: 8px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.tag.layout { background: #dcfce7; color: #166534; }
.tag.keyman { background: #e0e7ff; color: #3730a3; }
.preview-pane {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  min-height: 520px; max-height: 520px; overflow-y: auto; position: relative;
}
.preview-pane .placeholder, .preview-pane .loading {
  color: var(--muted); padding: 1.1rem; font-size: 0.9rem; line-height: 1.5;
}
.preview-pane .loading { color: var(--accent); }
.spin {
  display: inline-block; width: 12px; height: 12px; border: 2px solid #b7d3ee;
  border-top-color: var(--accent); border-radius: 50%; margin-right: 7px;
  animation: spin 0.8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge {
  position: absolute; top: 8px; right: 10px; background: #ffffffdd; border: 1px solid var(--line);
  border-radius: 10px; padding: 2px 9px; font-size: 0.75rem; color: var(--muted); z-index: 5;
}

/* Board previews: override the viewer's Latin-only font stack (higher
   specificity than its injected .aac-board-viewer rule) so key labels in
   Cyrillic, Gujarati, Arabic etc. render with the loaded Noto fonts. */
.preview-pane .aac-board-viewer,
.modal-body .aac-board-viewer,
.inline-preview .aac-board-viewer {
  font-family: var(--font-stack);
}

/* Details */
.details {
  margin-top: 1.5rem; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 1rem 1.2rem;
}
.details h2 { font-size: 1.15rem; margin: 0 0 0.3rem; }
.details .hint { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0 0.9rem; }
.details .row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 0.6rem 0; }
.details label.inline { display: flex; gap: 0.4rem; align-items: center; font-size: 0.92rem; }
.details select { padding: 0.45rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.92rem; max-width: 340px; }
.details .ok { color: var(--ok); font-size: 0.9rem; }
.details .verify-ok { color: var(--ok); }
.details .verify-bad { color: var(--err); }
.warnings { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.83rem; color: var(--warn); }
.inline-preview {
  margin-top: 0.9rem; border: 1px solid var(--line); border-radius: 8px;
  min-height: 200px; overflow: auto; background: #fafafa;
}
a.download-link {
  display: inline-block; background: #21a354; color: #fff; text-decoration: none;
  padding: 0.55rem 1.1rem; border-radius: 8px; font-size: 0.95rem;
}
a.download-link:hover { filter: brightness(1.07); }

/* Own layout */
.own-layout { margin-top: 1.6rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1.2rem; }
.own-layout summary { cursor: pointer; font-weight: 600; }
.own-layout p { color: var(--muted); font-size: 0.88rem; }
.own-layout-name { font-weight: 600; margin-top: 0.5rem; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: #00000066; display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal {
  background: var(--card); border-radius: 12px; max-width: 980px; width: 100%;
  max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 1.05rem; margin: 0; }
.modal-head button {
  border: none; background: transparent; font-size: 1.1rem; cursor: pointer;
  color: var(--muted); padding: 0.2rem 0.5rem; border-radius: 6px;
}
.modal-head button:hover { background: var(--accent-soft); color: var(--ink); }
.modal-body { padding: 0.9rem; overflow-y: auto; min-height: 480px; }
.modal-body .loading { color: var(--accent); padding: 1rem; }

@media (max-width: 760px) {
  .results { flex-direction: column; }
  .list-pane, .preview-pane { width: 100%; min-height: unset; }
  .preview-pane { min-height: 380px; max-height: 420px; }
}
