:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface2: #222733;
  --border: #2c3342;
  --text: #e8eaef;
  --muted: #9aa3b5;
  --accent: #8b5cf6;
  --accent-press: #7c3aed;
  --ok: #34d399;
  --radius: 12px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100%;
}
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100dvh;
  overflow-x: hidden;
  max-width: 100%;
}
.app {
  width: 100%;
  max-width: min(720px, 100%);
  margin: 0 auto;
  padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
}
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  min-width: 0;
}
h1 {
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.02em;
  min-width: 0;
  overflow-wrap: anywhere;
}
.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: calc(var(--radius) + 2px);
  padding: 14px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: visible;
}
.search-box {
  position: relative;
  z-index: 30;
  min-width: 0;
  width: 100%;
}
.search {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.search:focus { border-color: var(--accent); }
.dropdown {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #141821;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  -webkit-overflow-scrolling: touch;
}
.dropdown[hidden] { display: none; }
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  text-align: left;
  min-height: var(--tap);
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.card:active { transform: scale(0.99); }
.card[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.card-body { min-width: 0; flex: 1; overflow: hidden; }
.name {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag {
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty {
  color: var(--muted);
  padding: 12px 8px;
  text-align: center;
  font-size: 0.85rem;
}
.miss {
  width: 100%;
  min-height: var(--tap);
  border: none;
  border-radius: var(--radius);
  background: #7c3aed;
  color: white;
  font-weight: 650;
  font-size: 0.9rem;
  cursor: pointer;
}
.miss:disabled {
  cursor: default;
  background: var(--surface2);
  color: var(--ok);
}
.placeholder {
  color: var(--muted);
  padding: 28px 8px;
  text-align: center;
  font-size: 0.9rem;
}
.detail {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detail-top { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}
.label { width: 100%; color: var(--muted); font-size: 0.75rem; margin-bottom: 2px; }
.chip {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface2));
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: linear-gradient(transparent, var(--surface) 35%);
  min-width: 0;
  max-width: 100%;
}
.btn {
  flex: 1 1 140px;
  min-width: 0;
  min-height: var(--tap);
  border: none;
  border-radius: var(--radius);
  background: #7c3aed;
  color: white;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}
.btn:active { background: #6d28d9; }
.btn.copied { background: #047857; }
.btn.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:active { background: var(--border); }
.code {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: #0b0d11;
  border: 1px solid var(--border);
  color: #d7dde8;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  overflow-x: auto;
  overflow-wrap: normal;
  white-space: pre;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.code .flash {
  margin: 0;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.4);
  color: #ddd6fe;
  font: inherit;
  animation: flash-out 1s ease forwards;
}
@keyframes flash-out {
  0% {
    background: rgba(139, 92, 246, 0.5);
    color: #ede9fe;
  }
  60% {
    background: rgba(139, 92, 246, 0.28);
    color: #ddd6fe;
  }
  100% {
    background: transparent;
    color: inherit;
  }
}
.more {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  min-width: 0;
}
.more-body { margin-top: 10px; min-width: 0; }
.aux-label { margin-top: 8px; }
.more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 36px;
  display: flex;
  align-items: center;
  list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  border: 1px solid var(--border);
  color: var(--ok);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
  z-index: 40;
  max-width: calc(100vw - 24px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.catalog {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.catalog a {
  display: block;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 10px 12px;
}
