:root {
  --wine: #6B1A2A;
  --wine-dark: #3D0E18;
  --wine-light: #9B2335;
  --gold: #C8A415;
  --gold-light: #E8C84A;
  --cream: #F5F0E8;
  --text: #1A0A0E;
  --text-muted: #6B5660;
  --border: #D4B8BE;
  --card-bg: #FFFFFF;
  --bg: #F8F3F0;
  --tag-bg: #F0E8EC;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--wine-dark) 0%, var(--wine) 60%, var(--wine-light) 100%);
  color: white;
  padding: 20px 24px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.header-icon { font-size: 2.2rem; }

.header-title h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.header-title p {
  font-size: 0.8rem;
  opacity: 0.75;
  margin-top: 2px;
}

/* Search */
.search-wrap {
  position: relative;
  max-width: 520px;
  margin-bottom: 20px;
}

.search-wrap input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border-radius: 24px;
  border: none;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.15);
  color: white;
  outline: none;
  transition: background 0.2s;
}

.search-wrap input::placeholder { color: rgba(255,255,255,0.6); }
.search-wrap input:focus { background: rgba(255,255,255,0.25); }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.7;
  font-size: 1rem;
}

/* Nav Tabs */
nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  font-family: inherit;
}

.tab:hover { color: white; background: rgba(255,255,255,0.08); }

.tab.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
  background: rgba(255,255,255,0.08);
}

/* Main content */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

.panel { display: none; }
.panel.active { display: block; }

/* Section heading */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--wine);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(107,26,42,0.12);
  border-color: var(--wine-light);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--wine-dark);
  line-height: 1.3;
}

.card-name-fr {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

.card-desc {
  font-size: 0.8rem;
  color: #444;
  line-height: 1.6;
  margin-top: 6px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.tag {
  background: var(--tag-bg);
  color: var(--wine);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.tag.gold {
  background: #FFF8E0;
  color: #8B6000;
  border-color: var(--gold);
}

.tag.green {
  background: #E8F5E8;
  color: #2D6A2D;
  border-color: #A8D8A8;
}

/* Region color dot */
.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

/* Grapes list */
.grape-row {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #555;
}
.grape-row strong { color: var(--wine); font-size: 0.75rem; margin-right: 4px; }

/* Classification */
.classif-card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.classif-header {
  background: linear-gradient(135deg, var(--wine-dark), var(--wine));
  color: white;
  padding: 14px 18px;
}

.classif-header h3 { font-size: 1rem; }
.classif-header p { font-size: 0.78rem; opacity: 0.8; margin-top: 4px; }

.classif-body { padding: 16px; }

.rank-section { margin-bottom: 16px; }
.rank-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--wine);
  background: var(--tag-bg);
  padding: 4px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: inline-block;
}

.chateau-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.chateau-item {
  padding: 6px 10px;
  background: #FAFAFA;
  border-radius: 6px;
  border: 1px solid #EEE;
  font-size: 0.78rem;
}

.chateau-name { font-weight: 600; color: var(--text); }
.chateau-name-fr { color: var(--text-muted); font-style: italic; font-size: 0.72rem; margin-top: 1px; }
.chateau-note { color: var(--gold); font-size: 0.7rem; margin-top: 2px; }

/* Terms */
.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.term-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.term-word {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--wine-dark);
}

.term-reading {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 2px 0 6px;
}

.term-cat {
  font-size: 0.68rem;
  background: var(--wine);
  color: white;
  padding: 1px 7px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 6px;
}

