:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #d4dde8;
  --text: #1a2332;
  --muted: #5a6578;
  --accent: #2d5a8a;
  --accent-soft: #e8eef6;
  --accent-hover: #234a72;
  --tag-bg: #edf2f8;
  --sheet-bg: #f5f8fc;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
  --radius: 12px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #e2eaf4 0%, var(--bg) 200px);
  min-height: 100vh;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.header { padding: 28px 0 16px; }
.header h1 { margin: 0; font-size: 1.7rem; font-weight: 700; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }

.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.search-form { display: flex; gap: 10px; }
.search-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
}
.search-form input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.search-form button {
  padding: 12px 22px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.search-form button:hover { background: var(--accent-hover); }

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.filter-label { color: var(--muted); font-size: 0.9rem; }
.filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 220px;
}

.tag-section { margin-top: 14px; }
.tag-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.quick-tags, .sheet-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag, .sheet-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.tag:hover, .sheet-chip:hover { border-color: var(--accent); }
.tag.active, .sheet-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sheet-chip { background: var(--sheet-bg); }
.sheet-chip .sheet-no {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 4px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
}
.sheet-chip.active .sheet-no {
  background: #fff;
  color: var(--accent);
}
.sheet-chip .code {
  font-weight: 700;
  margin-right: 4px;
  color: var(--accent);
}
.sheet-chip.active .code { color: #fff; }

.content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 20px;
}
.content.has-detail {
  grid-template-columns: 1fr 380px;
}

.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-height: 320px;
}
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.results-header h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.results-count { color: var(--muted); font-size: 0.9rem; }

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.result-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.result-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.result-item.active { border-color: var(--accent); background: var(--accent-soft); }

.result-title { font-weight: 600; font-size: 1rem; }
.result-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  margin-right: 6px;
}
.result-snippet {
  font-size: 0.85rem;
  margin-top: 6px;
  color: var(--text);
  line-height: 1.45;
}
.result-snippet .field {
  color: var(--muted);
  font-size: 0.8rem;
}
.empty { color: var(--muted); padding: 24px; text-align: center; }

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.detail-close {
  float: right;
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.detail-panel h3 { margin: 0 0 8px; font-size: 1.15rem; }
.detail-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.detail-fields { margin: 0; }
.detail-fields dt {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 10px;
}
.detail-fields dd {
  margin: 2px 0 0;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}
.disclaimer { line-height: 1.5; }

@media (max-width: 900px) {
  .content.has-detail { grid-template-columns: 1fr; }
  .detail-panel { position: static; max-height: none; }
}
