/* Ops console shell: split-screen sign-in, OTP boxes, account menu, mobile bar (#980-#996).
   Loaded after app.css; colours come only from /shared/tokens.css, so every text/background pair
   keeps the contrast already measured there. No style="" attributes (CSP). */

/* ---- Sign-in: form + live WhatsApp proof (#980) -------------------------------------- */
.login-split {
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: center;
}
.login-split > .login-container {
  max-width: none;
}
.login-proof {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
@media (min-width: 992px) {
  .login-split {
    max-width: 58rem;
    grid-template-columns: minmax(0, 26rem) minmax(0, 21rem);
    gap: clamp(var(--sp-6), 6vw, 5rem);
    justify-content: center;
  }
  .login-proof {
    animation: login-rise 520ms var(--ease) 120ms both;
  }
}
.proof-phone {
  width: 100%;
  max-width: 21rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.proof-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.proof-avatar {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--chat-tone-0);
  color: #fff;
  font-weight: var(--weight-semibold);
  font-size: var(--fs-sm);
}
.proof-who {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.proof-who strong {
  font-size: var(--fs-sm);
  font-weight: var(--weight-medium);
}
.proof-who small {
  font-size: var(--fs-xs);
  color: var(--muted);
}
.proof-wa {
  color: var(--text-2);
  font-size: 1.1rem;
}
.proof-thread {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  background: var(--chat-wall);
  min-height: 15rem;
}
.proof-msg {
  margin: 0;
  max-width: 82%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--r);
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--chat-ink);
  animation: proof-in 420ms var(--ease) both;
}
.proof-in {
  align-self: flex-start;
  background: var(--chat-in);
  border-top-left-radius: 3px;
}
.proof-out {
  align-self: flex-end;
  background: var(--chat-out);
  border-top-right-radius: 3px;
}
.proof-d1 { animation-delay: 600ms; }
.proof-d2 { animation-delay: 1900ms; }
.proof-d3 { animation-delay: 3300ms; }
.proof-d4 { animation-delay: 4600ms; }
.proof-cap {
  margin: 0;
  max-width: 21rem;
  text-align: center;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--muted);
}
@keyframes proof-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
/* Narrow phones: keep the form first and the proof compact beneath it. */
@media (max-width: 991.98px) {
  .login-stage {
    align-items: flex-start;
  }
  .proof-thread {
    min-height: 0;
  }
}

/* The card eases out as the board loads (#985). */
.login-view .login-container,
.login-view .login-proof {
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.login-view.is-leaving .login-container,
.login-view.is-leaving .login-proof {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
#board-view.board-enter {
  animation: board-enter 380ms var(--ease) both;
}
@keyframes board-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---- Password field: show/hide, Caps Lock hint, forgot link (#981, #983) ------------- */
.login-pw {
  position: relative;
}
.login-pw .form-control {
  padding-right: 3.25rem;
}
.login-pw-toggle {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  font-size: 1.1rem;
  cursor: pointer;
}
.login-pw-toggle:hover {
  color: var(--text);
}
.login-pw-toggle:focus-visible,
.login-forgot:focus-visible,
.otp-link:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.login-caps {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--warn);
}
.login-forgot,
.otp-link {
  align-self: flex-start;
  padding: 0.65rem 0;
  min-height: 2.75rem;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.login-forgot:hover,
.otp-link:hover {
  color: var(--text);
}
.login-step-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tr-tight);
  color: var(--text);
}
/* While a reset form is open the sign-in titles step aside. */
.login-view.is-reset-flow .login-kicker,
.login-view.is-reset-flow .login-title,
.login-view.is-reset-flow .login-lede {
  display: none;
}

