/* Phone layout on top of the shared desktop styles. */
body { padding-top: env(safe-area-inset-top); }
.topbar { padding: 6px 12px; }
.brand span { display: inline; font-size: 15px; }

.tabbar {
  flex: none;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--accent); font-weight: 600; }
.tabbar .ico { font-size: 18px; line-height: 1.2; }
/* The player has its own controls bar at the bottom; hide the tabs there. */
body.in-player .tabbar { display: none; }

/* Library: one page that scrolls as a whole (the parts inside it don't scroll on their own, or
   the episodes would be squeezed into a sliver under everything else). The side list becomes
   strips that scroll sideways: the kinds of thing, then (under "Podcasts") the podcasts. */
.library { display: block; height: auto; min-height: 100%; }
.sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: none; padding: 8px 12px; gap: 8px; overflow: visible; }
.lib-main { overflow: visible; }
#podcast-list { padding-top: 2px; margin-bottom: 4px; }
/* The header row that stays at the top (web/css/media.css): here it starts with the kinds, as
   small pills in one line that scrolls sideways. */
.lib-bar { top: 0; margin: 0 -12px 8px; padding: 6px 12px 2px; }
.lib-bar .kind-row { flex-direction: row; overflow-x: auto; gap: 6px; padding: 0 0 2px; scrollbar-width: none; }
.lib-bar .kind-row::-webkit-scrollbar { display: none; }
.lib-bar .kind-row .feed-item { flex: none; flex-direction: row; width: auto; gap: 6px; padding: 6px 12px 6px 10px; border-radius: 99px; background: var(--surface-2); }
/* The chosen kind: a dark teal pill with a teal edge, so its white icon and label read as well as the others'. */
.lib-bar .kind-row .feed-item.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.lib-bar .kind-row .feed-item .ph.all { width: 20px; height: 20px; background: transparent; color: inherit; }
.lib-bar .kind-row .feed-item .ph.all svg { width: 20px; height: 20px; }
.lib-bar .kind-row .feed-item .t { font-size: 13px; font-weight: 600; white-space: nowrap; -webkit-line-clamp: 1; }
/* The status pills get the whole width; "Filter by title" has its own line under them. */
.lib-bar .filter-row { flex-wrap: wrap; gap: 0 8px; }
.lib-bar .filter-row .tabs { flex: 1 0 100%; margin: 4px 0; }
.lib-bar #title-filter { flex: 1 0 100%; min-width: 0; min-height: 34px; margin: 2px 0 4px; }
.lib-bar .toolbar { padding: 2px 0 6px; gap: 6px; }
.lib-bar .toolbar button { min-height: 32px; padding: 2px 10px; font-size: 13px; }
.lib-bar .toolbar #refresh { padding: 2px 6px; }
/* The + button sits above the tab bar, in thumb reach. */
.add-fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
body:has(.add-fab) .toasts { bottom: calc(144px + env(safe-area-inset-bottom)); }
.feed-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
.feed-item { flex: none; flex-direction: column; width: 84px; text-align: center; gap: 4px; padding: 4px; }
.feed-item .t { font-size: 12px; -webkit-line-clamp: 2; }
.feed-item .small { display: none; }
.feed-item img, .feed-item .ph { width: 56px; height: 56px; }
.lib-main { padding: 0 12px 104px; }
.lib-head img { width: 56px; height: 56px; }
.lib-head h1 { font-size: 18px; }
.toolbar { top: 0; }
.ep { grid-template-columns: auto 44px 1fr; padding: 8px; gap: 8px; }
.ep img, .ep .ph { width: 44px; height: 44px; }
.ep .status { grid-column: 1 / -1; align-items: stretch; min-width: 0; }
.ep .status .row { justify-content: flex-end; }

.page { padding: 12px 12px 24px; }
.settings select, .settings input[type=text], .settings input[type=password] { width: 100%; }
.stack-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.vocab-item { grid-template-columns: 1fr; }
/* Messages: the width of a phone's screen less its margins; in a wider window (the web app on a
   computer, a tablet) a box at the bottom right as on the desktop, never a bar across the window. */
.toasts { left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); align-items: stretch; }
.toast { max-width: none; }
@media (min-width: 640px) {
  .toasts { align-items: flex-end; }
  .toast { max-width: min(420px, 100%); }
}
button, .btn { min-height: 38px; }
.tabbar a { position: relative; }

/* ---------- Tamkeen: labelled bottom tabs, easy to reach and read ---------- */
.tabbar { box-shadow: 0 -6px 20px rgba(0, 0, 0, .08); border-top: none; }
.tabbar a { padding: 8px 0 9px; font-size: 11.5px; transition: transform .08s ease, color .12s ease; }
.tabbar .ico { font-size: 20px; width: 52px; height: 28px; border-radius: 99px; display: grid; place-items: center; transition: background-color .15s ease; }
.tabbar a.active .ico { background: var(--accent-soft); }
.tabbar .nav-count { top: 3px; margin-left: 22px; }
.brand span { font-size: 17px; }

/* ---------- swipe between sections: the highlight blob slides between tabs ---------- */
.tabbar { position: relative; }
.tab-blob { position: absolute; left: 0; top: 0; width: 52px; height: 28px; border-radius: 99px; background: var(--accent-soft);
  pointer-events: none; opacity: 0; will-change: transform; }
.tabbar.has-blob a { position: relative; z-index: 1; }
.tabbar.has-blob a.active .ico { background: transparent; }
#view { overflow-x: hidden; }

