body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
#app { padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); max-width: 720px; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--topbar-bg, var(--surface-2)); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0;
  font-size: 12px; color: var(--muted); text-decoration: none;
}
.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--primary-text); font-weight: 600; }

.reauth-banner {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface-2); border-bottom: 2px solid var(--bad); color: var(--text);
}
.reauth-banner[hidden] { display: none; }
.settings-card { padding: 16px; margin-bottom: 16px; }
.settings-card h2 { margin: 0 0 8px; font-size: 16px; }
.settings-card .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.settings-card input[type=range] { flex: 1; min-width: 120px; }
.sync-error { color: var(--bad); }

.word-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.word-toolbar input[type=search] { flex: 1 1 100%; }
.word-toolbar input, .word-toolbar select { min-height: 44px; box-sizing: border-box; }
.word-toolbar select { flex: 1; }
.word-list { list-style: none; margin: 0; padding: 0; }
.word-item { border-bottom: 1px solid var(--line); }
.word-row {
  display: flex; align-items: baseline; gap: 12px; width: 100%; min-height: 44px; padding: 10px 4px;
  text-align: left; background: none; border: none; box-shadow: none; border-radius: 0;
}
.word-row .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-open { padding: 0 4px 12px; }
.word-open .row { display: flex; gap: 12px; margin-top: 12px; }
.word-open button { min-height: 44px; min-width: 44px; }
.word-open .occurrences a { display: inline-block; padding: 10px 0; }
.word-list .empty { padding: 16px 4px; }
.word-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.home-due { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.home-start .row { display: flex; gap: 8px; }
.home-start input { flex: 1; min-height: 44px; box-sizing: border-box; }
.home-start button, .home-due .button { min-height: 44px; }
.home-start > button, .home-start > .sync-error { display: block; margin-top: 8px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.button { display: inline-flex; align-items: center; padding: 0 16px; border-radius: 8px; text-decoration: none; }
/* The scope select is as wide as its longest option (a video title); wider than the phone it widened the
   layout viewport and pushed the fixed tab bar off screen. */
.mobile-review .review-header select { flex: 1 1 100%; min-width: 0; max-width: 100%; min-height: 44px; }
.mobile-review .rate, .mobile-review .ratings .primary { min-height: 48px; }
.mobile-review .ratings { display: flex; gap: 8px; }
.mobile-review .ratings button { flex: 1; }
.mobile-review .review-card { cursor: pointer; overflow-wrap: anywhere; }

/* Learning page, portrait: video, current sentence, then the transcript scrolling in what is left. */
.learn.portrait {
  display: flex; flex-direction: column; gap: 12px;
  height: calc(100dvh - 96px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.learn-video { position: relative; flex: none; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.learn-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.learn-msg { flex: none; display: flex; flex-direction: column; gap: 8px; }
.learn-msg[hidden] { display: none; }
.learn-msg p { margin: 0; }
.learn-msg button, .learn-msg .button { align-self: flex-start; min-height: 44px; }
.learn-current .upcoming { opacity: .6; }
.learn-current { flex: none; min-height: calc(var(--sub-size) * 1.6); font-size: var(--sub-size); line-height: 1.6; font-weight: 500; }
.learn-list-wrap { position: relative; flex: 1; min-height: 0; }
.learn-list { position: relative; height: 100%; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.learn-row { padding: 10px 8px; font-size: 17px; line-height: 1.7; border-bottom: 1px solid var(--line); cursor: pointer; }
.learn-row.current { background: var(--primary-soft); }
.learn .w { padding: 2px 1px; border-radius: 4px; cursor: pointer; }
.learn .w.saved { background: rgba(255, 213, 79, .55); }
.learn .w.hit { background: var(--primary); color: var(--primary-ink); }
.learn-back {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); min-height: 40px; padding: 0 16px;
  border-radius: 999px; background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-hover);
}
.learn-back[hidden] { display: none; }
.learn-msg .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Landscape: fake fullscreen. The video fills the screen, the current sentence sits over its bottom edge, the list is hidden. */
.learn.landscape { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; }
.learn.landscape .learn-video { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; }
.learn.landscape .learn-list-wrap { display: none; }
.learn.landscape .learn-msg { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; padding: 8px 12px; border-radius: 8px; background: rgba(0, 0, 0, .75); }
.learn.landscape .learn-msg a { color: inherit; }
.learn.landscape .learn-current {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; min-height: 0; text-align: center;
  padding: 6px max(48px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(48px, env(safe-area-inset-left)); background: rgba(0, 0, 0, .65);
}
.learn.landscape .learn-current:empty { display: none; }
.learn.landscape .w.saved { color: #000; }
.learn-fs {
  display: none; position: absolute; top: 8px; right: 8px; z-index: 3; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 22px;
}
.learn.landscape .learn-fs:not([hidden]) { display: block; }
.learn-fs.on { background: var(--primary); color: var(--primary-ink); }

/* Split (tablet in landscape): the video and the big cue block on the left, the whole transcript beside them. */
/* The body becomes a column (banner, install hint, app) so the learning page fills what the tab bar leaves. */
body:has(.learn.split) { display: flex; flex-direction: column; height: 100dvh; box-sizing: border-box; overflow: hidden; }
#app:has(.learn.split) { max-width: none; width: 100%; box-sizing: border-box; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.learn.split {
  position: relative; display: grid; gap: 12px 16px; flex: 1; min-height: 0;
  grid-template-columns: 3fr 2fr; grid-template-rows: auto auto 1fr;
  grid-template-areas: "video list" "msg list" "current list";
}
.learn.split:fullscreen, .learn.split:-webkit-full-screen {
  position: fixed; inset: 0; width: 100%; height: 100dvh; box-sizing: border-box; padding: 12px; background: var(--bg);
}
.learn.split .learn-video { grid-area: video; }
.learn.split .learn-msg { grid-area: msg; }
.learn.split .learn-msg:empty, .learn.split .learn-msg[hidden] { display: none; }
.learn.split .learn-current { grid-area: current; min-height: 0; overflow-y: auto; }
.learn.split .learn-list-wrap { grid-area: list; }
.learn.split .learn-list { border-top: 0; border-left: 1px solid var(--line); }
/* The card is placed against the container's own box, so the (empty) sheet must not be the containing block. */
.learn.split .learn-sheet { display: contents; }
.learn.split .learn-fs:not([hidden]) { display: block; }
.learn.split .learn-fs { right: auto; left: 8px; }

.install-hint {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--primary); color: var(--primary-ink);
}
.install-hint span { flex: 1; }
.install-hint a { color: inherit; font-weight: 600; }
.install-hint button { background: transparent; color: inherit; font-size: 20px; padding: 0 8px; }
.help-origin { word-break: break-all; }