/* ---- Segmented one-time code (#982) -------------------------------------------------- */
.otp {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--sp-2);
}
.otp-box {
  width: 100%;
  height: 3.25rem;
  min-width: 0;
  padding: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  caret-color: var(--lime-text);
  transition: border-color var(--dur) var(--ease);
}
.otp-box:focus {
  outline: 0;
  border-color: color-mix(in srgb, var(--lime) 70%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--lime) 55%, transparent);
}
.otp-box.is-filled {
  border-color: color-mix(in srgb, var(--text) 30%, var(--line));
}
.otp.is-error .otp-box {
  border-color: var(--warn);
}
.otp-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
}
.otp-resend {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.otp-resend-timer {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---- Account menu: language, theme, sound live here (#995) ---------------------------- */
.user-menu {
  position: relative;
}
.user-menu-btn {
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.user-menu-btn:hover {
  border-color: var(--nav-border);
  background: color-mix(in srgb, var(--nav-fg) 5%, transparent);
}
.user-menu-btn[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--lime) 55%, var(--nav-border));
  background: color-mix(in srgb, var(--lime) 10%, transparent);
  box-shadow: 0 0 0 3px var(--lime-dim);
}
.user-menu-btn:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.user-avatar {
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--lime);
  color: var(--lime-ink);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  text-transform: uppercase;
}
.user-menu-pop {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 1090;
  width: min(20rem, calc(100vw - 1.5rem));
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--text);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.user-menu-pop:not([hidden]) {
  animation: user-menu-in 160ms var(--ease) both;
}
@keyframes user-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .user-menu-pop:not([hidden]) { animation: none; }
}
.user-menu-who {
  margin: 0 0 var(--sp-1);
  padding: 0 0 var(--sp-3);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.user-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 2.85rem;
  padding: 0;
}
.user-menu-label {
  font-size: var(--fs-sm);
  font-weight: var(--weight-medium);
  color: var(--text-2);
}
.user-menu-pop .panel-nav-icon-btn {
  height: 2.25rem;
  border-color: var(--nav-border);
}
.user-menu-logout {
  width: 100%;
  margin-top: var(--sp-1);
  height: 2.75rem;
  border-radius: var(--radius-pill);
  font-weight: var(--weight-semibold);
}
#user-menu-settings {
  margin-top: var(--sp-2);
  color: var(--text);
  border-color: var(--line);
}
#user-menu-settings:hover,
#user-menu-settings:focus-visible {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 22%, var(--line));
  background: var(--surface-2);
  outline: 0;
}
#logout-btn.user-menu-logout:hover,
#logout-btn.user-menu-logout:focus-visible {
  border-color: color-mix(in srgb, var(--warn) 40%, var(--line));
  color: var(--text);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}

/* Accent colour dropdown inside the account menu */
.user-menu .themes-picker {
  position: relative;
  flex-shrink: 0;
}
.user-menu .themes-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 6.75rem;
  height: 2rem;
  padding: 0.2rem 0.55rem 0.2rem 0.5rem;
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  cursor: pointer;
}
.user-menu .themes-trigger:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--text) 18%, var(--line));
  color: var(--text);
}
.user-menu .themes-trigger:focus,
.user-menu .themes-trigger[aria-expanded="true"] {
  border-color: var(--lime);
  box-shadow: 0 0 0 0.15rem var(--lime-dim);
  outline: 0;
}
.user-menu .themes-chevron {
  font-size: 0.65rem;
  opacity: 0.75;
  margin-left: 0.1rem;
}
.user-menu .theme-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--text) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 18%, transparent);
}
.user-menu .themes-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 1100;
  min-width: 9.5rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.user-menu .themes-menu[hidden] { display: none !important; }
.user-menu .themes-menu li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  cursor: pointer;
}
.user-menu .themes-menu li:hover,
.user-menu .themes-menu li:focus {
  background: var(--surface-2);
  outline: 0;
}
.user-menu .themes-menu li[aria-selected="true"] {
  background: var(--lime-dim);
}

/* One row from 1024px up: brand, tabs, chats counter, avatar. */
@media (min-width: 1024px) {
  .panel-nav .panel-nav-inner {
    flex-wrap: nowrap;
    height: 3.85rem;
    min-height: 3.85rem;
    padding-top: 0;
    padding-bottom: 0;
    row-gap: 0;
  }
  .panel-nav-primary {
    min-width: 0;
  }
  .panel-nav .main-tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    height: auto;
  }
  .panel-nav .main-tabs::-webkit-scrollbar {
    display: none;
  }
  .panel-nav .tab-btn {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
  }
  .panel-nav-tools {
    margin-left: auto;
    padding-right: 0;
  }
}

