/* FRELIP PWA — mobile-first styles. Navy #0F4C81 + gold #C8A02E. */

:root {
  --navy: #0F4C81;
  --navy-dark: #0b3a63;
  --gold: #C8A02E;

  /* light theme */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #16202b;
  --text-muted: #5a6b7b;
  --border: #e2e8f0;
  --header-bg: var(--navy);
  --header-text: #ffffff;
  --tabbar-bg: #ffffff;
  --tab-inactive: #8a99a8;
}

:root.dark {
  --bg: #0c1116;
  --surface: #161e27;
  --text: #e8eef4;
  --text-muted: #9fb0c0;
  --border: #26323e;
  --header-bg: #0a2c4d;
  --header-text: #ffffff;
  --tabbar-bg: #111922;
  --tab-inactive: #6e8092;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
}

/* ---------- offline banner ---------- */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--gold);
  color: var(--navy-dark);
  text-align: center;
  font-weight: 600;
  font-size: .85rem;
  padding: .5rem;
}

/* ---------- header ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .85rem 1rem;
  padding-top: calc(.85rem + env(safe-area-inset-top, 0));
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--navy-dark);
  color: var(--gold);
  font: 700 20px Georgia, serif;
  border: 1px solid var(--gold);
}
.app-title { font-size: 1.1rem; margin: 0; letter-spacing: .04em; }
.app-subtitle { font-size: .72rem; opacity: .8; margin-left: auto; }

/* ---------- main ---------- */
.app-main { padding: 1rem; max-width: 720px; margin: 0 auto; }
.view-title { font-size: 1.25rem; margin: .25rem 0 1rem; }
.hint { color: var(--text-muted); font-size: .85rem; margin: 0 0 1rem; }
.loading { color: var(--text-muted); padding: 2rem 0; text-align: center; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: .85rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.card-title { font-size: 1.02rem; margin: 0 0 .35rem; line-height: 1.3; }
.card-meta { font-size: .76rem; color: var(--text-muted); margin: 0 0 .5rem; }
.card-excerpt { font-size: .9rem; line-height: 1.5; margin: 0 0 .75rem; color: var(--text); }
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn-primary, .btn-ghost, .btn-save, .btn-remove {
  font-size: .85rem;
  font-weight: 600;
  border-radius: 8px;
  padding: .5rem .9rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
:root.dark .btn-ghost { color: var(--gold); }
.btn-save { background: var(--gold); color: var(--navy-dark); border-color: var(--gold); }
.btn-save.saved { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-remove { background: transparent; color: #c0392b; border-color: var(--border); }

/* ---------- search ---------- */
.search-form { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-form input {
  flex: 1;
  padding: .65rem .8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
}

/* ---------- settings ---------- */
.row { display: flex; align-items: center; justify-content: space-between; }
.row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--navy); }
.endpoint-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.endpoint-list li {
  display: flex; justify-content: space-between; gap: .75rem;
  font-size: .76rem; padding: .35rem 0; border-bottom: 1px solid var(--border);
}
.endpoint-list li:last-child { border-bottom: none; }
.endpoint-list code { color: var(--text-muted); word-break: break-all; text-align: right; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-title { font-weight: 600; font-size: 1rem; color: var(--text); margin: 0 0 .4rem; }
.empty-body { font-size: .85rem; line-height: 1.5; margin: 0 auto; max-width: 34ch; }

/* ---------- bottom tab bar ---------- */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  background: var(--tabbar-bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  height: calc(64px + env(safe-area-inset-bottom, 0));
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--tab-inactive);
  font-size: .68rem;
  padding-top: .35rem;
}
.tab-icon { font-size: 1.25rem; line-height: 1; }
.tab.active { color: var(--navy); }
:root.dark .tab.active { color: var(--gold); }
.tab.active .tab-label { font-weight: 700; }

/* ---------- responsive (tablet/desktop) ---------- */
@media (min-width: 720px) {
  .app-main { padding: 1.5rem; }
  .card { padding: 1.25rem; }
}

/* ---- auth / library sync (Settings) ---- */
.auth-form{display:flex;flex-direction:column;gap:8px;margin:12px 0 6px}
.auth-form input{padding:11px 13px;border:1.5px solid #cdd9e6;border-radius:8px;font-size:15px;font-family:inherit}
.auth-form input:focus{outline:none;border-color:#0F4C81}
.auth-error{color:#cc3300;font-size:13px;margin:8px 0 0;font-weight:600}
html.dark .auth-form input{background:#1a2733;border-color:#33475a;color:#e6eef5}

/* ───────────── In-app reader (offline article view) ───────────── */
body.reader-open { overflow: hidden; }
#reader-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(8, 16, 24, 0.55);
  display: flex; justify-content: center;
  overflow-y: auto;
  animation: reader-fade 0.15s ease;
}
@keyframes reader-fade { from { opacity: 0; } to { opacity: 1; } }
.reader-sheet {
  background: var(--bg);
  width: 100%; max-width: 720px;
  min-height: 100%;
  box-shadow: 0 0 40px rgba(0,0,0,0.25);
}
.reader-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  background: var(--header-bg); color: var(--header-text);
  padding: 10px 14px;
}
.reader-close {
  background: rgba(255,255,255,0.15); color: var(--header-text);
  border: none; border-radius: 8px;
  width: 32px; height: 32px; font-size: 15px; cursor: pointer;
  flex-shrink: 0;
}
.reader-close:hover { background: rgba(255,255,255,0.28); }
.reader-bar-title { font-size: 13px; font-weight: 600; opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-body { padding: 20px 18px 40px; }
.reader-title { font-size: 22px; line-height: 1.3; color: var(--text); margin: 4px 0 8px; }
.reader-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }
.reader-content { color: var(--text); font-size: 15px; line-height: 1.7; }
.reader-content p { margin: 0 0 14px; }
.reader-content strong { color: var(--text); }
.reader-loading, .reader-notice { color: var(--text-muted); font-style: italic; }
.reader-notice { font-style: normal; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
