/* Phones (html.phone, chosen in app.js): the assistant fills the screen; everything else is in the menu.
   Nothing here zooms: every field is 16px (iOS zooms into anything smaller), double-tap zoom is off, and the
   app is sized to the visible screen (--app-h, --app-top from app.js) so the keyboard never pushes it around. */
html:not(.phone) :is(.mtop, .cc-mb, .cc-hello-today, .cc-tabs-x, .mdrawer-bg) { display: none !important; }
.phone-back { margin-left: auto; }

html.phone { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.phone body { padding-bottom: 0; min-height: 100dvh; overflow-x: hidden; }
.phone #root { overflow-x: clip; }
.phone input, .phone textarea, .phone select, .phone [contenteditable="true"] { font-size: 16px !important; }
.phone button, .phone a { touch-action: manipulation; }
.phone .top, .phone .foot { display: none; }
.phone .toast { bottom: calc(96px + env(safe-area-inset-bottom)); width: max-content; text-align: center; }

/* The bar on every page but Home: the menu, where they are, and the assistant */
.phone .mtop { display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 20;
  padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); min-height: calc(54px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--card) 90%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); border-bottom: 1px solid var(--line); }
.mtop-b, .cc-mb { width: 44px; height: 44px; place-items: center; border: 0; background: none; border-radius: 12px; color: var(--ink); position: relative; flex: none; padding: 0; cursor: pointer; }
.phone .mtop-b { display: grid; }
.mtop-b svg, .cc-mb svg { width: 23px; height: 23px; }
.mtop-b:active, .cc-mb:active { background: var(--bg); }
.mtop-t { flex: 1; min-width: 0; text-align: center; font-size: 17px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtop-ask .as-orb { width: 30px; height: 30px; margin: 0; }
.mtop-dot { position: absolute; top: 9px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); }

