:root {
  --bg:            #0f1117;
  --surface:       #181c24;
  --surface2:      #1e2330;
  --surface3:      #252c3a;
  --accent:        #4db8c8;
  --accent-hover:  #72cdd9;
  --accent-dim:    rgba(77, 184, 200, 0.1);
  --text:          #d8e0ec;
  --text-muted:    #7a8899;
  --danger:        #e06060;
  --danger-bg:     rgba(224, 96, 96, 0.1);
  --success:       #4ec994;
  --success-bg:    rgba(78, 201, 148, 0.1);
  --border:        #252c3a;
  --border-accent: #2e3a50;
  --nav-height:    56px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--nav-height);
  line-height: 1.5;
}

/* ── NAV ── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  z-index: 100;
}

.nav-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-links a:hover  { color: var(--text); background: var(--surface2); }
.nav-links a.active { color: var(--accent); background: var(--accent-dim); }

/* ── LAYOUT ── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

h1 {
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 32px;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 20px;
}

/* ── FORM ELEMENTS ── */
select, input[type="number"], input[type="text"] {
  background: var(--surface2);
  border: 1px solid var(--border-accent);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

select:focus, input:focus { border-color: var(--accent); }
select option { background: var(--surface2); }

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ── RECIPE CALCULATOR ── */
.recipe-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.form-group { display: flex; flex-direction: column; }

#recipe-select { min-width: 260px; }
#qty-input     { width: 100px; }

.recipe-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  min-height: 1.4em;
}

.recipe-meta span { color: var(--text); }

.recipe-controls-right {
  margin-left: auto;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border-accent);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ── INGREDIENTS TABLE ── */
.ingredients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ingredients-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.ingredients-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.ingredients-table tbody tr:last-child td { border-bottom: none; }
.ingredients-table tbody tr:hover td { background: var(--surface2); }

.ingredient-name { font-weight: 500; }

.col-need {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 60px;
}

.have-input { width: 90px; }

.missing-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.missing-value.none { color: var(--success); }
.missing-value.some { color: var(--danger); }

.can-make-row {
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  font-size: 0.875rem;
}

.can-make-row strong { color: var(--accent); }

.balance-row {
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.7;
}

.balance-row strong { color: var(--text); }
.bal-short          { color: var(--danger); }
.bal-ok             { color: var(--success); }

.empty-state {
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── TAMES PAGE ── */
.search-box {
  width: 100%;
  max-width: 380px;
  margin-bottom: 16px;
}

.resource-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.resource-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.resource-btn:hover   { border-color: var(--border-accent); background: var(--surface3); }
.resource-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.resource-category-label {
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  padding: 6px 2px 2px;
}

.tame-panel-title {
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 16px;
  font-weight: 600;
}

.tame-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tame-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}

.tame-rank {
  font-size: 1.2rem;
  width: 30px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 1px;
}

.tame-info { flex: 1; }

.tame-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.tame-notes {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.tame-rating {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  padding-top: 2px;
}

.star { color: var(--border-accent); font-size: 0.9rem; }
.star.filled { color: var(--accent); }

.no-selection {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* ── TAME ADVISOR ── */
.config-card {
  margin-bottom: 24px;
  padding: 0;
  overflow: hidden;
}

.config-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
}

.config-header:hover { background: var(--surface2); }

.config-title  { font-weight: 600; font-size: 0.95rem; flex: 1; }
.owned-summary { font-size: 0.8rem; color: var(--text-muted); }
.config-chevron { font-size: 0.75rem; color: var(--text-muted); }

#config-body {
  padding: 0 20px 18px;
  border-top: 1px solid var(--border);
}

.config-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 12px 0 10px;
}

.config-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.ownership-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.own-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.own-btn:hover { border-color: var(--border-accent); color: var(--text); }

.own-btn.owned {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.task-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.task-category-label {
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  padding: 8px 2px 2px;
}

.task-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.task-btn:hover   { border-color: var(--border-accent); background: var(--surface3); }
.task-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.hide-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 20px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
}

.hide-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.task-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: -8px;
}

.tame-card.dimmed {
  opacity: 0.4;
}

/* ── TAME BASE STATS ── */
.stat-details {
  margin-top: 8px;
}

.stat-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  transition: color 0.15s;
}

.stat-summary::-webkit-details-marker { display: none; }
.stat-summary::after                   { content: ' ▾'; font-size: 0.65rem; }
details[open] .stat-summary::after     { content: ' ▴'; }
.stat-summary:hover                    { color: var(--text); }

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 48px;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.stat-val {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 500;
}

/* ── WIKI LINKS ── */
.wiki-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--border-accent);
  transition: color 0.15s, border-color 0.15s;
}

.wiki-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.not-owned-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}


/* ── INDEX PAGE ── */
.index-hero {
  padding: 32px 0 48px;
}

.index-hero h1 { font-size: 2rem; margin-bottom: 10px; }

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool-card-icon  { font-size: 2.2rem; margin-bottom: 12px; }
.tool-card h2    { color: var(--accent); font-size: 1.05rem; margin-bottom: 8px; }
.tool-card p     { font-size: 0.875rem; color: var(--text-muted); line-height: 1.55; }

/* ── FOOTER NOTE ── */
.wiki-note {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.wiki-note a { color: var(--accent); }

/* ── HAMBURGER NAV ── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  margin-left: auto;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}

.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: background 0.15s;
}

.nav-hamburger:hover span { background: var(--text); }

/* Mobile dropdown panel */
.nav-links-dropdown {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-accent);
  z-index: 99;
  padding: 8px 0;
}

.nav-links-dropdown li { list-style: none; }

.nav-links-dropdown a {
  display: block;
  padding: 12px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.15s, background 0.15s;
}

.nav-links-dropdown a:hover  { color: var(--text); background: var(--surface2); }
.nav-links-dropdown a.active { color: var(--accent); }

nav.open .nav-links-dropdown { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  /* Nav: hide inline links, show hamburger */
  .nav-hamburger { display: flex; }
  .nav-links      { display: none; }

  nav { padding: 0 14px; }
  main { padding: 24px 14px 48px; }

  /* Prevent iOS Safari from zooming in on focused inputs */
  select,
  input[type="number"],
  input[type="text"] { font-size: 1rem; }

  /* Recipe controls stack vertically */
  .recipe-controls { flex-direction: column; align-items: stretch; }
  .recipe-controls-right { margin-left: 0; }
  #recipe-select { min-width: unset; width: 100%; }
  #qty-input     { width: 100%; }

  /* Hide "Need" column — saves space, not critical info on mobile */
  .ingredients-table th:nth-child(2),
  .ingredients-table td:nth-child(2) { display: none; }

  /* Have input full-width in its cell */
  .have-input { width: 100%; min-width: 64px; }

  /* Recipe meta: stack instead of inline dots */
  .recipe-meta { display: flex; flex-direction: column; gap: 2px; line-height: 1.7; }

  /* Balance row: stack shortage items vertically */
  .balance-row { display: flex; flex-direction: column; gap: 4px; }

  /* Tame cards: move star rating below name on very narrow screens */
  .tame-card { flex-wrap: wrap; }
  .tame-rating { order: 3; width: 100%; padding-top: 6px; }
  .tame-info   { order: 2; }

  /* Touch targets: ensure minimum 44px on interactive chips */
  .own-btn,
  .resource-btn,
  .task-btn { min-height: 44px; display: inline-flex; align-items: center; }

  /* Search box full width */
  .search-box { max-width: 100%; }

  /* Index hero */
  .index-hero h1 { font-size: 1.5rem; }
}
