:root {
  --bg: #14161a;
  --surface: #1c1f26;
  --surface-2: #242832;
  --border: #2c3038;
  --text: #ece9e2;
  --text-dim: #8b8f9b;
  --amber: #e8a33d;
  --coral: #d9704f;
  --sage: #7fa66b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .title-font, button, .btn {
  font-family: 'Quicksand', sans-serif;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 76px;
}

.app-shell.no-nav { padding-bottom: 0; }

.topbar {
  padding: 20px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 700;
}

.topbar .logout-link {
  color: var(--text-dim);
  font-size: 0.85rem;
}

main { padding: 8px 16px 16px; flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.card:active { background: var(--surface-2); }

.card-title {
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.card-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 16px;
  font-size: 0.95rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary { background: var(--amber); color: #1a1408; }
.btn-danger { background: var(--coral); color: #200c05; }
.btn-sage { background: var(--sage); color: #0e1a08; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; border-radius: 10px; }

/* Forms */
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
}

label {
  display: block;
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 12px 0 4px;
}

form .field:first-child label { margin-top: 0; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  max-width: 560px;
  margin: 0 auto;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 12px 0 10px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
}

.bottom-nav a.active { color: var(--amber); }
.bottom-nav .icon { display: block; font-size: 1.2rem; margin-bottom: 2px; }

/* Tabs / filters */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs a {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.85rem;
}

.tabs a.active { background: var(--amber); color: #1a1408; border-color: var(--amber); }

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.filters select { width: auto; min-width: 120px; }

/* Chips */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #14161a;
}

.chip-medicament { background: var(--amber); }
.chip-simptom { background: var(--coral); }
.chip-liber { background: var(--text-dim); }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-activ { background: var(--sage); color: #0e1a08; }
.status-inchis { background: var(--border); color: var(--text-dim); }

/* Episode detail */
.episode-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.episode-header .back { color: var(--text-dim); font-size: 1.3rem; padding-right: 6px; }
.episode-header h2 { margin: 0; font-size: 1.15rem; }
.episode-header .card-sub { margin-top: 2px; }

.episode-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 180px;
}

section.block { margin-bottom: 22px; }
section.block h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.dose-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.dose-item.bifat { opacity: 0.55; }
.dose-item.bifat .dose-desc { text-decoration: line-through; }

.dose-checkbox {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--sage);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sage);
  font-weight: 700;
  background: transparent;
  width: 26px;
}

.dose-item.bifat .dose-checkbox { background: var(--sage); color: #0e1a08; }

.dose-desc { flex: 1; font-size: 0.9rem; }
.dose-time { color: var(--text-dim); font-size: 0.78rem; }

.add-dose-form {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.add-dose-form input { flex: 1; }

.journal-entry {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.journal-entry:last-child { border-bottom: none; }
.journal-time { color: var(--text-dim); font-size: 0.75rem; min-width: 42px; padding-top: 2px; }
.journal-content { flex: 1; }
.journal-text { font-size: 0.92rem; margin-top: 4px; }
.journal-del {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}

/* Input bar fixed bottom on episode screen */
.input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.quick-buttons-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 8px;
  padding-bottom: 2px;
}

.quick-btn {
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

.quick-btn.tip-medicament { border-color: var(--amber); color: var(--amber); }
.quick-btn.tip-simptom { border-color: var(--coral); color: var(--coral); }

.entry-form { display: flex; gap: 8px; }
.entry-form input { flex: 1; }
.entry-form button { flex-shrink: 0; }

.top-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
}
.top-actions form { flex: 1; }

/* Login / setup */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
  text-align: center;
}

.auth-card p.sub {
  color: var(--text-dim);
  text-align: center;
  margin: 0 0 20px;
  font-size: 0.88rem;
}

.error-msg {
  background: rgba(217, 112, 79, 0.15);
  color: var(--coral);
  border: 1px solid var(--coral);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--amber);
  font-size: 0.85rem;
  margin-top: 6px;
}

.member-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.qb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.qb-item .qb-label { flex: 1; font-weight: 700; }
.qb-item .qb-del { background: none; border: none; color: var(--coral); font-size: 1.1rem; cursor: pointer; }
