/* Rent or buy? — GitHub-dark design tokens ported verbatim from
   webgpu-fluid-solver / webgpu-gray-scott. Single dark theme. */

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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --raised: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-2: #b1bac4;
  --muted: #8b949e;
  --faint: #484f58;
  --accent: #1f6feb;
  --accent-text: #58a6ff;
  --buy: #f0883e;
  --rent: #58a6ff;
  --green: #238636;
  --green-text: #7ee787;
  --error: #da3633;
  --mono: 'SF Mono', 'Cascadia Code', monospace;
}

body {
  background: var(--bg);
  color: var(--text-2);
  font-family: -apple-system, 'Segoe UI', sans-serif;
  margin: 0;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Error banner (device-lost pattern) */
#error-banner {
  display: none;
  background: var(--error);
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
  z-index: 100;
}
#error-banner.visible { display: block; }
#error-banner button {
  margin-left: 10px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  padding: 2px 10px;
  cursor: pointer;
}

/* Title bar (ported) */
#title-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#app-name { font-weight: 700; font-size: 16px; color: var(--text); }
.badge {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(31, 111, 235, 0.2);
  color: var(--accent-text);
  border: 1px solid rgba(31, 111, 235, 0.3);
}
.title-spacer { flex: 1; }
.author-link { color: var(--text-2); text-decoration: none; font-size: 12px; }
.author-link:hover { color: #ffffff; }
.gh-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #c9d1d9;
  text-decoration: none;
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--raised);
  transition: border-color 0.2s, color 0.2s;
}
.gh-pill:hover { border-color: var(--accent-text); color: #ffffff; }

/* Preset bar (ported) */
#preset-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}
.preset-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.preset-btn {
  padding: 4px 10px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: #c9d1d9;
  cursor: pointer;
  white-space: nowrap;
}
.preset-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.preset-btn.disabled { color: var(--faint); cursor: not-allowed; }
.btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  background: var(--raised);
  color: #c9d1d9;
  white-space: nowrap;
}
.btn-advanced { background: var(--error); border-color: var(--error); color: #fff; }

/* Layout */
#main { flex: 1; display: flex; overflow: hidden; position: relative; }
#input-panel {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
#results {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#results-spinner {
  display: none;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--green-text);
}

/* Inputs (ported slider system) */
.section-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 8px;
}
#input-panel .section-title:first-child { margin-top: 0; }
.slider-row { margin-bottom: 10px; }
.slider-header { display: flex; justify-content: space-between; margin-bottom: 3px; }
.slider-name { font-size: 12px; color: #c9d1d9; }
.slider-value { font-size: 12px; color: var(--green-text); font-family: var(--mono); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--raised);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
.slider-hint { font-size: 10px; color: #6e7681; margin-top: 2px; }
.select-row select {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  margin-bottom: 10px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #c9d1d9;
  margin-bottom: 10px;
}
.checkbox-row input { accent-color: var(--accent); }
.seg-picker { display: flex; gap: 6px; margin-bottom: 10px; }
.seg-btn {
  flex: 1;
  padding: 4px 0;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--mono);
  color: #c9d1d9;
  cursor: pointer;
}
.seg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Advanced drawer (ported) */
#advanced-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 10;
  overflow-y: auto;
}
#advanced-panel.visible { transform: translateX(0); }
.panel-header {
  font-weight: 600;
  font-size: 14px;
  color: #f0f6fc;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
}
.panel-header button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

/* Verdict hero */
#verdict-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 26px;
}
#verdict-line {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.3;
  margin: 0;
}
#verdict-line .amount-buy { color: var(--buy); }
#verdict-line .amount-rent { color: var(--rent); }
#verdict-subline { font-size: 13px; color: var(--muted); margin-top: 8px; }
#stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.stat-card.buy { border-left: 3px solid var(--buy); }
.stat-card.rent { border-left: 3px solid var(--rent); }
.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value { font-family: var(--mono); font-size: 16px; color: var(--text); margin-top: 3px; }
.stat-value.buy { color: var(--buy); }
.stat-value.rent { color: var(--rent); }

/* Chart cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.card h2 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.card .card-sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.chart { width: 100%; height: 320px; }

/* Numbers table */
#numbers {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
}
#numbers summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); }
#data-table { margin-top: 10px; max-height: 400px; overflow: auto; }
#data-table table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 11px; }
#data-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  text-align: right;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
#data-table td {
  text-align: right;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.4);
  color: var(--text-2);
}
#csv-btn { margin-top: 10px; }

/* Footer */
footer { font-size: 12px; color: var(--muted); line-height: 1.7; padding: 8px 4px 24px; }
footer a { color: var(--accent-text); text-decoration: none; }
#region-notes { margin-top: 10px; }
#region-notes ul { margin: 6px 0 0; padding-left: 18px; }
#region-notes li { margin-bottom: 4px; }

/* Overlays: welcome modal + guide (ported) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.3s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.modal {
  position: relative;
  max-width: 600px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: 12px;
  padding: 40px 40px 32px;
  box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22);
}
.modal h1 { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; margin: 0 0 14px; }
.modal p, .modal li { font-size: 14px; line-height: 1.65; color: var(--text-2); }
.modal strong { color: var(--text); }
.modal em { color: #a5d6ff; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.btn-primary {
  display: inline-flex;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--green);
  border: 1px solid rgba(35, 134, 54, 0.6);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #2ea043; }
.guide-section { border-bottom: 1px solid rgba(48, 54, 61, 0.6); }
.guide-section:last-child { border-bottom: none; }
.guide-section-header { display: flex; align-items: center; gap: 8px; padding: 12px 0; cursor: pointer; }
.guide-section-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.guide-chevron { color: var(--faint); transition: transform 0.2s; }
.guide-section.open .guide-chevron { transform: rotate(90deg); }
.guide-section-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.guide-section.open .guide-section-body { max-height: 2000px; }

/* Mobile: left panel becomes a drawer */
#inputs-btn { display: none; }
@media (max-width: 900px) {
  #inputs-btn { display: inline-flex; }
  #input-panel {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  #input-panel.visible { transform: translateX(0); box-shadow: 8px 0 16px rgba(0, 0, 0, 0.4); }
  #stat-row { grid-template-columns: repeat(2, 1fr); }
  #verdict-line { font-size: 20px; }
  #results { padding: 14px; }
}