/* ---- Below 1024px: slim header + bottom bar (#996) ----------------------------------- */
.bottom-bar,
.more-sheet {
  display: none;
}
@media (max-width: 1023.98px) {
  .panel-nav .panel-nav-inner {
    flex-wrap: nowrap;
    height: 3.5rem;
    min-height: 3.5rem;
    padding: 0 0.75rem;
    row-gap: 0;
    gap: 0.5rem;
  }
  .panel-nav .panel-nav-brand {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
  }
  .panel-nav-brand-text {
    min-width: 0;
  }
  .panel-nav-brand-text .nav-title,
  .panel-nav-brand-text .label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .panel-nav .panel-nav-primary {
    display: none;
  }
  .panel-nav .panel-nav-tools {
    margin-left: 0;
    padding: 0;
  }
  .panel-nav .panel-nav-warn {
    flex: 0 1 auto;
    max-width: 40vw;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fs-xs);
  }
  .panel-nav-inbox {
    display: none !important;
  }
  .bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #board-view:not([hidden]) {
    padding-bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
    overflow-x: clip;
  }
  .bottom-bar-btn {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    min-height: 3.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem 0.25rem;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-size: 0.6875rem;
    font-weight: var(--weight-medium);
    cursor: pointer;
  }
  .bottom-bar-btn i {
    font-size: 1.25rem;
    line-height: 1;
  }
  .bottom-bar-btn.active,
  .bottom-bar-btn[aria-expanded="true"] {
    color: var(--lime-text);
  }
  .bottom-bar-btn.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28%;
    right: 28%;
    height: 2px;
    background: var(--lime);
  }
  .bottom-bar-btn:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: -3px;
  }
  .bottom-bar-badge {
    position: absolute;
    top: 0.35rem;
    left: calc(50% + 0.45rem);
    min-width: 1.1rem;
    padding: 0 0.3rem;
    border-radius: var(--r-pill);
    background: var(--lime);
    color: var(--lime-ink);
    font-family: var(--mono);
    font-size: 0.625rem;
    font-weight: var(--weight-semibold);
    line-height: 1.1rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }
  .more-sheet:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
  }
  .more-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--ground) 72%, transparent);
  }
  .more-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 75dvh;
    overflow-y: auto;
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: sheet-up 240ms var(--ease) both;
  }
  .more-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.75rem;
  }
  .more-sheet-title {
    margin: 0;
    font-size: var(--fs-md);
    font-weight: var(--weight-semibold);
    color: var(--text);
  }
  .more-sheet-close {
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--r);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
  }
  .more-sheet-list {
    display: flex;
    flex-direction: column;
  }
  .more-sheet-item {
    width: 100%;
    min-height: 3rem;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-1);
    border: 0;
    border-top: 1px solid var(--line-soft);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: var(--fs-md);
    text-align: left;
    cursor: pointer;
  }
  .more-sheet-item i {
    width: 1.5rem;
    color: var(--text-2);
    font-size: 1.1rem;
  }
  .more-sheet-item.active {
    color: var(--lime-text);
  }
  .more-sheet-item.active i {
    color: var(--lime-text);
  }
  .more-sheet-item:focus-visible,
  .more-sheet-close:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: -2px;
  }
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .login-proof,
  .proof-msg,
  .more-sheet-panel,
  #board-view.board-enter {
    animation: none;
  }
  .login-view .login-container,
  .login-view .login-proof,
  .otp-box {
    transition: none;
  }
  .login-view.is-leaving .login-container,
  .login-view.is-leaving .login-proof {
    transform: none;
  }
}

/* ---- Tablet / touch (#2155, #2156): the shell's own controls on coarse pointers ------------ */
@media (pointer: coarse) {
  .tab-btn,
  .shell-nav button,
  .shell-nav a,
  .account-menu button,
  .account-menu a {
    min-height: 44px;
    min-width: 44px;
  }
  .login-view .form-control { min-height: 44px; font-size: 16px; }
  .login-view .btn { min-height: 44px; }
}
