:root {
  --bg: #f3f5fb;
  --text: #0f172a;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --border: #e2e8f0;
  --muted: #6b7280;
  --tag-bg: #eef2ff;
  --tag-text: #312e81;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --surface: #ffffff;
  --gradient: radial-gradient(circle at 20% 20%, #e0e7ff 0, transparent 35%),
    radial-gradient(circle at 80% 0%, #c7d2fe 0, transparent 25%),
    #f3f5fb;
  --danger: #dc2626;
  --code-border: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans JP', sans-serif;
  background: var(--gradient);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.site-header {
  background: linear-gradient(135deg, #312e81, #4338ca, #2563eb);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 28px 0 36px;
  box-shadow: 0 10px 30px rgba(49, 46, 129, 0.28);
  position: relative;
  overflow: hidden;
}

.site-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.16) 0, transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.1) 0, transparent 25%);
  pointer-events: none;
}

.site-header .container {
  position: relative;
  z-index: 1;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 10px;
  font-size: 36px;
  letter-spacing: 0.8px;
  background: linear-gradient(135deg, #eef2ff, #c7d2fe, #e0f2fe);
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.18);
}

.site-header h1 a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}

.site-header .description {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
}

.site-footer {
  margin-top: 48px;
  padding: 24px 0 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr;
  gap: 20px;
  margin-top: -48px;
  position: relative;
}

.search-panel {
  background: var(--surface);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(79, 70, 229, 0.08);
  position: relative;
  height: fit-content;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-close {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--muted);
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.content-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.06);
  min-width: 0;
}

.content-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.24);
}

.filter-toggle__icon {
  position: relative;
  width: 18px;
  height: 12px;
  display: inline-block;
}

.filter-toggle__icon::before,
.filter-toggle__icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 4px;
  background: currentColor;
}

.filter-toggle__icon::before {
  top: 0;
  box-shadow: 0 5px 0 currentColor;
}

.filter-toggle__icon::after {
  bottom: 0;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-field__label {
  font-weight: 600;
}

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

.language-select {
  min-width: 160px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.04);
  width: 100%;
}

.tag-select {
  position: relative;
  margin-bottom: 14px;
}

.tag-select__control {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.04);
}

.tag-select__control::after {
  content: '\25BE';
  color: var(--muted);
  font-size: 12px;
}

.tag-select__menu {
  position: absolute;
  z-index: 10;
  inset: calc(100% + 6px) 0 auto 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
  padding: 10px;
}

.tag-select__search input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.tag-select__options {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.tag-select__empty {
  padding: 6px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  grid-column: 1 / -1;
}

.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tag-option input {
  width: 16px;
  height: 16px;
}

.tag-option:hover {
  border-color: var(--primary);
  background: #f8fafc;
}

.tag-option.is-active {
  border-color: rgba(67, 56, 202, 0.6);
  background: var(--tag-bg);
  color: var(--tag-text);
  box-shadow: 0 2px 8px rgba(67, 56, 202, 0.12);
}

.search-form input[type="text"] {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.04);
  min-width: 0;
  width: 100%;
}

.search-actions {
  display: flex;
  justify-content: flex-end;
}

.search-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.24);
  min-width: 96px;
  white-space: nowrap;
}

.search-form button:hover {
  opacity: 0.9;
}

.search-summary {
  margin-top: 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--border);
  padding: 10px 12px;
  border-radius: 12px;
}

.search-summary__title {
  margin: 0 0 6px;
  font-weight: 600;
}

.search-summary__list {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
}

.search-summary__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.search-summary__label {
  font-size: 14px;
  color: var(--muted);
}

.search-summary__chip {
  font-weight: 600;
}

.search-summary__chips {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.snippets {
  display: grid;
  gap: 16px;
}

.snippet {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 15px 40px rgba(15, 23, 42, 0.05);
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.snippet-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.snippet h3 {
  margin: 0 0 6px;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.meta-label {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge.language {
  background: #ecfdf3;
  color: #15803d;
  border-radius: 6px;
  padding: 4px 8px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.tag {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 13px;
  border: 1px solid rgba(67, 56, 202, 0.2);
}

.selected-tags {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 6px 0 14px;
}

.selected-tags__label {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--muted);
}

.selected-tags__chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.selected-tag:hover,
.clear-tags:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.clear-tags {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--muted);
}

.code-block {
  position: relative;
  margin-top: 10px;
  border: 1px solid var(--code-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
  color: var(--code-text);
}

.code-block pre {
  background: transparent;
  color: inherit;
  padding: 16px;
  overflow-x: auto;
  white-space: pre;
  font-family: 'Fira Code', 'Source Code Pro', Consolas, monospace;
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

.code-block code {
  display: block;
  width: 100%;
  min-width: 0;
  word-break: normal;
}

.code-block::before {
  content: attr(data-language);
  position: absolute;
  top: 0;
  left: 0;
  padding: 8px 12px;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.86);
  background: rgba(255, 255, 255, 0.04);
  border-bottom-right-radius: 10px;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}

.copy-btn:hover {
  transform: translateY(-1px);
}

.copy-btn.copied {
  background: #22c55e;
  border-color: #16a34a;
}

.description {
  margin: 8px 0;
}

.hljs {
  background: transparent;
}

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.empty {
  color: var(--muted);
  margin: 0 0 12px;
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 80;
  display: none;
}

.panel-backdrop.is-active {
  display: block;
}

@media (max-width: 640px) {
  .search-form button {
    width: 100%;
    justify-content: center;
  }

  .copy-btn {
    position: static;
    margin-top: 8px;
    background: #334155;
    border-color: #1f2937;
    width: 100%;
  }

  .code-block::before {
    position: static;
    display: inline-block;
    border-bottom-right-radius: 0;
  }
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
    margin-top: -32px;
  }

  .search-panel {
    position: fixed;
    inset: 0 auto 0 -120%;
    width: min(88vw, 360px);
    height: 100vh;
    border-radius: 0 16px 16px 0;
    z-index: 100;
    transition: transform 0.2s ease, inset 0.2s ease;
    overflow-y: auto;
    box-shadow: 10px 0 30px rgba(15, 23, 42, 0.18);
  }

  .search-panel.is-open {
    inset: 0 auto 0 0;
  }

  .panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .filter-toggle {
    display: inline-flex;
  }
}

@media (max-width: 860px) {
  .container {
    padding: 0 16px 32px;
  }

  .content-column,
  .search-panel {
    padding: 16px;
  }

  .snippet {
    padding: 16px;
  }

  .snippet-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .container {
    padding: 0 12px 28px;
  }

  .search-summary__list {
    flex-direction: column;
    align-items: flex-start;
  }

  .code-block pre {
    font-size: 13px;
  }
}
