/* YHGĐ Hub — giao diện di động (Bộ môn Y học Gia đình, ĐHYK PNT) */
:root{
  /* Bảng màu = bộ nhận diện thương hiệu BSGD (lấy mẫu từ logo gốc bsgdtphcm.vn) */
  --teal:#00944a; --teal-dark:#0a5c31; --teal-deep:#063d22;      /* xanh chủ đạo */
  --brand-red:#cf1313; --brand-red-dark:#a30f0f; --brand-cream:#f7faf8;
  --ink:#12261e; --ink-2:#5b7268; --line:#dbe7e1; --bg:#f7faf8; --white:#fff;
  --amber:#c8860a; --indigo:#5c6bc0; --danger:#cf1313;
  --sh:0 2px 10px rgba(6,61,34,.10);
  --tab-h:64px; --top-h:60px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;height:100%}
body{
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
  background:var(--bg);color:var(--ink);font-size:15px;line-height:1.5;overscroll-behavior-y:contain;
}
a{color:var(--teal-dark)}
h1,h2,h3{margin:0 0 6px}
.muted{color:var(--ink-2);font-size:13.5px}
.hint{color:var(--ink-2);font-size:12.5px;margin:8px 0 0}
[hidden]{display:none !important}

/* ── Splash ── */
.splash{position:fixed;inset:0;background:linear-gradient(160deg,#00BFA5,#00695C);color:#fff;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;z-index:60}
.splash-logo img{width:88px;height:88px;border-radius:22px;box-shadow:0 10px 26px rgba(0,0,0,.25)}
.splash h1{margin:12px 0 0;font-size:22px;letter-spacing:.3px}
.splash p{margin:0;opacity:.9;font-size:13.5px}
.spinner{width:26px;height:26px;margin-top:18px;border:3px solid rgba(255,255,255,.35);
  border-top-color:#fff;border-radius:50%;animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ── Đăng nhập ── */
.login{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px 16px 40px;
  background:linear-gradient(170deg,#e8f7f4 0%,#f4f7f9 45%,#f4f7f9 100%)}
.login-card{width:100%;max-width:400px;background:var(--white);border-radius:18px;padding:24px 20px;
  box-shadow:0 12px 30px rgba(15,34,51,.10)}
.login-logo{width:64px;height:64px;border-radius:16px;display:block;margin:0 auto 10px}
.login h1{text-align:center;font-size:19px}
.login-sub{text-align:center;color:var(--ink-2);font-size:13px;margin:6px 0 18px}
#login-form label{display:block;font-size:13px;font-weight:600;color:var(--ink-2);margin:12px 0 6px}
#login-form input[type=text],#login-form input[type=password]{
  width:100%;padding:13px 14px;border:1.5px solid var(--line);border-radius:12px;font-size:16px;
  background:#fbfdfe;color:var(--ink)}
#login-form input:focus{outline:none;border-color:var(--teal);background:#fff}
.pass-wrap{position:relative}
.pass-eye{position:absolute;right:6px;top:6px;border:0;background:transparent;font-size:17px;padding:8px 10px;cursor:pointer}
.remember{display:flex;align-items:center;gap:8px;margin:14px 0 4px;font-size:13.5px;color:var(--ink-2)}
.login-error{margin-top:12px;background:#fdecea;border:1px solid #f5c6c2;color:#a5352c;
  border-radius:10px;padding:10px 12px;font-size:13.5px}
.btn-primary{width:100%;margin-top:16px;padding:14px;border:0;border-radius:12px;background:var(--teal);
  color:#fff;font-size:16px;font-weight:700;cursor:pointer;box-shadow:0 4px 14px rgba(0,191,165,.32)}
.btn-primary:active{transform:translateY(1px)}
.btn-primary[disabled]{opacity:.6;box-shadow:none}
.login-links{text-align:center;margin-top:16px;font-size:13px;color:var(--ink-2)}
.login-links .dot{margin:0 6px;color:#c3ccd5}
.login-foot{text-align:center;font-size:11.5px;color:#93a2b0;margin:18px 0 0}

/* ── Khung ứng dụng ── */
#topbar{position:fixed;top:0;left:0;right:0;height:var(--top-h);display:flex;align-items:center;gap:10px;
  padding:0 12px;padding-top:env(safe-area-inset-top);background:var(--white);border-bottom:1px solid var(--line);
  box-shadow:var(--sh);z-index:30}
.top-avatar{width:38px;height:38px;border-radius:50%;object-fit:cover;background:#e8eeea}
.top-info{flex:1;min-width:0}
.top-info strong{display:block;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top-info span{font-size:12px;color:var(--ink-2)}
.icon-btn{border:0;background:#f1f6f7;color:var(--teal-deep);width:38px;height:38px;border-radius:11px;
  font-size:17px;cursor:pointer}
.view{display:none;padding:calc(var(--top-h) + env(safe-area-inset-top) + 12px) 12px calc(var(--tab-h) + 24px)}
.view.active{display:block}
#view-feed{padding:calc(var(--top-h) + env(safe-area-inset-top)) 0 calc(var(--tab-h) + env(safe-area-inset-bottom));height:100vh}
.iframe-wrap{height:100%;background:#fff}
#feed-frame{width:100%;height:100%;border:0;display:block}

/* ── Hero ── */
.hero{display:flex;gap:12px;align-items:center;border-radius:16px;padding:16px;color:#fff;margin-bottom:14px}
.hero h2{font-size:17px}
.hero p{margin:2px 0 0;font-size:12.8px;opacity:.95}
.hero-icon{width:46px;height:46px;border-radius:13px;background:rgba(255,255,255,.2);display:grid;place-items:center;flex:0 0 auto}
.hero-icon svg{width:24px;height:24px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.hero-teal{background:linear-gradient(135deg,#00BFA5,#00897B)}
.hero-amber{background:linear-gradient(135deg,#f6a623,#e07b2a)}
.hero-indigo{background:linear-gradient(135deg,#5c6bc0,#3f51b5)}

/* ── Thẻ / danh sách ── */
.card{background:var(--white);border-radius:16px;padding:16px;box-shadow:var(--sh);margin-bottom:14px}
.card h3{font-size:15px;margin-bottom:10px}
.list{list-style:none;margin:0;padding:0}
.list li{border-bottom:1px solid var(--line);padding:11px 0;display:flex;gap:10px;align-items:flex-start}
.list li:last-child{border-bottom:0}
.list li a{text-decoration:none;color:var(--ink);font-weight:600;font-size:14px}
.list li .sub{display:block;font-weight:400;color:var(--ink-2);font-size:12.5px;margin-top:2px}
.list li .chev{margin-left:auto;color:#b6c1cb;font-size:18px;flex:0 0 auto}
.tag{display:inline-block;background:#e8f7f4;color:var(--teal-deep);border-radius:6px;padding:1px 7px;
  font-size:11px;font-weight:600;margin-right:6px}
.btn-ghost{display:inline-block;text-align:center;width:100%;margin-top:12px;padding:12px;border:1.5px solid var(--teal);
  border-radius:12px;background:#fff;color:var(--teal-deep);font-weight:600;font-size:14.5px;text-decoration:none;cursor:pointer}
.btn-ghost.sm{width:auto;padding:8px 14px;margin:0;font-size:13px}
.btn-danger{width:100%;padding:14px;border:0;border-radius:12px;background:#fdecea;color:var(--danger);
  font-weight:700;font-size:15px;cursor:pointer;margin-top:4px}

/* ── Tìm kiếm / chips ── */
.search-row{display:flex;gap:8px;margin-bottom:10px}
.search-row input{flex:1;padding:12px 14px;border:1.5px solid var(--line);border-radius:12px;font-size:15px;background:#fff}
.search-row input:focus{outline:none;border-color:var(--teal)}
.btn-search{border:0;background:var(--teal);color:#fff;border-radius:12px;padding:0 18px;font-weight:700;font-size:14px}
.chips{display:flex;gap:8px;overflow-x:auto;padding-bottom:8px;margin-bottom:8px;-webkit-overflow-scrolling:touch}
.chip{border:1.5px solid var(--line);background:#fff;color:var(--ink-2);border-radius:20px;padding:7px 13px;
  font-size:13px;white-space:nowrap;cursor:pointer}
.chip.on{background:var(--teal);border-color:var(--teal);color:#fff;font-weight:600}

/* ── Hồ sơ ── */
.profile-card{background:var(--white);border-radius:16px;padding:20px;text-align:center;box-shadow:var(--sh);margin-bottom:14px}
.profile-card img{width:76px;height:76px;border-radius:50%;object-fit:cover;background:#e8eeea}
.profile-card h2{font-size:17px;margin:10px 0 2px}
.badges{display:flex;gap:8px;justify-content:center;margin-top:10px}
.badge{font-size:11.5px;background:#eef2f6;color:var(--ink-2);border-radius:20px;padding:4px 10px}
.badge.ok{background:#e6f7f1;color:#00795f}

/* ── Trình phát ── */
.player{position:fixed;left:8px;right:8px;bottom:calc(var(--tab-h) + env(safe-area-inset-bottom) + 8px);
  background:#fff;border-radius:16px;box-shadow:0 -2px 20px rgba(15,34,51,.18);padding:12px;z-index:35}
.player-head{display:flex;align-items:center;gap:8px;margin-bottom:6px}
.player-head strong{flex:1;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.player audio{width:100%}
.player-actions{display:flex;align-items:center;gap:10px;margin-top:8px}

/* ── Tabbar ── */
#tabbar{position:fixed;bottom:0;left:0;right:0;height:calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom:env(safe-area-inset-bottom);background:#fff;border-top:1px solid var(--line);
  display:flex;z-index:40}
.tab{flex:1;border:0;background:transparent;color:#8a99a7;font-size:10.5px;font-weight:600;display:flex;
  flex-direction:column;align-items:center;justify-content:center;gap:3px;cursor:pointer;padding:6px 0}
.tab .ico svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.tab.active{color:var(--teal)}

/* ── Toast ── */
.toast{position:fixed;left:50%;bottom:calc(var(--tab-h) + 26px);transform:translateX(-50%);
  background:rgba(15,34,51,.92);color:#fff;padding:11px 16px;border-radius:11px;font-size:13.5px;z-index:70;max-width:90%}

/* ── v1.2: phụ trợ đồng bộ, nghe tiếp, thư viện 3 chế độ ── */
.sync-dot{width:9px;height:9px;border-radius:50%;background:var(--amber);margin-right:2px;
  animation:pulse 1s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:.35}50%{opacity:1}}
.center-note{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:10px;color:var(--ink-2);font-size:13.5px}
.center-note .spinner{margin:0;border-color:rgba(0,191,165,.25);border-top-color:var(--teal)}
.iframe-wrap{position:relative}
.row-actions{display:flex;gap:8px;align-items:center;margin-top:10px}
.row-actions .btn-ghost{flex:1;margin-top:0}

/* nghe tiếp */
.card.resume{border-top:3px solid var(--amber);padding:14px 16px}
.resume-head{display:flex;align-items:center;gap:8px;margin-bottom:6px}
.resume-head .tag{background:#fff4e2;color:#a9660a}
.pbar{display:block;height:5px;border-radius:3px;background:#eef2f6;margin-top:6px;overflow:hidden}
.pbar i{display:block;height:100%;background:var(--teal)}
.tag-done{background:#e6f7f1;color:#00795f}

/* thư viện: 3 chế độ */
.subtabs{display:flex;gap:6px;background:#eef2f6;border-radius:12px;padding:4px;margin-bottom:12px}
.subtab{flex:1;border:0;background:transparent;color:var(--ink-2);font-weight:600;font-size:13.5px;
  padding:9px 4px;border-radius:9px;cursor:pointer}
.subtab.active{background:#fff;color:var(--teal-deep);box-shadow:0 1px 4px rgba(15,34,51,.10)}
.libpane{display:none}
.libpane.active{display:block}
.answer{background:#fff;border-radius:14px;padding:14px 16px;box-shadow:var(--sh);margin-bottom:10px;
  border-left:4px solid var(--indigo)}
.answer-body{font-size:14.5px;line-height:1.65;white-space:normal}
.answer-src{margin-top:10px;padding-top:10px;border-top:1px solid var(--line);font-size:12.5px;color:var(--ink-2)}

/* ── v1.3: thanh thao tác nhanh cho bảng tin nhúng ── */
#view-feed{position:relative}
#view-feed.view.active{display:flex;flex-direction:column;height:100vh;
  padding-top:calc(var(--top-h) + env(safe-area-inset-top));padding-bottom:calc(var(--tab-h) + env(safe-area-inset-bottom))}
.feed-actions{flex:0 0 auto;display:flex;gap:8px;overflow-x:auto;padding:8px 10px;
  background:#fff;border-bottom:1px solid var(--line);-webkit-overflow-scrolling:touch}
.fbtn{display:inline-flex;align-items:center;gap:6px;border:1.5px solid var(--line);background:#fbfdfe;
  color:var(--ink);border-radius:20px;padding:7px 13px;font-size:13px;font-weight:600;white-space:nowrap;cursor:pointer}
.fbtn .ico svg{width:16px;height:16px;stroke:var(--teal-deep);fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.fbtn.on{background:var(--teal);border-color:var(--teal);color:#fff}
.fbtn.on .ico svg{stroke:#fff}
#view-feed .iframe-wrap{position:relative;flex:1 1 auto;height:auto}

/* ── v1.4: trạng thái bản audio đã tải + tìm kiếm ── */
.list-head{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted,#6b7280);
  padding:2px 2px 8px;margin:0}
.list-head b{color:#0f766e}
.dl-state{font-size:12.5px;background:#e8f7f4;color:#0b5b4c;border-radius:10px;
  padding:7px 10px;margin-top:8px;line-height:1.45}
.dl-state.warn{background:#fff4e2;color:#a9660a}
.tag-dl{background:#e0f2fe;color:#0369a1;margin-right:5px}
.tag-file{background:#f1f5f9;color:#475569;margin-right:5px}
.btn-ghost.sm.on{background:#0f766e;color:#fff;border-color:#0f766e}
.search-row .btn-ghost.sm{flex:0 0 auto;margin-top:0;padding:0 14px}
.search-row .icon-btn{flex:0 0 auto}
.chap-filter{margin:0 0 8px}
.chap-filter input{width:100%;padding:9px 12px;border:1.5px solid var(--line);border-radius:10px;font-size:14px}

/* ── v1.7: logo nhận diện thương hiệu ── */
/* Logo co giãn theo bề ngang khung (bộ nhận diện mới có tỉ lệ rộng hơn) */
.brand-logo{max-width:100%;max-height:34px;height:auto;width:auto;display:block}
.brand-logo--lg{max-height:56px}
.splash .brand-logo--lg{max-height:72px;margin:0 auto}
.login-logo{max-height:64px !important;max-width:100%;height:auto;width:auto}
#top-avatar{border-radius:50%}
.me-brand{display:flex;align-items:center;gap:10px;justify-content:center;margin-bottom:6px}
.me-brand img{max-height:38px;max-width:100%;height:auto;width:auto}

/* ── v1.8: khung đọc bản ghi thư viện trong ứng dụng ── */
.reader{position:fixed;inset:0;background:#fff;z-index:60;display:flex;flex-direction:column}
.reader-head{display:flex;align-items:center;gap:8px;padding:10px 12px;padding-top:calc(10px + env(safe-area-inset-top));
  border-bottom:1px solid var(--line);background:#fff}
.reader-head strong{flex:1;font-size:15px;line-height:1.3;max-height:2.6em;overflow:hidden}
.reader-meta{margin:0 12px;padding:8px 10px;background:var(--teal-50,#eaf8f0);border-radius:10px;
  font-size:12.5px;color:var(--teal-dark)}
.reader-body{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:12px 14px 20px;
  font-size:15.5px;line-height:1.62;color:var(--ink)}
.reader-body img{max-width:100%;height:auto;border-radius:8px}
.reader-body table{width:100%;border-collapse:collapse;font-size:14px;display:block;overflow-x:auto}
.reader-body td,.reader-body th{border:1px solid var(--line);padding:6px 8px;vertical-align:top}
.reader-body h1,.reader-body h2,.reader-body h3{font-size:17px;margin:16px 0 6px;color:var(--teal-deep)}
.reader-body ul,.reader-body ol{padding-left:20px;margin:8px 0}
.reader-body li{margin:4px 0}
.reader-body a{color:var(--teal-dark);text-decoration:underline}
.reader-body p{margin:8px 0}
.reader-body .hint{color:var(--ink-2)}
#reader-title{}
.reader-actions{display:flex;gap:8px;padding:10px 12px;padding-bottom:calc(10px + env(safe-area-inset-bottom));
  border-top:1px solid var(--line);background:#fff}
.reader-actions .btn-ghost{flex:1;margin-top:0}
.list-hint{font-size:12.5px;color:var(--ink-2);padding:4px 2px 8px}

/* ── v1.9: thẻ gợi ý cài ứng dụng (chỉ hiện trên điện thoại chưa cài) ── */
.install-card{background:#eaf8f0;border:1px solid #cfeedd;border-radius:14px;padding:11px 12px;margin:0 0 14px}
.install-card .install-row{display:flex;align-items:flex-start;gap:9px}
.install-card .install-icon{flex:0 0 32px;height:32px;border-radius:9px;background:#00944a;
  display:flex;align-items:center;justify-content:center;margin-top:1px}
.install-card .install-icon svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round}
.install-card .install-text{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.4}
.install-card .install-text b{font-size:13.5px;color:#063d22}
.install-card .install-text span{font-size:12.3px;color:#5b7268}
.install-card .icon-btn{flex:0 0 auto;opacity:.55;font-size:15px;padding:2px 4px}
.install-card .install-cta{display:block;width:100%;text-align:center;margin-top:9px;text-decoration:none}

/* ── v1.6: thẻ "có bản cập nhật" + huy hiệu trên tab + chip trạng thái bài tập ── */
.update-card{position:sticky;bottom:0;margin:0 0 8px;background:#fff8e6;border:1px solid #f0dca8;border-radius:14px;padding:10px 12px}
.update-card .uc-row{display:flex;align-items:flex-start;gap:9px}
.update-card .uc-ico{flex:0 0 32px;height:32px;border-radius:9px;background:#00944a;display:flex;align-items:center;justify-content:center}
.update-card .uc-ico svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.update-card .uc-text{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.4}
.update-card .uc-text b{font-size:13.5px;color:#7a5c00}
.update-card .uc-text span{font-size:12.3px;color:#8a6d1f}
.update-card .icon-btn{flex:0 0 auto;opacity:.55;font-size:15px}
.update-card .uc-cta{display:block;width:100%;margin-top:9px}
.tab{position:relative}
.tab-badge{position:absolute;top:4px;right:10px;background:#cf1313;color:#fff;font-size:10px;line-height:1;
  padding:3px 5px;border-radius:9px;font-weight:700}
.stat-row{display:flex;gap:8px;margin-bottom:10px}
.stat-row .st{flex:1;background:#fff;border:1px solid #e3ece7;border-radius:12px;padding:9px 10px;text-align:center}
.stat-row .st b{display:block;font-size:17px;color:#00944a}
.stat-row .st span{font-size:11.5px;color:#6b7d76}
.chip-st{display:inline-block;font-size:11px;padding:2px 7px;border-radius:8px;margin-right:5px;font-weight:600}
.chip-todo{background:#fdecec;color:#b3261e}
.chip-replied{background:#fff6e0;color:#8a6d1f}
.chip-graded{background:#e7f7ee;color:#0a5c31}

/* ── v1.7: khối hướng dẫn môn học ── */
.guide-card{background:#f4faf7;border:1px solid #d9ece2}
.guide-card h3{font-size:14.5px;margin:0 0 7px;color:#0a5c31}
.guide-card p{font-size:13.5px;line-height:1.55;color:#41604f;margin:0 0 9px}
.guide-list{margin:0 0 4px 18px;padding:0}
.guide-list li{font-size:13.2px;line-height:1.6;color:#41604f}
.guide-card .btn-ghost{margin-top:8px}
