:root {
  --paper: #f4efe2;      /* vanilla / beige background */
  --paper-2: #efe8d8;    /* slightly deeper panel tone */
  --ink: #1a1a1a;        /* near-black text */
  --muted: #6b6457;      /* warm grey for secondary text */
  --line: #d8cfba;       /* hairline rules / borders */
  --line-soft: #e4dccb;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --radius: 3px;
}

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

body {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header — quiet, typographic, hairline underline */
.app-header {
  background: var(--paper);
  color: var(--ink);
  padding: 32px 20px 20px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  padding-top: calc(32px + env(safe-area-inset-top));
}
.app-header h1 {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tagline {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

/* Tabs — text with an underline on the active item */
.tabs {
  display: flex;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 12px 4px;
  font-family: var(--serif);
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 24px 18px; }

.view { display: none; }
.view.active { display: block; }

/* Cards — framed by a hairline, no shadow */
.card {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}
.card p { color: var(--ink); line-height: 1.6; margin-bottom: 8px; }
.card hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* Word card */
.word-card { text-align: center; }
.word-head { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.word-main {
  font-size: 2.6rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
}
.badge.pos { }
.badge.gender { }
.badge.level { }
.translation {
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
  margin: 10px 0 20px;
}

/* Example — a quiet blockquote with a left rule */
.example {
  border-left: 2px solid var(--line);
  padding: 4px 0 4px 16px;
  text-align: left;
  margin-top: 10px;
}
.example .pt { font-weight: 600; }
.example .en { color: var(--muted); font-size: 0.95rem; font-style: italic; margin-top: 4px; }
.notes { font-size: 0.88rem; color: var(--muted); margin-top: 16px; font-style: italic; }

/* Buttons — ink outline / ink fill, no colour */
.actions { display: flex; gap: 12px; margin-top: 4px; }
.btn {
  flex: 1;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 13px;
  border-radius: var(--radius);
  font-family: var(--serif);
  font-size: 0.95rem;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }

/* Quiz */
.quiz-card { text-align: center; min-height: 220px; }
.quiz-prompt { font-size: 2.1rem; font-weight: 600; color: var(--ink); margin: 18px 0; }
.quiz-answer { font-size: 1.1rem; color: var(--muted); font-style: italic; margin-bottom: 16px; }
.quiz-hidden { color: var(--line); }
.quiz-buttons { display: flex; gap: 12px; margin-top: 12px; }
.quiz-score { text-align: center; color: var(--muted); font-size: 0.9rem; }

/* Browse */
.search {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.95rem;
  margin-bottom: 16px;
}
.search:focus { outline: none; border-color: var(--ink); }
.browse-item {
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 14px 4px;
  margin-bottom: 0;
}
.browse-item .row { display: flex; justify-content: space-between; align-items: baseline; }
.browse-item .w { font-weight: 600; color: var(--ink); font-size: 1.1rem; }
.browse-item .t { color: var(--muted); font-size: 0.92rem; font-style: italic; }
.browse-item .ex { font-size: 0.88rem; color: var(--muted); margin-top: 4px; }

.status { font-size: 0.85rem; color: var(--muted); margin-top: 8px; font-style: italic; }
.meta-card p { font-size: 0.85rem; color: var(--muted); }

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 20px 16px 16px; /* extra top room for the ring over the "a" */
  border-top: 1px solid var(--line);
}
.app-footer .credit {
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.app-footer .credit:hover { color: var(--ink); }
/* The connection-status dot sits above the second "a" of Ozvaag, like a Nordic
   ring (å). Grey while offline, ink once /api/words answers — same rule as before. */
.ring-a { position: relative; display: inline-block; }
.ring-a #conn-status {
  position: absolute;
  left: 50%;
  top: -0.42em;
  transform: translateX(-50%);
  font-size: 0.5em;
  line-height: 1;
}
#conn-status { color: var(--line); }
#conn-status.online { color: var(--ink); }

.loading { color: var(--muted); text-align: center; font-style: italic; }

/* Notification interval picker (Definições) */
.pref-row { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.pref-row label { font-size: 0.9rem; color: var(--ink); }
.select {
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  cursor: pointer;
}
.pref-row .status { margin: 0; }

/* Level filter (Definições) */
.level-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.level-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
}
.level-chip input { accent-color: var(--ink); cursor: pointer; }

/* Conjugation (verb cards) — collapsed by default, deliberately quiet */
.conj {
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  text-align: left;
}
.conj summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  list-style-position: inside;
}
.conj summary:hover { color: var(--ink); }
.conj-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 10px; }
.conj-chip {
  font-family: var(--serif);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.conj-chip.active { border-color: var(--ink); color: var(--ink); }
.conj-table { border-collapse: collapse; font-size: 0.92rem; }
.conj-table td { padding: 3px 0; }
.conj-table .conj-p {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
  padding-right: 18px;
  white-space: nowrap;
}

/* Suggestions form (Definições) */
.textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  margin: 8px 0 10px;
}
.textarea:focus { outline: none; border-color: var(--ink); }
.suggest-contact { margin-bottom: 12px; }
