/* ===== LINGULIA — Mental Health Edition ===== */
@font-face {
  font-family: "Noto Sans Ethiopic";
  src: url("../fonts/NotoSansEthiopic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Ethiopic";
  src: url("../fonts/NotoSansEthiopic-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --teal: #0E7C7B;
  --teal-dark: #0a5e5d;
  --teal-light: #e3f1f0;
  --amber: #F2B44B;
  --ink: #14302f;
  --muted: #5d7271;
  --bg: #f6faf9;
  --card: #ffffff;
  --line: #d9e6e4;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --radius: 14px;
  --maxw: 720px;
  --tabbar-h: 64px;
  font-size: 17px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans Ethiopic", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}
h1, h2, h3 { line-height: 1.25; }
button { font-family: inherit; cursor: pointer; }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--teal); color: #fff;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,.18); font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.05rem; letter-spacing: .5px; }
.brand-text small { font-size: .68rem; opacity: .85; }
.header-right { display: flex; align-items: center; gap: 10px; }
.net-status { display: inline-flex; align-items: center; gap: 5px; font-size: .65rem; opacity: .9; }
.net-status .dot { width: 9px; height: 9px; border-radius: 50%; background: #e74c3c; display: inline-block; }
.net-status.online .dot { background: #2ecc71; }
.lang-toggle { display: flex; background: rgba(255,255,255,.16); border-radius: 999px; padding: 3px; }
.lang-btn {
  border: 0; background: transparent; color: #fff; font-size: .82rem;
  padding: 6px 11px; border-radius: 999px; min-width: 40px;
}
.lang-btn.active { background: #fff; color: var(--teal-dark); font-weight: 700; }

/* ===== Disclaimer ===== */
.disclaimer {
  display: flex; gap: 8px; align-items: flex-start;
  background: #fff7e6; color: #7a5a10; border-bottom: 1px solid #f0e0bf;
  font-size: .78rem; padding: 8px 14px;
}

/* ===== Main / views ===== */
#main { max-width: var(--maxw); margin: 0 auto; padding: 14px; }
.view { animation: fade .2s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Search ===== */
.search-bar input {
  width: 100%; font-size: 1.05rem; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
}
.search-bar input:focus { outline: none; border-color: var(--teal); }
.hint { color: var(--muted); font-size: .82rem; margin: 10px 2px; }

/* Search home (shown when the box is empty) */
.search-home { margin-top: 24px; }
.search-suggest .ss-label { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.ss-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.ss-chip { border: 1.5px solid var(--line); background: var(--card); color: var(--teal-dark); border-radius: 999px; padding: 9px 15px; font-size: .92rem; font-weight: 600; font-family: inherit; }
.ss-chip:active { background: var(--teal-light); border-color: var(--teal); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 26px; }
.qa-tile { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 12px; color: inherit; font-family: inherit; }
.qa-tile:active { background: var(--teal-light); }
.qa-tile .qa-ico { font-size: 1.7rem; }
.qa-tile .qa-name { font-weight: 700; }
.qa-tile .qa-desc { color: var(--muted); font-size: .78rem; }
@media (max-width: 480px) { .quick-actions { grid-template-columns: 1fr; } }

/* "Voice coming soon" pill (Amharic / Afaan Oromo on-device voice is a future plan) */
.voice-soon { display: inline-flex; align-items: center; gap: 5px; background: #eef3f2; color: #8aa3a1; border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; font-size: .72rem; white-space: nowrap; }

/* ===== Term list ===== */
.term-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.term-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left; color: inherit;
}
.term-card:active { background: var(--teal-light); }
.term-card .tc-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.term-card .tc-primary { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.term-card .tc-secondary { color: var(--muted); font-size: .85rem; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-card .chip { flex-shrink: 0; }
.chip {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .4px;
  background: var(--teal-light); color: var(--teal-dark);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.chip.draft { background: #fdeedd; color: #9a6312; }

/* ===== Browse categories ===== */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px; text-align: left; color: inherit; min-height: 92px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cat-card:active { background: var(--teal-light); }
.cat-card .cc-icon { font-size: 1.5rem; }
.cat-card .cc-name { font-weight: 700; margin-top: 8px; }
.cat-card .cc-count { color: var(--muted); font-size: .78rem; }
.back-btn { border: 0; background: none; color: var(--teal-dark); font-weight: 700; font-size: .95rem; padding: 6px 0; margin-bottom: 4px; }

/* ===== Term modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,30,29,.55); display: grid; align-items: end; }
.modal-card {
  background: var(--card); width: 100%; max-width: var(--maxw); margin: 0 auto;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom,0px));
  max-height: 86vh; overflow: auto; position: relative; animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-close { position: absolute; top: 12px; right: 12px; border: 0; background: var(--teal-light); color: var(--teal-dark); width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; }
.lang-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.lang-row:last-child { border-bottom: 0; }
.lang-row .lr-flag { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.lang-row .lr-term { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lang-row .lr-phon { color: var(--muted); font-style: italic; font-size: .85rem; }
.lang-row .lr-def { margin-top: 4px; font-size: .95rem; }
.lang-row .lr-lay { margin-top: 6px; font-size: .85rem; }
.lang-row .lr-lay b { color: var(--muted); font-weight: 600; }
.speak-btn { border: 0; background: var(--teal-light); color: var(--teal-dark); border-radius: 999px; padding: 4px 10px; font-size: .8rem; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }

/* ===== Screening ===== */
.screen-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.screen-item .si-q { font-weight: 600; margin-bottom: 10px; }
.screen-opts { display: grid; gap: 8px; }
.screen-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: .92rem; }
.screen-opt.selected { border-color: var(--teal); background: var(--teal-light); }
.screen-opt input { accent-color: var(--teal); width: 20px; height: 20px; }
.primary-btn { width: 100%; border: 0; background: var(--teal); color: #fff; font-size: 1.05rem; font-weight: 700; padding: 16px; border-radius: var(--radius); margin-top: 6px; }
.primary-btn:disabled { opacity: .5; }
.result-box { border-radius: var(--radius); padding: 16px; margin-top: 8px; }
.result-box.minimal { background: #eafaf1; border: 1px solid #b9e6cc; }
.result-box.mild { background: #fef7e3; border: 1px solid #f3e1ad; }
.result-box.moderate { background: #fdeede; border: 1px solid #f3cf9d; }
.result-box.severe { background: var(--danger-bg); border: 1px solid #f3b6ae; }
.result-box .rb-score { font-size: 2rem; font-weight: 800; }
.result-box .rb-sev { font-weight: 700; }
.flag-alert { background: var(--danger-bg); border: 1.5px solid var(--danger); color: var(--danger); border-radius: var(--radius); padding: 14px; margin: 12px 0; font-weight: 600; }

/* ===== Phrases ===== */
.phrase-group { margin-bottom: 18px; }
.phrase-group h3 { font-size: .95rem; color: var(--teal-dark); margin: 0 0 8px; }
.phrase-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.phrase-card .pc-target { font-size: 1.12rem; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.phrase-card .pc-en { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.phrase-card .pc-phon { color: var(--muted); font-style: italic; font-size: .78rem; margin-top: 2px; }

/* ===== AI ===== */
.ai-settings { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.ai-settings label { display: block; font-size: .8rem; color: var(--muted); margin: 10px 0 4px; }
.ai-settings select, .ai-settings input { width: 100%; padding: 10px; border: 1.5px solid var(--line); border-radius: 10px; font-size: .95rem; }
.ai-chat { display: flex; flex-direction: column; gap: 10px; }
.ai-msgs { display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.ai-msg { padding: 10px 12px; border-radius: 12px; max-width: 88%; font-size: .95rem; white-space: pre-wrap; }
.ai-msg.user { background: var(--teal); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.ai-msg.bot { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 3px; }
.ai-msg.sys { background: #fff7e6; color: #7a5a10; align-self: center; font-size: .82rem; text-align: center; }
.ai-input-row { display: flex; gap: 8px; }
.ai-input-row input { flex: 1; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: .95rem; }
.ai-input-row button { border: 0; background: var(--teal); color: #fff; border-radius: 10px; padding: 0 16px; font-weight: 700; }

/* ===== About ===== */
.about-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.about-card h3 { margin-top: 0; }
.about-card ul { padding-left: 18px; margin: 8px 0; }
.about-card li { margin-bottom: 6px; font-size: .92rem; }
.emerg { border-left: 4px solid var(--danger); }
.emerg h4 { color: var(--danger); margin: 0 0 6px; }
.muted { color: var(--muted); font-size: .82rem; }

/* ===== Tabbar ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .62rem;
}
.tab .tab-ico { font-size: 1.2rem; filter: grayscale(1); opacity: .7; }
.tab.active { color: var(--teal-dark); font-weight: 700; }
.tab.active .tab-ico { filter: none; opacity: 1; }

@media (min-width: 560px) {
  .cat-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* Very small phones: trim the header and shrink the tab bar so nothing overflows */
@media (max-width: 360px) {
  .app-header { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .brand-text small { display: none; }
  .header-right { gap: 6px; }
  .net-status #net-label { display: none; }
  .lang-btn { padding: 6px 9px; min-width: 30px; font-size: .76rem; }
  .tab { font-size: .56rem; }
  .tab .tab-ico { font-size: 1.05rem; }
  #main { padding: 12px; }
}
