:root {
  color-scheme: dark;
  --bg: #101218;
  --panel: #171b24;
  --line: #2a3140;
  --text: #f4f6fb;
  --muted: #8d94a6;
  --red: #e8453c;
  --red-deep: #c83730;
  --gold: #f4c14a;
  --chip: #222836;
  --chip-on: #2d3548;
  --focus: #7aa2ff;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 392px;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.app {
  padding: 14px 14px 12px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.site-picker select {
  appearance: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 26px 6px 10px;
  font: inherit;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 11px, calc(100% - 8px) 11px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 8px 0 10px;
}

.search-wrap:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.18);
}

.search-icon {
  color: var(--muted);
  font-size: 16px;
}

#q {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 11px 0;
  outline: none;
}

.icon-btn,
.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.icon-btn:hover,
.text-btn:hover {
  color: var(--text);
  background: var(--chip);
}

.card-meta {
  margin-top: 8px;
}

.set-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 10px;
}

.set-field span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 0 0 auto;
}

#setNo {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 8px 0;
  outline: none;
}

.set-field:focus-within {
  border-color: var(--focus);
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.type-row .pill {
  padding: 4px 8px;
  font-size: 12px;
}

.pill.on {
  border-color: var(--gold);
  background: #2a2416;
  color: var(--gold);
}

.chip.set {
  border-color: rgba(122, 162, 255, 0.45);
}

.preview {
  margin-top: 10px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 8px 10px 10px;
  min-height: 62px;
}

.preview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-height: 28px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 8px 3px 9px;
  max-width: 100%;
}

.chip b {
  font-weight: 650;
}

.chip small {
  color: var(--muted);
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 1px;
}

.chip.pokemon {
  border-color: rgba(232, 69, 60, 0.45);
}

.chip.term {
  border-color: rgba(244, 193, 74, 0.4);
}

.empty-chip {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

button.primary,
button.ghost {
  border-radius: 11px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button.primary {
  flex: 1;
  border: 0;
  background: var(--red);
  color: white;
}

button.primary:hover {
  background: var(--red-deep);
}

button.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

button.ghost {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.toggles {
  display: flex;
  gap: 12px;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 8px;
  background: var(--panel);
  padding: 3px;
  border-radius: 11px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.tab.active {
  background: var(--chip-on);
  color: var(--text);
}

.panel {
  min-height: 220px;
  max-height: 340px;
  overflow: auto;
}

.hint {
  color: var(--muted);
  margin: 8px 2px 10px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 12px;
  padding: 8px 9px;
  cursor: pointer;
  font: inherit;
}

.row:hover,
.row.active {
  border-color: #3d475c;
  background: #1d2330;
}

.dex {
  color: var(--gold);
  font-size: 11px;
  width: 38px;
  flex: 0 0 auto;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-main b {
  display: block;
  font-size: 14px;
}

.row-main span {
  color: var(--muted);
  font-size: 11px;
}

.cat {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 9px;
  cursor: pointer;
  font: inherit;
}

.pill:hover {
  border-color: var(--gold);
}

.section + .section {
  margin-top: 12px;
}

.section h2 {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: #111;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #2c3344;
  border-radius: 99px;
}