.term-desc {
  font-size: 0.78rem;
  color: #444;
  line-height: 1.65;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.filter-btn:hover { border-color: var(--wine-light); color: var(--wine); }
.filter-btn.active { background: var(--wine); color: white; border-color: var(--wine); }

/* Overview hero */
.overview-hero {
  background: linear-gradient(135deg, var(--wine-dark) 0%, var(--wine) 100%);
  border-radius: 16px;
  padding: 28px 28px 24px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.overview-hero::after {
  content: '🍷';
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 5rem;
  opacity: 0.15;
}

.overview-hero h2 { font-size: 1.4rem; margin-bottom: 8px; }
.overview-hero p { font-size: 0.85rem; opacity: 0.85; line-height: 1.7; max-width: 640px; }

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.stat-box {
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px 18px;
  text-align: center;
  min-width: 90px;
}

.stat-num { font-size: 1.5rem; font-weight: 700; color: var(--gold-light); }
.stat-label { font-size: 0.72rem; opacity: 0.8; margin-top: 2px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

.modal-header {
  background: linear-gradient(135deg, var(--wine-dark), var(--wine));
  color: white;
  padding: 18px 20px;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-body { padding: 20px; }

.modal-body h4 {
  font-size: 0.85rem;
  color: var(--wine);
  margin: 14px 0 6px;
  font-weight: 600;
}

.modal-body p { font-size: 0.85rem; line-height: 1.7; color: #333; }

.info-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.info-table td { padding: 6px 10px; font-size: 0.82rem; border-bottom: 1px solid #EEE; }
.info-table td:first-child { color: var(--text-muted); width: 110px; font-weight: 500; }

/* Search results */
.search-results {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.search-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid #F0EEF0;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); }

.result-type {
  font-size: 0.68rem;
  background: var(--tag-bg);
  color: var(--wine);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
  font-weight: 600;
}

.result-name { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.result-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }

/* Vineyard special */
.vineyard-card {
  border-left: 4px solid var(--gold);
}

/* Responsive */
@media (max-width: 600px) {
  .header-title h1 { font-size: 1.2rem; }
  .grid-2, .grid-3, .term-grid { grid-template-columns: 1fr; }
  .chateau-grid { grid-template-columns: 1fr; }
  .overview-hero::after { display: none; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Explorer / Drill-down ---- */
.explorer-bc {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  padding: 9px 14px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
}
.bc-link {
  color: var(--wine);
  cursor: pointer;
  font-weight: 600;
}
.bc-link:hover { text-decoration: underline; }
.bc-current { color: var(--text-muted); font-weight: 500; }
.bc-sep { color: #CCC; margin: 0 2px; }

/* Parcel grid */
.parcel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}
.parcel-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.parcel-card:hover {
  border-color: var(--wine-light);
  box-shadow: 0 2px 8px rgba(107,26,42,0.1);
  transform: translateY(-1px);
}
.parcel-name { font-size: 0.87rem; font-weight: 700; color: var(--wine-dark); line-height: 1.3; }
.parcel-fr { font-size: 0.71rem; color: var(--text-muted); font-style: italic; margin: 2px 0 4px; }
.parcel-size { font-size: 0.7rem; color: #888; }
.parcel-note { font-size: 0.7rem; color: #9B7A00; margin-top: 2px; }
.parcel-desc { font-size: 0.74rem; color: #555; margin-top: 5px; line-height: 1.55; }

/* GC highlight */
.parcel-card.gc {
  border-left: 3px solid var(--gold);
  background: #FFFDF5;
}
.parcel-card.pc { border-left: 3px solid #6AADE4; }
.parcel-card.notable { border-left: 3px solid #6BAD6A; }

/* Village detail header */
.village-detail-header {
  background: white;
  border-radius: 10px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--wine);
  margin-bottom: 4px;
}
.village-detail-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--wine-dark);
}
.village-detail-fr {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: normal;
  margin-left: 8px;
}
.village-detail-desc {
  font-size: 0.82rem;
  color: #444;
  margin-top: 8px;
  line-height: 1.65;
}

/* Sub-region card */
.subregion-card {
  background: linear-gradient(135deg, white 60%, var(--tag-bg));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.subregion-card:hover {
  border-color: var(--wine-light);
  box-shadow: 0 3px 12px rgba(107,26,42,0.1);
  transform: translateY(-2px);
}
.subregion-name { font-size: 0.95rem; font-weight: 700; color: var(--wine-dark); }
.subregion-fr { font-size: 0.75rem; color: var(--text-muted); font-style: italic; margin: 3px 0 6px; }
.subregion-desc { font-size: 0.78rem; color: #555; line-height: 1.55; }

@media (max-width: 600px) {
  .parcel-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== 味わいノート ===== */
.taste-note {
  margin-top: 8px;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(107,26,42,0.06), rgba(200,164,21,0.07));
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
  font-size: 0.82rem;
  line-height: 1.65;
  color: #5a3a42;
}
.taste-note.small {
  font-size: 0.74rem;
  padding: 6px 8px;
  line-height: 1.55;
}
.taste-note strong { color: var(--wine); }

/* ===== テロワール表示 ===== */
.terroir-box {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(107,26,42,0.04);
  border: 1px solid rgba(107,26,42,0.12);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.terroir-row {
  display: flex;
  gap: 6px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: #4a3a3e;
  align-items: baseline;
}
.terroir-icon { flex: 0 0 auto; }
.terroir-label {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--wine);
  font-size: 0.72rem;
}
.terroir-box.compact { padding: 6px 8px; }
.terroir-box.compact .terroir-row { font-size: 0.72rem; }
