:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
}

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

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: #1a1a1a;
  background: #fff;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

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

/* Left panel */
.panel-features {
  overflow-y: auto;
  padding: var(--space-4);
  border-right: 1px solid #e0e0e0;
  background: #f8f8f8;
}

/* Right panel */
.panel-results {
  overflow-y: auto;
  padding: var(--space-4);
}

/* Panel header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.panel-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  gap: 2px;
}

.lang-btn {
  padding: 3px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid #ccc;
  background: #fff;
  color: #666;
  cursor: pointer;
  border-radius: 3px;
}

.lang-btn:first-child {
  border-radius: 3px 0 0 3px;
}

.lang-btn:last-child {
  border-radius: 0 3px 3px 0;
}

.lang-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* Feature groups */
.feature-group {
  margin-bottom: var(--space-5);
}

.feature-group h2 {
  margin: 0 0 var(--space-4) 0;
  font-size: 1em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #111;
}

.feature-group h3 {
  margin: var(--space-4) 0 var(--space-1) 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: #555;
}

/* Pills container */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* Pill button */
.pill {
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: #f5f5f5;
  font-size: 0.8rem;
  color: #333;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.2;
}

.pill:hover {
  border-color: #2c5f2e;
  background: #f0f7f0;
}

.pill.active {
  background: #2c5f2e;
  color: #fff;
  border-color: #2c5f2e;
}

/* Reset button */
.btn-reset {
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  color: #555;
}

.btn-reset:hover {
  background: #f0f0f0;
}

/* Tannin dimming */
.tannin-section.dimmed {
  opacity: 0.4;
  pointer-events: none;
}

/* Result rows */
.result-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid #f0f0f0;
}

.rank {
  font-weight: bold;
  color: #333;
  text-align: right;
}

.result-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.variety {
  font-weight: bold;
}

.region {
  color: #666;
  font-size: 0.8rem;
}

/* Confidence bar */
.confidence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.confidence-track {
  width: 80px;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
}

.confidence-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #2c5f2e;
  border-radius: 4px;
}

.confidence-label {
  font-size: 0.8rem;
  color: #666;
  white-space: nowrap;
  min-width: 32px;
}

/* Feature tags — second grid row, spanning info + bar columns */
.feature-tags {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.tag {
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 0.8rem;
}

.tag.matched {
  background: #d4edda;
  color: #155724;
}

.tag.conflict {
  background: #f8d7da;
  color: #721c24;
}

/* Section heading with help icon */
.section-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-heading {
  margin-top: var(--space-4);
}

.section-heading h3 {
  margin: 0;
}

.help-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: 1px solid #999;
  background: none;
  color: #666;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  touch-action: manipulation;
}

/* Extend tap area to 44x44 without affecting layout */
.help-icon::after {
  content: '';
  position: absolute;
  inset: -13px;
}

.help-icon:hover {
  border-color: #2c5f2e;
  color: #2c5f2e;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modal-fade-in 0.15s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #666;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #333;
}

.modal-terms {
  margin: 0;
  padding: 16px;
  overflow-y: auto;
}

.modal-terms dt {
  font-weight: 600;
  margin-top: var(--space-3);
}

.modal-terms dt:first-child {
  margin-top: 0;
}

.modal-terms dd {
  margin: var(--space-1) 0 0 0;
  color: #555;
}
