/* Phone presentation, layered over the unchanged page styles and desktop.css.
   Same palette as the desktop window (red up, green down; wine and forest accents), but opaque
   backgrounds instead of Windows acrylic, iOS fonts instead of Segoe, drawn icons instead of the
   Segoe Fluent icon font, and the left rail as a bottom tab bar. Read only: no restart/preflight. */
html.mobile-desk:root {
  --font-display: -apple-system, 'SF Pro Display', 'PingFang SC', 'Helvetica Neue', sans-serif;
  --page: #eef0f4; --bar: rgba(249, 249, 251, .94);
  font-family: -apple-system, 'SF Pro Text', 'PingFang SC', 'Helvetica Neue', sans-serif;
  -webkit-text-size-adjust: 100%;
}
html.mobile-desk[data-theme="dark"]:root { --page: #121115; --bar: rgba(24, 22, 27, .94); }
html.mobile-desk body {
  min-height: 100dvh; background-color: var(--page); background-attachment: scroll;
  -webkit-tap-highlight-color: transparent;
}

/* Drawn icons (the Windows icon font does not exist on iPhone). */
html.mobile-desk .panel-heading h2::before, html.mobile-desk .risk-eyebrow::before { content: none; }
html.mobile-desk .desk-nav-icon, html.mobile-desk .theme-toggle-icon {
  display: inline-block; width: 22px; height: 22px; font: 0/0 a; background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat;
}
html.mobile-desk .desk-nav-icon::before, html.mobile-desk .theme-toggle-icon::before { content: none; }
html.mobile-desk .desk-nav-market { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 20h18'/%3E%3Cpath d='M4 16l5-6 4 4 7-9'/%3E%3Cpath d='M15 5h5v5'/%3E%3C/svg%3E"); }
html.mobile-desk .desk-nav-strategy { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='7' width='16' height='12' rx='3'/%3E%3Cpath d='M12 3v4M9 12v1M15 12v1M9 16h6M2 12v2M22 12v2'/%3E%3C/svg%3E"); }
html.mobile-desk .theme-toggle-icon { width: 18px; height: 18px; --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z'/%3E%3C/svg%3E"); }
html.mobile-desk[data-theme="dark"] .theme-toggle-icon { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E"); }

/* Top bar: safe area, no Windows caption buttons, wraps to two rows. */
html.mobile-desk .topbar {
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap; row-gap: 6px; column-gap: 8px;
  min-height: 0; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: var(--bar);
  -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4);
}
html.mobile-desk .brand-lockup { flex: 1 1 auto; min-width: 0; }
html.mobile-desk .brand-lockup h1 { font-size: 16px; white-space: nowrap; }
html.mobile-desk .brand-lockup .eyebrow { display: none; }
html.mobile-desk .brand-mark { width: 26px; height: 26px; flex: none; }
html.mobile-desk .top-actions { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
html.mobile-desk .date-control { padding: 0; background: none; border: 0; box-shadow: none; }
html.mobile-desk .date-control > span { display: none; }
html.mobile-desk .date-control select { max-width: 122px; min-height: 34px; font-size: 13px; }
/* The page's own narrow-screen rule hides icon buttons; the phone keeps refresh and the theme switch. */
html.mobile-desk .top-actions .icon-button { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; font-size: 13px; }
html.mobile-desk .theme-toggle > span:not(.theme-toggle-icon) { display: none; }
html.mobile-desk .theme-toggle { padding: 0 9px; }

/* Relay status pill (mobile.js): whether home is online and how fresh the data is. */
html.mobile-desk .relay-status {
  order: 3; flex: 1 0 100%; display: flex; align-items: center; gap: 7px; min-height: 22px;
  color: var(--fg-3); font-size: 12px; font-variant-numeric: tabular-nums;
}
html.mobile-desk .relay-status::before {
  content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--idle);
}
html.mobile-desk .relay-status[data-state="live"]::before { background: var(--ok); }
html.mobile-desk .relay-status[data-state="offline"] { color: var(--bad); font-weight: 600; }
html.mobile-desk .relay-status[data-state="offline"]::before { background: var(--bad); }
html.mobile-desk .relay-status button {
  margin-left: auto; padding: 2px 10px; color: var(--fg-2); font: inherit; font-weight: 500;
  background: var(--control); border: 1px solid var(--stroke); border-radius: 999px;
}
html.mobile-desk .account-sheet {
  order: 4; flex: 1 0 100%; display: grid; gap: 8px; padding: 12px; margin-top: 2px;
  background: var(--card); border: 1px solid var(--stroke); border-radius: 12px; font-size: 13px; color: var(--fg-2);
}
html.mobile-desk .account-sheet[hidden] { display: none; }
html.mobile-desk .account-sheet button {
  justify-self: start; padding: 7px 14px; color: var(--bad); font: inherit; font-weight: 600;
  background: var(--bad-soft); border: 1px solid var(--bad-line); border-radius: 9px;
}

/* Content: full width, cards stacked. */
html.mobile-desk .app-shell { width: calc(100% - 20px); margin: 10px auto 16px; }
html.mobile-desk .detail-panel { position: static; top: auto; max-height: none; overflow: visible; }
html.mobile-desk .regime-label { font-size: 32px; }
html.mobile-desk .theme-board, html.mobile-desk .rapid-growth-panel, html.mobile-desk .feedback-panel,
html.mobile-desk .recent-panel, html.mobile-desk .health-panel { padding: 0 12px 14px; }
html.mobile-desk .detail-panel { padding: 14px 12px; }
html.mobile-desk #rapid-growth-themes, html.mobile-desk .member-table-wrap, html.mobile-desk #yesterday-feedback {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
@media (max-width: 600px) {
  html.mobile-desk .risk-cards { grid-template-columns: minmax(0, 1fr); }
}
html.mobile-desk .rapid-growth-table { min-width: 720px; }
html.mobile-desk .feedback-table { min-width: 560px; }
html.mobile-desk .member-table { min-width: 520px; }

/* Read only on the phone: restarting or pre-checking strategies stays on the home desk. */
html.mobile-desk #v23-strategy-status button[data-restart],
html.mobile-desk #v23-strategy-status button[data-preflight] { display: none; }

/* Left rail becomes a bottom tab bar. */
html.mobile-desk .desk-layout { display: block; }
html.mobile-desk .desk-views { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
html.mobile-desk .desk-nav {
  position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 45;
  flex-direction: row; justify-content: center; gap: 12px;
  width: auto; height: auto; margin: 0; padding: 6px 16px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--bar); border: 0; border-top: 1px solid var(--divider); border-radius: 0; box-shadow: none;
  -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4);
}
html.mobile-desk #toast { bottom: calc(76px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); z-index: 60; }
html.mobile-desk .desk-nav button { flex: 1 1 0; max-width: 150px; min-height: 50px; gap: 3px; font-size: 11px; }
html.mobile-desk .desk-nav-badge { top: 3px; right: calc(50% - 26px); }

@media (min-width: 900px) {
  html.mobile-desk .app-shell { width: calc(100% - 40px); max-width: 1400px; }
}

/* Login page (public; does not load the desk styles). */
body.login-page {
  margin: 0; display: grid; place-items: center; padding: calc(env(safe-area-inset-top) + 24px) 18px 32px;
  color: #16181d; background: #eef0f4; font: 16px/1.6 -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
}
.login-card, .login-card * { box-sizing: border-box; }
.login-card {
  width: min(100%, 420px); padding: 26px 22px; background: #fff; border: 1px solid rgba(22, 26, 38, .08);
  border-radius: 18px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px rgba(16, 24, 40, .07);
}
.login-icon { display: block; border-radius: 16px; }
.login-card h1 { margin: 14px 0 4px; font-size: 24px; }
.login-lead { margin: 0 0 18px; color: #5f636d; font-size: 15px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; color: #3d4049; font-size: 14px; font-weight: 600; }
.login-card input {
  min-height: 48px; padding: 0 14px; color: inherit; font: 500 18px -apple-system, 'PingFang SC', sans-serif;
  letter-spacing: .06em; background: #f6f7f9; border: 1px solid rgba(22, 26, 38, .14); border-radius: 12px;
}
.login-card input#device { letter-spacing: 0; font-size: 16px; }
.login-card input:focus { outline: 2px solid rgba(155, 47, 77, .45); outline-offset: 1px; background: #fff; }
.login-card button {
  min-height: 50px; color: #fff; font: 600 17px -apple-system, 'PingFang SC', sans-serif;
  background: #9b2f4d; border: 0; border-radius: 12px;
}
.login-card button:disabled { opacity: .6; }
.login-error { min-height: 1.4em; margin: 0; color: #d2383f; font-size: 14px; font-weight: 600; }
.login-help { margin-top: 18px; color: #3d4049; font-size: 14px; }
.login-help summary { color: #992c4b; font-weight: 600; }
.login-help ol { margin: 10px 0 0; padding-left: 20px; }
@media (prefers-color-scheme: dark) {
  body.login-page { color: #f6f2ef; background: #121115; }
  .login-card { background: #1e1b21; border-color: rgba(235, 214, 221, .12); box-shadow: none; }
  .login-lead, .login-card label, .login-help { color: #d6cbce; }
  .login-card input { background: #2a262d; border-color: rgba(235, 214, 221, .16); }
  .login-card input:focus { background: #2f2a32; }
  .login-help summary { color: #ff9cb6; }
  .login-error { color: #ff827f; }
}
