:root {
  --orange: #e65c00;
  --orange-dark: #c44d00;
  --bg: #0d0d0d;
  --bg-card: #1a1a1a;
  --bg-input: #252525;
  --text: #f0f0f0;
  --text-muted: #999;
  --border: #333;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

#header {
  background: var(--orange);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}

#header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

.icon-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

#main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}

.view {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.search-controls {
  margin-bottom: 12px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23999' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

input:focus, select:focus {
  border-color: var(--orange);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 10px;
}

#results-count {
  font-weight: 600;
  font-size: 1rem;
}

.btn-secondary {
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-secondary:active {
  background: var(--orange-dark);
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}

.result-card:active {
  background: #222;
  border-color: var(--orange);
}

.result-card .county {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.result-card .abbr {
  color: var(--orange);
  font-weight: 700;
  font-size: 0.95rem;
}

.result-card .name {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2px 0 0;
}

.result-card .chevron {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* Detail */
#back-btn {
  margin-bottom: 16px;
}

#detail-content h2 {
  font-size: 1.6rem;
  margin: 4px 0 2px;
}

#detail-content .abbr-big {
  color: var(--orange);
  font-weight: 700;
  font-size: 1.1rem;
}

#detail-content .county-line {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

#detail-content .desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.detail-box {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.detail-box .label {
  font-size: 0.8rem;
  color: var(--orange);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.detail-box .value {
  font-size: 1.05rem;
  line-height: 1.45;
}

.detail-box.rate-box .value {
  font-size: 1.3rem;
  font-weight: 700;
}

/* Calculator */
.calc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.calc-tab {
  flex: 1;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.calc-tab.active {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
  font-weight: 600;
}

.calc-panel {
  display: none;
}

.calc-panel.active {
  display: block;
}

.rate-buttons {
  display: flex;
  gap: 10px;
}

.rate-btn {
  flex: 1;
  padding: 12px 8px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

.rate-btn.active {
  border-color: var(--orange);
  background: rgba(230, 92, 0, 0.15);
  color: var(--orange);
  font-weight: 700;
}

.calc-results {
  margin-top: 24px;
}

.result-box {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  margin-bottom: 12px;
}

.result-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--orange);
}

.calc-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  margin-top: 8px;
}

/* Scientists */
.scientist-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px 16px;
}

.scientist-card .name {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.scientist-card .phone {
  color: var(--orange);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.scientist-card .phone a {
  color: var(--orange);
  text-decoration: none;
}

.scientist-card .location {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.scientist-card .area {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.75rem;
  background: rgba(230, 92, 0, 0.15);
  color: var(--orange);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Definitions */
.def-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.def-card .word {
  color: var(--orange);
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.def-card .definition {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

/* Bottom nav */
#bottom-nav {
  display: flex;
  background: #111;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.nav-btn.active {
  color: var(--orange);
}

.nav-icon {
  font-size: 1.35rem;
}

.empty-state, .loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* County conflict UI */
.county-conflict {
  background: rgba(230, 92, 0, 0.1);
  border: 1px solid var(--orange);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.conflict-msg {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}

.conflict-counties {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.conflict-county-btn {
  background: var(--bg-input);
  border: 1px solid var(--orange);
  color: var(--orange);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}

.conflict-county-btn:active,
.conflict-county-btn.selected {
  background: var(--orange);
  color: white;
}