/* The update popup sits above the tab bar, in thumb reach. */
.update-notice { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }

/* ---------- tab bar icons: the app's own line icons (web/js/icons.js) ---------- */
.tabbar a { color: var(--muted); }
.tabbar .ico { color: inherit; }
.tabbar .ico svg { display: block; transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), stroke-width .15s ease; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .ico svg { transform: translateY(-1px) scale(1.08); stroke-width: 2.1; }
.tabbar a.active .ic .fill { opacity: .22; }
.tabbar a:active .ico svg { transform: scale(.9); }
.top-search { display: inline-flex; align-items: center; gap: 6px; }
.top-ico { display: inline-flex; }

/* The web app's "add to home screen" button and its steps (web-install.js) */
.top-install { margin-inline-start: auto; color: #fff; padding: 0; width: 36px; height: 36px; min-width: 0; display: inline-grid; place-items: center; position: relative; border-radius: 50%; isolation: isolate; }
/* A purple ring travelling round the button, so it is noticed (only shown in a browser tab, see web-install.js) */
.top-install::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; z-index: -1; padding: 2px;
  background: conic-gradient(from var(--ring-turn, 0deg), transparent 0deg, #e08ade 90deg, #8e2b8c 180deg, transparent 270deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); animation: top-install-ring 2.4s linear infinite; }
@property --ring-turn { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes top-install-ring { to { --ring-turn: 360deg; } }
@media (prefers-reduced-motion: reduce) { .top-install::before { animation: none; background: #e08ade; } }
.top-install + .top-search { margin-inline-start: 4px; }
.install-steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 10px; line-height: 1.5; }


/* The web app's "Reconnect Google" (app.js boot): a small pill in the top bar while Google's hour-long pass has run out. */
.top-reconnect { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; min-height: 0;
  border: 0; border-radius: 99px; background: #8f1d84; color: #fff; font-size: 13px; } /* (the brand purple, as on new words) */
.top-reconnect[hidden] { display: none; }
.top-install + .top-reconnect { margin-inline-start: 4px; }
.top-reconnect:not([hidden]) + .top-search { margin-inline-start: 4px; }
@media (max-width: 420px) { .top-reconnect span { display: none; } .top-reconnect { padding: 7px; } }
/* The refresh button (components/refreshbutton.js) sits just before Search; while "Reconnect Google"
   shows it steps aside (that button does the same). */
.top-refresh { width: 32px; height: 32px; }
.top-install ~ .top-refresh { margin-inline-start: 4px; }
.top-reconnect:not([hidden]) ~ .top-refresh { display: none; }
.top-reconnect:not([hidden]) ~ .top-search { margin-inline-start: 4px; }
/* A narrow phone: tighter gaps; with the web app's install button there too, Search is its icon alone. */
@media (max-width: 420px) {
  .topbar { gap: 8px; }
  .top-install ~ .top-search { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; }
  .top-install ~ .top-search span:not(.top-ico) { display: none; }
}

/* The web app's "Updated to version …" (app.js versionBanner): a small brand-teal pill at the top left, for a few seconds. */
.version-banner { position: fixed; left: 12px; z-index: 75; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);
  padding: 6px 6px 6px 14px; border-radius: 99px; background: #0b8693; color: #fff; font-size: 13px; font-weight: 600;
  animation: version-in .3s ease-out both; }
.version-banner a { color: #fff; text-decoration: underline; font-weight: 500; white-space: nowrap; }
/* "What's new": a button that opens the list of new features under the banner (app.js versionBanner) */
.version-banner:has(.version-banner-row) { flex-direction: column; align-items: stretch; gap: 6px; }
.version-banner-row { display: flex; align-items: center; gap: 10px; }
.version-banner-more { display: inline-flex; align-items: center; gap: 3px; background: transparent; border: 0; padding: 0; min-height: 0;
  color: #fff; font: inherit; font-weight: 600; text-decoration: underline; white-space: nowrap; cursor: pointer; }
.version-banner-more .ic { transform: rotate(90deg); transition: transform .15s; }
.version-banner-more[aria-expanded="true"] .ic { transform: rotate(-90deg); }
.version-banner-list { margin: 0; padding: 0 4px 2px 20px; max-width: 360px; font-size: 13px; line-height: 1.45; }
.version-banner-list li { margin: 3px 0; }
.version-banner-list[hidden] { display: none; }
.version-banner-close { background: transparent; border: 0; color: #fff; padding: 4px; min-height: 0; border-radius: 50%; display: grid; place-items: center; }
.version-banner-close:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.version-banner.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .35s, transform .35s; }
@keyframes version-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .version-banner { animation: none; } .version-banner.leaving { transition: none; } }
/* With the list open the pill becomes a rounded card. */
.version-banner:has(.version-banner-list:not([hidden])) { border-radius: 16px; padding-bottom: 10px; }

/* The "?" (components/helpbutton.js) sits just before refresh. After the web app's install button or
   "Reconnect Google" it keeps close to them; on a narrow phone Search is its icon alone, to make room. */
.top-install ~ .top-help, .top-reconnect:not([hidden]) ~ .top-help { margin-inline-start: 4px; }
.top-help { width: 32px; height: 32px; }
.xp-badge { width: 32px; height: 32px; } /* the game's level badge (game/xpbadge.js), just before the "?" */
@media (max-width: 420px) {
  .top-search { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; }
  .top-search span:not(.top-ico) { display: none; }
}
