/* Darwin's Journey Companion — styles
   Palette: aged field-journal paper + expedition teal/brass. Mobile-first. */

:root {
  --ink: #21322f;
  --paper: #faf6ee;
  --paper-dim: #f1ead9;
  --line: #ddd2b8;
  --teal: #1f3d3a;
  --teal-light: #2c5651;
  --brass: #b3812f;
  --brass-light: #e7c789;
  --red: #9c3d3d;
  --green-ok: #3d7a4f;
  --shadow: 0 1px 3px rgba(33, 50, 47, 0.12), 0 1px 2px rgba(33, 50, 47, 0.08);
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece6d8;
    --paper: #171f1d;
    --paper-dim: #1e2825;
    --line: #35423d;
    --teal: #6fb3aa;
    --teal-light: #8fc9c1;
    --brass: #e0b361;
    --brass-light: #4a3c22;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; margin: 0 0 .3em; line-height: 1.2; }
p { line-height: 1.5; }
a { color: inherit; }
button { font: inherit; }

/* App bar */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--teal); color: var(--paper);
  padding-top: var(--safe-top);
  box-shadow: var(--shadow);
}
.app-bar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 720px; margin: 0 auto;
  padding: 14px 16px;
}
.app-bar-title { font-family: Georgia, serif; font-size: 1.1rem; font-weight: 600; letter-spacing: .2px; }
.icon-btn {
  background: rgba(255,255,255,.12); border: none; color: inherit;
  border-radius: 8px; padding: 6px 10px; font-size: .85rem; cursor: pointer;
}

/* Main view */
.view {
  max-width: 720px; margin: 0 auto;
  padding: 16px 16px calc(88px + var(--safe-bottom));
  min-height: calc(100vh - 56px);
}

/* Tab bar */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -1px 6px rgba(0,0,0,.05);
}
.tab-link {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 7px; text-decoration: none; color: var(--ink); opacity: .55;
  font-size: .72rem; font-weight: 600;
}
.tab-link.active { opacity: 1; color: var(--teal-light); }
.tab-icon { font-size: 1.25rem; line-height: 1; }

/* Cards */
.card {
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:active { transform: scale(0.99); }
.card-title { font-family: Georgia, serif; font-size: 1.05rem; margin: 0 0 4px; color: var(--teal-light); }
.card-desc { font-size: .88rem; opacity: .8; margin: 0; }

.hero { text-align: center; padding: 20px 8px 8px; }
.hero h1 { font-size: 1.5rem; color: var(--teal-light); }
.hero p { opacity: .75; font-size: .92rem; }

.about-note {
  font-size: .78rem; opacity: .6; text-align: center; margin-top: 24px; line-height: 1.5;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--teal); color: var(--paper);
  border: none; border-radius: 999px;
  padding: 12px 22px; font-size: .95rem; font-weight: 600;
  cursor: pointer; width: 100%;
}
.btn:active { opacity: .85; }
.btn.secondary { background: transparent; color: var(--teal-light); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 14px; font-size: .82rem; }
.btn.danger-outline { background: transparent; border: 1px solid var(--red); color: var(--red); }

/* Forms */
.field-label { display: block; font-weight: 700; margin: 32px 0 8px; font-size: .92rem; }
.hint { font-size: .8rem; opacity: .65; margin: -4px 0 10px; }

.count-picker { display: flex; gap: 8px; }
.count-btn {
  flex: 1; padding: 12px 0; text-align: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper-dim); cursor: pointer; font-weight: 700;
}
.count-btn.selected { background: var(--teal); color: var(--paper); border-color: var(--teal); }

.module-group-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; opacity: .55; margin: 16px 0 6px; }
.module-row {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
  background: var(--paper-dim);
}
.module-row.selected { border-color: var(--brass); background: color-mix(in srgb, var(--brass-light) 35%, var(--paper-dim)); }
.module-row.disabled { opacity: .45; cursor: not-allowed; }
.module-row input { margin-top: 3px; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--teal); }
.module-name { font-weight: 700; font-size: .92rem; }
.module-desc { font-size: .78rem; opacity: .7; margin-top: 2px; }
.module-incompatible { font-size: .76rem; color: var(--red); margin-top: 4px; font-weight: 600; }

.toggle-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; font-size: .9rem; font-weight: 600;
}
.toggle-row input { width: 18px; height: 18px; accent-color: var(--teal); }

/* Checklist */
.progress-wrap { margin: 4px 0 18px; }
.progress-track {
  height: 8px; border-radius: 99px; background: var(--paper-dim);
  border: 1px solid var(--line); overflow: hidden;
}
.progress-fill { height: 100%; background: var(--brass); transition: width .2s ease; }
.progress-label { font-size: .78rem; opacity: .65; margin-top: 6px; }

.step-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.step-item input {
  margin-top: 3px; width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--green-ok);
}
.step-num {
  font-size: .72rem; font-weight: 700; opacity: .5; min-width: 22px;
}
.step-text { font-size: .92rem; line-height: 1.45; }
.step-item.checked .step-text { opacity: .45; text-decoration: line-through; }
.step-note {
  display: block; font-size: .78rem; opacity: .75; margin-top: 4px;
  border-left: 2px solid var(--brass); padding-left: 8px; white-space: pre-line;
}

.note-card { border-left: 3px solid var(--teal-light); }
.note-card ul { margin: 6px 0 0; padding-left: 18px; font-size: .85rem; line-height: 1.5; }

/* Reference */
.search-bar {
  position: sticky; top: 56px; z-index: 10; background: var(--paper);
  padding: 10px 0 8px;
}
.search-input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper-dim); color: var(--ink);
  font-size: 1rem;
}
.filter-row { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
.filter-select {
  border: 1px solid var(--line); background: var(--paper-dim); color: var(--ink);
  border-radius: 8px; padding: 7px 8px; font-size: .82rem; flex: 1; min-width: 0;
}
.results-count { font-size: .78rem; opacity: .6; margin: 10px 2px 6px; }

.ref-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px; background: var(--paper-dim);
}
.ref-item-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ref-code {
  font-family: Georgia, serif; font-weight: 700; font-size: 1rem;
  background: var(--brass); color: #2a1e05; border-radius: 6px; padding: 1px 8px;
}
.ref-cat { font-size: .72rem; opacity: .6; }
.ref-mod-badge {
  font-size: .68rem; font-weight: 700; opacity: .8;
  border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px;
  margin-left: auto;
}
.ref-title { font-weight: 700; font-size: .95rem; margin: 2px 0 4px; }
.ref-text { font-size: .88rem; line-height: 1.5; }
.ref-flavor { font-style: italic; opacity: .8; font-size: .84rem; margin-bottom: 6px; }
.ref-choice { margin-top: 6px; font-size: .86rem; }
.ref-choice b { color: var(--teal-light); }
.ref-disclaimer { font-size: .78rem; opacity: .65; margin: 8px 0 12px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; }

.empty-state { text-align: center; padding: 40px 12px; opacity: .6; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(72px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 999px; font-size: .85rem;
  z-index: 30; box-shadow: var(--shadow);
}

/* Install banner */
.install-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--brass-light); border: 1px solid var(--brass);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .84rem;
}
.install-banner .btn.small { background: var(--teal); color: var(--paper); }

@media (min-width: 600px) {
  .view { padding-left: 24px; padding-right: 24px; }
}
