:root {
  color-scheme: light;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-hover: #eef0f9;
  --border: rgba(15, 25, 35, 0.08);
  --text: #1a2330;
  --text-muted: rgba(26, 35, 48, 0.66);
  --highlight: #375dfb;
  --highlight-soft: rgba(55, 93, 251, 0.12);
  --shadow: 0 18px 40px rgba(20, 35, 90, 0.08);
}

body.dark {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1e2530;
  --border: rgba(240, 246, 252, 0.08);
  --text: #f0f6fc;
  --text-muted: rgba(240, 246, 252, 0.68);
  --highlight: #6bb6ff;
  --highlight-soft: rgba(107, 182, 255, 0.15);
  --shadow: 0 16px 48px rgba(4, 12, 35, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  transition: transform 0.3s ease;
  justify-content: space-between;
  padding: 0.5rem 2.5rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg), transparent 15%);
}

.topbar.is-hidden {
  transform: translateY(-100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-letter {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--highlight-soft);
  color: var(--highlight);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.875rem;
}

.nav-links a {
  font-weight: 600;
  color: var(--text-muted);
}

.nav-links a:hover {
  color: var(--highlight);
}

.theme-toggle {
  border: 0;
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, background 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  background: var(--surface-hover);
}

.theme-toggle span {
  font-size: 1.15rem;
}

.app {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  padding: 1.5rem max(3vw, 1.5rem);
  align-items: start;
}

.sidebar-toggle {
  display: none;
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 50px;
  height: fit-content;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}

.search-panel {
  display: flex;
  flex-direction: column;
}

.search-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  padding: 0.5rem 0.9rem;
}

.search-input-wrapper:focus-within {
  border-color: var(--highlight);
  box-shadow: 0 0 0 4px var(--highlight-soft);
}

#search-input {
  flex: 1;
  min-width: 0;
  font-size: 1.4rem;
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#search-input::placeholder,
#filter-input::placeholder {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#search-clear {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.35rem;
  line-height: 1;
  transition: color 160ms ease;
}

#search-clear:hover {
  color: var(--highlight);
}

.search-helper {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filters-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 0.4rem 0.75rem;
}

.filter-input-wrapper:focus-within {
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px var(--highlight-soft);
}

#filter-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-helper {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.5rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--highlight-soft);
  color: var(--highlight);
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.filter-chip:hover,
.filter-chip:focus-visible {
  background: var(--highlight);
  color: #fff;
}

.filter-chip-label {
  font-weight: 600;
}

.filter-chip-count {
  min-width: 1.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--highlight), transparent 60%);
  color: var(--highlight);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
}

.filter-chip-close {
  font-size: 0.9rem;
  line-height: 1;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.suggestion-column {
  --accent: var(--highlight);
  --accent-soft: var(--highlight-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 160ms ease;
}

.suggestion-column:hover {
  transform: translateY(-4px);
}

.suggestion-column.is-focused {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft);
}

.suggestion-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface), var(--highlight) 4%);
}

.suggestion-header svg {
  width: 24px;
  height: 24px;
  fill: var(--accent);
}

.suggestion-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
}

.suggestions-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: all 160ms ease;
}

.copy-button {
  background: none;
  border: none;
  padding: 0.35rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 160ms ease, opacity 160ms ease;
  opacity: 0.6;
  margin-left: auto;
}

.copy-button:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

body.dark .copy-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.copy-button svg {
  width: 16px;
  height: 16px;
  fill: var(--accent);
}

.copy-button.copy-success svg {
  fill: #22c55e;
}

.copy-button.copy-error svg {
  fill: #ef4444;
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0;
}

.suggestion-item {
  display: flex;
  align-items: center;
  padding: 0.55rem 1.25rem;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
  position: relative;
}

.suggestion-item button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  color: inherit;
}

.suggestion-label {
  flex: 1;
}

.suggestion-highlight {
  display: inline;
  background: color-mix(in srgb, var(--accent), transparent 82%);
  color: var(--accent);
  font-weight: 600;
  border-radius: 4px;
  padding: 0 0.2rem;
}

.suggestion-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.engine-matches {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.engine-match-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.suggestion-count {
  min-width: 1.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.suggestion-item:hover,
.suggestion-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.suggestion-item.is-expanded {
  color: var(--accent);
  font-weight: 600;
}

.suggestion-item button:hover {
  color: inherit;
}

.suggestion-item .open-icon {
  opacity: 0;
  transition: opacity 160ms ease;
  font-size: 1.1rem;
  color: inherit;
  line-height: 1;
}

.suggestion-item:hover .open-icon,
.suggestion-item.is-active .open-icon {
  opacity: 1;
}

.suggestion-item.is-loading .open-icon {
  opacity: 0;
}

.suggestion-item.is-loading .suggestion-meta::before {
  content: "";
  margin-right: 0.35rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: suggestion-spin 0.8s linear infinite;
}

.suggestion-item.has-error {
  color: #c3382a;
}

body.dark .suggestion-item.has-error {
  color: #ff8477;
}

.suggestion-status {
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.suggestion-status--loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.suggestion-status--loading::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  animation: suggestion-spin 0.8s linear infinite;
}

.suggestion-status--error {
  color: #c3382a;
}

body.dark .suggestion-status--error {
  color: #ff8477;
}

@keyframes suggestion-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.master-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.master-copy-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--highlight);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms ease;
  box-shadow: var(--shadow);
}

.master-copy-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.master-copy-button svg {
  fill: currentColor;
}

.master-copy-button.copy-success {
  background: #10b981;
}

.master-copy-button.copy-error {
  background: #ef4444;
}

.shortcuts-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shortcuts-panel h3 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.shortcut-item kbd {
  min-width: 1.75rem;
}

.info-panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.info-panel p {
  margin: 0;
  color: var(--text-muted);
}

.info-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.info-list li {
  color: var(--text);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.shortcut-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shortcut-card h3 {
  margin: 0;
  font-size: 1rem;
  display: flex;
  gap: 0.35rem;
}

kbd {
  padding: 0.2rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  font-size: 0.85rem;
  font-weight: 600;
}

.footer {
  padding: 2rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg), transparent 10%);
}

.feedback-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--highlight);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 960px) {
  .topbar {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 1.5rem;
  }

  .nav-links {
    gap: 1rem;
  }

  .search-box {
    padding: 1.5rem;
  }
}

@media (max-width: 720px) {
  body {
    min-height: 100vh;
  }

  .app {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .left-panel {
    position: static;
    max-height: none;
    order: 2;
  }

  .search-box,
  .master-actions,
  .shortcuts-panel {
    box-shadow: none;
  }

  .suggestions-grid {
    grid-template-columns: 1fr;
    order: 1;
  }

  .suggestion-column {
    border-radius: 16px;
  }

  .topbar {
    gap: 0.75rem;
  }
}
