: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: 16px;
  border-top: 1px solid var(--line);
}
#conn-status { color: var(--line); }
#conn-status.online { color: var(--ink); }

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