.mobile-system-bar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: calc(var(--mobile-system-bar-height) + var(--safe-area-top));
  padding:
    var(--safe-area-top)
    calc(10px + var(--safe-area-right))
    0
    calc(10px + var(--safe-area-left));
  border-bottom: 1px solid var(--line);
  background: var(--bg-0);
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  user-select: none;
}

body.android-shell .mobile-system-bar {
  display: flex;
}

.mobile-system-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.mobile-system-indicators,
.mobile-network-status,
.mobile-battery-status {
  display: inline-flex;
  align-items: center;
}

.mobile-system-indicators {
  gap: 10px;
}

.mobile-network-status,
.mobile-battery-status {
  gap: 4px;
  min-height: 22px;
}

.mobile-network-status svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.mobile-network-status.offline {
  color: var(--muted);
}

.battery-icon {
  position: relative;
  display: inline-flex;
  width: 19px;
  height: 10px;
  padding: 1px;
  border: 1px solid currentColor;
  border-radius: 2px;
}

.battery-icon::after {
  position: absolute;
  top: 2px;
  right: -3px;
  width: 2px;
  height: 4px;
  border-radius: 0 1px 1px 0;
  background: currentColor;
  content: "";
}

.battery-icon > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 1px;
  background: currentColor;
  transition: width 180ms ease;
}

.mobile-battery-status.charging {
  color: var(--mint-text);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1600px;
  /* Android 12 WebView may not parse dynamic viewport units. Keep a
     standards-compatible fallback before the newer value overrides it. */
  height: 100vh;
  max-height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding:
    calc(14px + var(--safe-area-top))
    calc(14px + var(--safe-area-right))
    calc(14px + var(--safe-area-bottom))
    calc(14px + var(--safe-area-left));
  display: grid;
  grid-template-areas:
    "topbar"
    "navigation"
    "announcement"
    "content"
    "jobs";
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
}

body.android-shell .app-shell {
  padding-top: calc(14px + var(--safe-area-top) + var(--mobile-system-bar-height));
}

.boot-overlay {
  position: fixed;
  /* Issue #362: longhands first for WebViews older than Chrome 87. */
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--bg-0);
  transition: opacity 180ms ease, visibility 180ms ease;
}

body.app-ready .boot-overlay {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Issue #349: 启动卡片去掉了图标，网格从「图标/文案/转圈」三列改为
   「文案/转圈」两列，否则文案会被塞进原来图标的窄列里。 */
.boot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(520px, calc(100vw - 36px));
  padding: 18px;
}

.boot-copy {
  min-width: 0;
}

.boot-title {
  font-size: 17px;
  font-weight: 700;
}

.boot-message {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Issue #362: compat.js explains a stuck start instead of spinning forever. */
.boot-guard-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.boot-guard-reload {
  margin-top: 10px;
  padding: 6px 14px;
  border: 1px solid var(--line, rgba(127, 127, 127, 0.35));
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
}

.topbar {
  grid-area: topbar;
  min-width: 0;
  padding: 10px 12px;
}

.topbar-main {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(300px, auto);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-block {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--m3-shape-md);
  object-fit: cover;
  background: var(--m3-primary-container);
}

.brand-copy,
.brand-title {
  min-width: 0;
}

.brand-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-status {
  display: grid;
  grid-template-columns: minmax(110px, auto) auto auto auto auto;
  align-items: center;
  justify-content: end;
  gap: 6px;
  width: auto;
  min-width: 0;
  min-height: 44px;
  padding: 5px 6px 5px 10px;
  border: 0;
  background: var(--m3-surface-container-high);
}

.topbar-status > :first-child {
  min-width: 0;
}

.status-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-value {
  max-width: 190px;
  margin-top: 2px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-progress {
  width: min(180px, 100%);
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-1);
}

.update-progress.hidden,
.update-action-button.hidden {
  display: none;
}

.update-progress-bar {
  width: 2%;
  transition: width 160ms ease;
}

.update-action-button {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--accent-2);
  background: var(--panel-3);
  color: var(--accent-2-text);
  font-size: 12px;
  font-weight: 700;
}

.language-select {
  width: 104px;
  max-width: 104px;
  min-height: 32px;
  padding: 0 24px 0 8px;
  border: 1px solid var(--m3-outline);
  border-radius: var(--m3-shape-full);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--text);
}

.theme-toggle svg,
.window-control svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.theme-toggle-icon-dark {
  display: block;
}

.theme-toggle-icon-light {
  display: none;
}

:root[data-theme="light"] .theme-toggle-icon-dark {
  display: none;
}

:root[data-theme="light"] .theme-toggle-icon-light {
  display: block;
}

.window-controls {
  display: none;
  align-items: center;
  gap: 4px;
}

body.desktop-shell .window-controls {
  display: inline-flex;
}

.window-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--text);
}

/* Issue #463: the mini window button stays out unless app.js shows it. */
.window-control[hidden] {
  display: none;
}

.window-mini-control[aria-pressed="true"] {
  color: var(--accent, currentColor);
}

.window-control-close:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 18%, var(--panel-2));
  color: var(--danger-text);
}

.tabbar {
  grid-area: navigation;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  overflow: hidden;
}

.nav-item {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-width: 86px;
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  line-height: 1;
}

.nav-item:hover {
  border-color: var(--line);
  background: var(--panel-2);
}

.nav-item.active {
  border-color: var(--accent);
  background: var(--panel-3);
  color: var(--text);
}

.nav-item > span {
  min-width: 0;
  overflow: hidden;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-icon {
  display: inline-grid;
  flex: 0 0 16px;
  place-items: center;
  width: 16px;
  height: 16px;
}

.nav-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.announcement-rail {
  grid-area: announcement;
  min-width: 0;
  max-height: min(180px, 24vh);
  max-height: min(180px, 24dvh);
  overflow: auto;
}

.view-stack {
  grid-area: content;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.view {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.view.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.content-grid {
  display: grid;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.discover-grid {
  width: 100%;
  height: 100%;
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.15fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.panel-tight {
  padding: 14px;
}

.discover-search-panel,
.discover-detail-panel,
.history-panel,
.bookshelf-panel,
.settings-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.discover-search-panel,
.discover-detail-panel {
  display: flex;
  flex-direction: column;
}

.detail-panel-shell {
  min-height: 0;
}

.mobile-back-button {
  display: none;
}

.section-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.compact-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.list-meta {
  flex: 0 0 auto;
  margin: 8px 0;
}

.discover-search-panel #searchResults,
.discover-detail-panel #bookDetailPanel {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* The active-job surface is a grid row, not a fixed overlay. */
.job-drawer {
  grid-area: jobs;
  position: relative;
  width: 100%;
  max-height: 190px;
  padding: 10px 42px 10px 12px;
  overflow: auto;
  background: var(--panel-strong);
  transition: max-height 160ms ease, padding 160ms ease;
}

.job-drawer.hidden {
  display: none;
}

.job-drawer.collapsed {
  max-height: 38px;
  padding-top: 8px;
  padding-bottom: 8px;
  overflow: hidden;
}

.job-drawer-content {
  min-width: 0;
}

.job-drawer.collapsed .job-drawer-content {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.job-drawer-toggle {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  transform: rotate(90deg);
}

.job-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.job-foot {
  margin-top: 8px;
}

.progress-detail-text {
  color: var(--muted);
  overflow-wrap: anywhere;
}