/* Pages */
.phone .page { max-width: none; padding: 18px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.phone .page h1 { font-size: 25px; line-height: 1.2; }
.phone .section-head { flex-wrap: wrap; gap: 10px; }
.phone .card { border-radius: 16px; }
.phone .btn { min-height: 40px; }
.phone .btn.sm { min-height: 34px; }
.phone table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.phone .ProseMirror table { display: table; }
.phone .ProseMirror { overflow-x: auto; }
.phone pre { max-width: 100%; overflow-x: auto; }
.phone img, .phone video, .phone iframe { max-width: 100%; }

.phone .ct-bar { flex-wrap: wrap; }
.phone .ct-bar .fl-search { flex: 1 1 100%; }
/* (The page's own big title says where they are; the bar's appears once it scrolls away, the way iPhone apps do.) */
.phone .mtop-t { opacity: 0; transition: opacity .2s; }
.phone.scrolled .mtop-t, .phone .mtop-t.always { opacity: 1; }

.phone .hd-link { padding: 10px 10px; font-size: 16px; }
.phone .hd-backbtn { display: grid; place-items: center; width: 40px; height: 40px; }

/* Home: the conversation is the whole screen */
.phone .page.mfull { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); padding: 0; margin: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--card); }
.phone body:has(.mfull) { overflow: hidden; overscroll-behavior: none; }
.phone .page.mfull > .preview-bar { flex: none; }
.phone .cc { flex: 1; min-height: 0; height: auto; margin: 0; display: flex; flex-direction: column; gap: 0; }
.phone .cc-mtabs, .phone .cc-tools, .phone .cc-foot { display: none; }
.phone .cc-chat { flex: 1; min-height: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--card); }
.phone .cc-chat-h { gap: 0; min-height: calc(54px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); flex: none; }
.phone .cc-mb { display: grid; }
.phone .cc-convos { flex: 1; min-width: 0; display: flex; justify-content: center; position: static; }
.phone .cc-convo-btn { gap: 4px; padding: 8px 6px 8px 10px; max-width: 100%; }
.phone .cc-convo-btn .cc-moon, .phone .cc-convo-btn small { display: none; }
.phone .cc-convo-btn > span { min-width: 0; }
.phone .cc-convo-btn b { display: block; font-size: 16.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone .cc-convo-btn > svg { width: 16px; height: 16px; color: var(--muted); }
.phone .cc-convo-menu { position: fixed; left: 10px; right: 10px; top: calc(var(--app-top, 0px) + env(safe-area-inset-top) + 56px); width: auto; min-width: 0; max-height: calc(var(--app-h, 100dvh) - env(safe-area-inset-top) - 140px); overflow-y: auto; border-radius: 16px; z-index: 40; }
.phone .cc-mtoday .cc-count { position: absolute; top: 4px; right: 2px; min-width: 18px; padding: 0 5px; line-height: 18px; font-size: 11px; background: var(--cc-need); border: 2px solid var(--card); }
.phone .cc-main { min-height: 0; }
.phone .cc-thread { padding: 18px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); gap: 18px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.phone .cc-thread .as-text { font-size: 16px; }
.phone .cc-thread .as-msg { gap: 10px; }
.phone .cc-thread .as-orb { width: 28px; height: 28px; }
.phone .as-bubble { max-width: 88%; font-size: 16px; }
.phone .cc-compose { flex: none; margin: 4px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); border-radius: 24px; padding: 5px 5px 5px 8px; }
.phone.kb .cc-compose { margin-bottom: 8px; }
.phone .cc-compose textarea { min-height: 40px; max-height: 30vh; padding: 8px 6px; }
.phone .cc-compose .as-send { width: 40px; height: 40px; }
.phone .cc-target { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.phone .cc-target button { flex: none; font-size: 13px; padding: 5px 11px; }

/* Home with nothing asked yet: a hello, what needs them, and a few ideas */
.phone .cc-hello { margin: auto 0; padding: 8px 2px 4px; text-align: left; max-width: none; }
.phone .cc-hello-moon { width: 52px; height: 52px; margin: 0 0 14px; }
.phone .cc-hello h2 { font-size: 24px; line-height: 1.25; letter-spacing: -.02em; margin-bottom: 14px; }
.phone .cc-hello > p { display: none; }
.phone .cc-hello-today { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 18px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--ink); text-align: left; font: inherit; font-size: 15px; line-height: 1.4; cursor: pointer; }
.cc-hello-today > svg:first-child { width: 20px; height: 20px; color: var(--accent); }
.cc-hello-today > svg:last-child { width: 16px; height: 16px; color: var(--muted); transform: rotate(-90deg); }
.cc-hello-today b { color: var(--cc-need); }
.phone .cc-ideas { flex-direction: column; align-items: stretch; gap: 8px; justify-content: flex-start; }
.phone .cc-idea { text-align: left; border-radius: 14px; padding: 12px 14px; font-size: 15.5px; line-height: 1.35; background: var(--card); }

/* Today (with Huddle and a meeting): in place of the conversation, with a way back */
.phone .cc[data-m="chat"] .cc-side { display: none; }
.phone .cc[data-m="side"] .cc-chat { display: none; }
.phone .cc-side { flex: 1; min-height: 0; background: var(--bg); padding-top: env(safe-area-inset-top); }
.phone .cc-tabs { margin: 8px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); align-items: center; }
.phone .cc-tabs button { padding: 9px 8px; font-size: 14.5px; }
.phone .cc-tabs-x { display: grid; place-items: center; flex: 0 0 40px !important; width: 40px; height: 38px; padding: 0 !important; color: var(--ink) !important; }
.phone .cc-tabs-x svg { width: 18px; height: 18px; }
.phone .cc-pane { padding: 0 max(12px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); overscroll-behavior: contain; }
.phone .cc-card-b { flex-wrap: wrap; }
.phone .cc-card-b .btn { min-height: 38px; }
.phone .cc-hdpanel { inset: 0; border-radius: 0; z-index: 30; padding-top: env(safe-area-inset-top); }
.phone .cc-main.in-call .cc-callslot { height: clamp(200px, 32vh, 320px); margin: 6px 8px; }

/* Dialogs rise from the bottom, inside the visible screen */
.phone .modal-bg { inset: auto 0 auto 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); padding: 0; display: flex; align-items: flex-end; animation: m-fade .2s ease both; }
.phone .modal { width: 100%; max-width: none; border-radius: 22px 22px 0 0; padding: 12px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  max-height: calc(var(--app-h, 100dvh) - env(safe-area-inset-top) - 16px); overflow-y: auto; overscroll-behavior: contain; animation: m-up .28s cubic-bezier(.2, .8, .2, 1) both; }
.phone.kb .modal { padding-bottom: 14px; }
.phone .modal::before { content: ''; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.phone .modal h2 { font-size: 20px; }
.phone .modal .actions { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
.phone .modal .actions .btn { width: 100%; justify-content: center; min-height: 48px; }
@keyframes m-up { from { transform: translateY(100%); } }
@keyframes m-fade { from { background: transparent; } }

/* A list of choices, as a sheet (the phone's ⋯) */
.sheet-list { display: flex; flex-direction: column; }
.sheet-list button { display: flex; align-items: center; gap: 14px; padding: 15px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; font-size: 16.5px; color: var(--ink); text-align: left; cursor: pointer; }
.sheet-list button:last-child { border-bottom: 0; }
.sheet-list button svg { width: 21px; height: 21px; color: var(--accent); }
.sheet-cancel { margin-top: 10px; min-height: 48px; justify-content: center; }

/* The menu */
.phone .mdrawer-bg { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(10, 14, 24, .42); animation: m-fade .22s ease both; transition: opacity .2s; }
.mdrawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(84vw, 340px); background: var(--card); display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 14px) 12px calc(env(safe-area-inset-bottom) + 10px) max(12px, env(safe-area-inset-left)); overflow-y: auto; overscroll-behavior: contain;
  box-shadow: 10px 0 40px rgba(0, 0, 0, .18); animation: m-in .26s cubic-bezier(.2, .8, .2, 1) both; transition: transform .2s; }
.mdrawer-bg.out { opacity: 0; }
.mdrawer-bg.out .mdrawer { transform: translateX(-100%); }
@keyframes m-in { from { transform: translateX(-100%); } }
.md-head { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 4px 6px 16px; }
.md-head > span:last-child { min-width: 0; max-width: 100%; }
.md-head b { display: block; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-head small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mdrawer .md-logo { max-width: 150px; max-height: 32px; object-fit: contain; object-position: left; flex: none; }
.md-new { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px; font: inherit; font-size: 16px; font-weight: 600; color: var(--ink); cursor: pointer; }
.md-new svg { width: 20px; height: 20px; color: var(--accent); }
.md-places { display: flex; flex-direction: column; gap: 1px; margin: 10px 0 8px; }
.md-places a { display: flex; align-items: center; gap: 13px; padding: 11px 10px; border-radius: 12px; color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 500; }
.md-places a svg { width: 21px; height: 21px; color: var(--muted); }
.md-places a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.md-places a.on svg { color: var(--accent); }
.md-n { margin-left: auto; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 8px; }
.md-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; border-top: 1px solid var(--line); }
.md-chats { flex: 1 0 auto; display: flex; flex-direction: column; }
.md-chats a { display: block; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.md-chats a.on { background: var(--bg); }
.md-chats span { display: block; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-chats small { display: block; font-size: 12.5px; color: var(--faint); }
.md-note { padding: 8px 10px; color: var(--muted); font-size: 14px; }
.md-foot { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.md-foot button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 10px; font: inherit; font-size: 15px; color: var(--muted); border-radius: 10px; cursor: pointer; }
.md-foot button svg { width: 18px; height: 18px; }

/* Signing in */
.phone .auth { min-height: 100dvh; padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px); align-items: start; }
.phone .auth .card { padding: 26px 22px; margin-top: 6vh; }
.phone .auth .btn { min-height: 50px; }

@media (prefers-reduced-motion: reduce) { .phone .modal, .phone .modal-bg, .mdrawer, .phone .mdrawer-bg { animation: none !important; transition: none !important; } }
