/* Amadeus web chat — UI v3: dark, near-black canvas tinted by the chosen companion (Arpeo [id scholar], Roble, Amadeus [id pip],
   Lumina). Round hamburger + "Invitar" pill on top, a pill composer (+ · text · mic · call), a floating
   4-tab pill at the bottom and a slide-out drawer. Pip runs across the splash on every load.
   Dark only (one look on every device). No remote fonts or assets; icons are an inline SVG sprite. */
:root {
  --char: #14b8a6; --char-soft: #d5f5ef;
  /* Companion theme: every surface is a near-black mixed with a little of the companion's colour. */
  --base: #070808;
  --bg: color-mix(in srgb, var(--char) 6%, var(--base));
  --panel: color-mix(in srgb, var(--char) 7%, #151617);
  --panel-2: color-mix(in srgb, var(--char) 9%, #1d1e20);
  --panel-3: color-mix(in srgb, var(--char) 12%, #2a2b2e);
  --line: color-mix(in srgb, var(--char) 10%, #26272a); --line-strong: color-mix(in srgb, var(--char) 14%, #3a3b40);
  --text: #f3f3f1; --muted: #a9aaa6; --ink: #f3f3f1; --ink-text: #0b0c0c;
  --accent: var(--char); --accent-text: color-mix(in srgb, var(--char) 62%, #ffffff); --accent-soft: color-mix(in srgb, var(--char) 22%, #151617);
  --user-bubble: color-mix(in srgb, var(--char) 30%, #18191b); --user-ink: #f7f7f5; --bot-bubble: color-mix(in srgb, var(--char) 6%, #1c1d1f);
  --danger: #f28b82; --danger-soft: #3a1d1a; --warn: #f0c060; --warn-soft: #3a2e14; --ok: #6fd08f; --ok-soft: #17301f;
  --badge: #e5484d; --focus: color-mix(in srgb, var(--char) 45%, #ffffff);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-float: 0 2px 6px rgba(0, 0, 0, .35), 0 14px 36px rgba(0, 0, 0, .5);
  --radius: 22px; --radius-sm: 14px; --tap: 44px;
  --font: "Inter", "Helvetica Neue", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Inter", "Helvetica Neue", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: dark;
}
/* Signature colours (brand.js CHARACTERS) so the theme is right before app.js paints --char. */
body[data-character="scholar"] { --char: #14b8a6; }
body[data-character="roble"] { --char: #e08a2c; }
body[data-character="pip"] { --char: #3fa34d; }
body[data-character="lumina"] { --char: #8b7cf6; }
* { box-sizing: border-box; }
html { height: 100%; background: var(--base); }
body { margin: 0; }
body {
  background:
    radial-gradient(120% 55% at 50% -12%, color-mix(in srgb, var(--char) 26%, transparent) 0%, transparent 62%),
    radial-gradient(80% 40% at 100% 105%, color-mix(in srgb, var(--char) 10%, transparent) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  transition: background-color .4s;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
a { color: var(--text); text-underline-offset: 3px; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--char) 70%, var(--text)); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--char) 60%, transparent); outline-offset: 0; border-color: var(--char); }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---- top bar: round ☰ left, "Invitar" pill right ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  padding-top: max(12px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { flex: 1; }
.round-btn {
  width: 46px; height: 46px; min-height: 0; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
}
.round-btn:hover:not(:disabled) { background: var(--panel-3); }
.pill-btn {
  min-height: 42px; padding: 0 20px; border-radius: 999px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  font: 700 15px/1 var(--font);
}
.pill-btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.badge { background: var(--badge); color: #fff; border-radius: 999px; min-width: 20px; padding: 0 6px; font-size: 12px; line-height: 20px; text-align: center; font-weight: 700; }

/* ---- drawer (slide-out on phones, sidebar on desktop) ---- */
.drawer-backdrop, .sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); animation: fade .2s ease; }
.drawer {
  position: fixed; inset: 0 auto 0 0; z-index: 41; width: min(86vw, 340px); overflow-y: auto; overscroll-behavior: contain;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, color-mix(in srgb, var(--char) 12%, #111213), var(--panel) 40%);
  border-right: 1px solid var(--line); box-shadow: var(--shadow-float);
  animation: slide-in .24s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column; gap: 4px;
}
@keyframes slide-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px 8px; }
.drawer-title { margin: 0; font-size: 26px; }
.drawer-search { padding: 0 4px 8px; }
.drawer-search input { border-radius: 999px; background: var(--panel-2); }
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-nav a, .drawer-user, .more-nav a {
  display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 14px; border-radius: 16px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 17px;
}
.drawer-nav a:hover, .drawer-user:hover, .more-nav a:hover { background: var(--panel-2); }
.drawer-nav a[aria-current="page"], .more-nav a[aria-current="page"], .drawer-user[aria-current="page"] { background: var(--panel-3); }
.drawer-nav a .ico { color: var(--muted); }
.drawer-nav a[aria-current="page"] .ico { color: var(--accent-text); }
.drawer-user { margin-top: 6px; }
.drawer-avatar .avatar-mini { width: 30px; height: 30px; }
.drawer-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-rule { border: 0; border-top: 1px solid var(--line); margin: 10px 8px; width: auto; }
.drawer-section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 14px; }
.drawer-section-head h3, .drawer-more-title { margin: 6px 0; font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.drawer-more-title { padding: 0 14px; }
.icon-link { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted); }
.icon-link:hover { background: var(--panel-2); color: var(--text); }
.drawer-chats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.drawer-chats li.muted { padding: 8px 14px; }
.chat-link {
  width: 100%; text-align: left; background: transparent; min-height: 42px; padding: 0 14px; border-radius: 14px; font-weight: 500; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);
}
.chat-link:hover:not(:disabled) { background: var(--panel-2); }
.more-nav { display: flex; flex-direction: column; gap: 2px; }
.more-nav a { font-size: 15.5px; min-height: 44px; position: relative; }
.more-nav a .ico { width: 20px; height: 20px; color: var(--muted); }
.more-nav .badge { margin-left: auto; }
.drawer-legal { margin-top: auto; padding: 18px 14px 4px; color: var(--muted); }
.drawer-legal a { color: var(--muted); }

/* ---- bottom tab bar: 4 icons in a floating pill, the current one on a lighter pill ---- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 20;
  width: min(calc(100vw - 32px), 400px); display: flex; justify-content: space-between; padding: 6px; gap: 4px;
  background: color-mix(in srgb, var(--panel-2) 92%, transparent); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-float); -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
}
.tabbar a {
  flex: 1; height: 50px; display: inline-grid; place-items: center; border-radius: 999px; color: var(--muted); position: relative;
  transition: background-color .15s, color .15s;
}
.tabbar a .ico { width: 25px; height: 25px; }
.tabbar a:hover { color: var(--text); }
.tabbar a[aria-current="page"] { background: color-mix(in srgb, var(--char) 16%, #3a3b40); color: var(--text); }
.tabbar a:focus-visible { outline-offset: -3px; }
.tabbar .badge { position: absolute; top: 4px; right: calc(50% - 26px); min-width: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }
body:has(#tabbar:not([hidden])) main { padding-bottom: 96px; }
body:has(#tabbar:not([hidden])) #view-chat { padding-bottom: 76px; }

/* ---- sheets (Invitar, "+") ---- */
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 41; width: min(100vw, 520px); max-height: 85vh; overflow-y: auto;
  padding: 18px 18px max(22px, env(safe-area-inset-bottom)); background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 28px 28px 0 0; box-shadow: var(--shadow-float); animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1);
}
@keyframes sheet-up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 21px; }
.sheet .round-btn { width: 40px; height: 40px; }
.sheet p { margin: 8px 0 14px; }

/* ---- tiles (Explorar, Archivo, Perfil, "+") ---- */
.tiles { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 18px; }
.tile {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px; border-radius: 20px; text-decoration: none; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); width: 100%; text-align: left; font: inherit;
}
.tile:hover, .tile-btn:hover:not(:disabled) { background: var(--panel-2); }
.tile > .ico:first-child { width: 40px; height: 40px; padding: 9px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); }
.tile-text { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; }
.tile-text strong { font-size: 16px; }
.tile .chev { color: var(--muted); width: 20px; height: 20px; }
.tile .badge { flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip { min-height: 40px; padding: 0 16px; font-weight: 600; font-size: 14.5px; background: var(--panel-2); border: 1px solid var(--line); }
.chats-list .chat-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; background: transparent; padding: 0; min-height: 0; font-weight: 500; border-radius: 0; }
.chats-list .chat-row:hover:not(:disabled) { background: transparent; }
.chats-list li { padding: 0; }
.chats-list li > .chat-row { padding: 14px 16px; border-radius: var(--radius); }
.chat-row-title { grid-column: 1 / -1; font-weight: 600; overflow-wrap: anywhere; }
.chat-row .pill { justify-self: end; }
.profile-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.profile-head h2 { margin: 0; }
.profile-head p { margin: 2px 0 0; }
.profile-avatar .avatar-mini { width: 56px; height: 56px; }
.pair.flash .msg { box-shadow: 0 0 0 2px var(--char); transition: box-shadow .3s; }

/* ---- layout ---- */
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 18px 16px; min-height: 0; }
.view { display: block; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 136px); height: calc(100dvh - 136px); min-height: 320px; }
/* Chat fills exactly the space between the top bar and the footer, whatever their height. */
@supports selector(:has(a)) {
  body:has(#view-chat:not([hidden])) { height: 100vh; height: 100dvh; }
  body:has(#view-chat:not([hidden])) main { display: flex; flex-direction: column; padding-bottom: 0; padding-top: 4px; }
  .chat { height: auto; flex: 1; min-height: 0; }
}
@supports not selector(:has(a)) { @media (max-width: 560px) { .chat { height: calc(100dvh - 230px); } } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 12px 0; box-shadow: var(--shadow); }
.card > h3:first-child { margin-top: 0; }
.narrow { max-width: 440px; margin: 40px auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--danger); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.03em; line-height: 1.15; font-weight: 800; }
h1, h2 { margin: 18px 0 8px; } h1 { font-size: 30px; } h2 { font-size: 23px; } h3 { font-size: 18px; margin: 12px 0 6px; font-weight: 700; }
.view > .row:first-child h2 { margin: 0; }
.view > .row:first-child { margin-bottom: 10px; }
.view > h2:first-child { margin-top: 0; }
#view-devices > h2:not(:first-child) { margin-top: 30px; }
#view-devices > .list + button, #view-devices > p + button { margin-top: 12px; }

/* ---- forms ---- */
label { font-weight: 600; font-size: 15px; }
input, textarea, select {
  width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 11px 14px; font: inherit; min-height: var(--tap);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
select { width: auto; border-radius: 999px; }
textarea { resize: vertical; }
button {
  background: var(--panel-2); color: var(--text); border: 1px solid transparent; border-radius: 999px;
  padding: 0 20px; min-height: var(--tap); font: 700 15px/1.2 var(--font); cursor: pointer; letter-spacing: -.01em;
  transition: background-color .15s, border-color .15s, transform .08s;
}
button:hover:not(:disabled) { background: var(--panel-3); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .5; cursor: progress; }
button.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
button.primary { background: var(--ink); color: var(--ink-text); }
button.primary:hover:not(:disabled) { background: var(--ink); filter: brightness(1.25); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
button.danger { background: var(--danger-soft); color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
button.wide { width: 100%; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; word-break: break-all; font-size: .88em; }
details summary { cursor: pointer; color: var(--muted); margin: 14px 0 8px; padding: 6px 0; font-weight: 600; }

/* ---- sign-in ---- */
#view-signin { background: var(--panel); border-color: var(--line); }
#view-signin h1 { margin-top: 0; }
#view-signin > .muted { margin: 10px 0 0; }
#signin-error { background: var(--danger-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin: 14px 0 0; }

/* ---- loading ---- */
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 64px 0; }
.loading p { margin: 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- companion (the character) ---- */
.companion { position: relative; display: inline-grid; place-items: center; flex: none; }
.companion::before {
  content: ""; position: absolute; inset: 8% 6% 0; border-radius: 50%; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--char) 34%, transparent), transparent);
  opacity: .55; transition: opacity .3s;
}
.companion img { display: block; width: var(--size, 52px); height: var(--size, 52px); object-fit: contain; filter: drop-shadow(0 6px 10px rgba(17, 17, 19, .12)); }
.companion[data-mood="idle"] img { animation: float 4.2s ease-in-out infinite; }
.companion[data-mood="thinking"] img { animation: float 2.6s ease-in-out infinite; }
.companion[data-mood="thinking"]::before { animation: glow 1.4s ease-in-out infinite; opacity: 1; }
.companion[data-mood="speaking"] img { animation: bob .42s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes glow { 0%, 100% { transform: scale(.88); opacity: .45; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-2px) scale(1.02, .98); } }
.companion-hero img { --size: 168px; }
#view-retry .companion-hero img { --size: 148px; }

.chat-head { display: flex; justify-content: center; padding: 2px 0 8px; }
.companion-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; background: transparent; border: 0; padding: 4px 12px 6px;
  min-height: 0; border-radius: 22px; font-weight: 600;
}
.companion-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--panel) 60%, transparent); }
.companion-meta { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.companion-name {
  font: 800 14px/1 var(--font-display); letter-spacing: -.01em; padding: 5px 12px; border-radius: 999px;
  background: var(--panel); box-shadow: var(--shadow);
}
.companion-status { font-size: 12.5px; color: var(--muted); font-weight: 500; }
/* While the empty state shows the big character, the small header avatar stays out of the way. */
.chat:has(#messages:empty) .chat-head { display: none; }

/* ---- picker ---- */
.picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
@media (min-width: 720px) { #view-devices .picker { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px 14px; min-height: 0; height: auto;
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 700;
  text-align: center; line-height: 1.25;
}
.pick img { width: 88px; height: 88px; object-fit: contain; transition: transform .2s; }
.pick strong { font: 800 17px/1.1 var(--font-display); letter-spacing: -.02em; margin-top: 2px; }
.pick .small { font-weight: 500; font-size: 13px; }
.pick:hover:not(:disabled) { background: var(--panel); border-color: color-mix(in srgb, var(--pick) 50%, var(--line)); }
.pick:hover img { transform: translateY(-3px) rotate(-2deg); }
.pick[aria-checked="true"] {
  border-color: var(--pick); background: linear-gradient(180deg, color-mix(in srgb, var(--pick) 24%, var(--panel)), var(--panel));
}

.pick[aria-checked="true"] img { animation: float 3s ease-in-out infinite; }
.onboarding h1 { margin-top: 8px; font-size: 32px; }
.onboarding .picker + button { margin-top: 4px; }

/* ---- retry ---- */
.retry { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.retry h1 { margin: 10px 0 2px; }
.retry p { margin: 2px 0 8px; max-width: 38ch; }
.retry .wide { max-width: 320px; }

/* ---- chat ---- */
.chat-empty { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px 12px; gap: 4px; }
.chat-empty h2 { margin: 10px 0 4px; font-size: 30px; }
.chat-empty p { margin: 4px 0; max-width: 40ch; }
.chat:has(#messages:empty) .chat-empty { display: flex; }
.chat:has(#messages:empty) #messages { flex: 0; }
.messages { list-style: none; margin: 0; padding: 4px 2px 14px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.pair { display: flex; flex-direction: column; gap: 8px; }
.bot-row { display: flex; align-items: flex-end; gap: 8px; max-width: 92%; }
.avatar-mini { width: 32px; height: 32px; flex: none; object-fit: contain; border-radius: 50%; background: color-mix(in srgb, var(--char-soft) 70%, var(--panel)); padding: 1px; }
.msg { max-width: 82%; padding: 11px 16px; border-radius: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user-bubble); color: var(--user-ink); border-bottom-right-radius: 8px; font-weight: 500; }
.bot-row .msg.bot { max-width: none; }
.msg.bot { align-self: flex-start; background: var(--bot-bubble); border-bottom-left-radius: 8px; }
.msg .meta { font-size: 13px; color: var(--muted); margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg .meta a { font-weight: 700; }
.msg .meta button.small { min-height: 30px; padding: 0 12px; background: var(--panel); }
.msg.failed { background: var(--danger-soft); }
.msg .md { white-space: normal; }
.md p, .md ul, .md ol, .md pre { margin: 0 0 8px; }
.md > :last-child { margin-bottom: 0; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: 2px; }
.md pre { background: var(--panel); padding: 8px 10px; border-radius: 10px; overflow-x: auto; white-space: pre; }
.md pre code { background: none; padding: 0; word-break: normal; }
.md a { word-break: break-all; }
.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 6px 6px 6px 8px; margin: 4px 0 max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-float);
}
.composer textarea { flex: 1; border: 0; background: transparent; border-radius: 22px; padding: 10px 10px; max-height: 40vh; resize: none; min-height: 44px; }
.composer textarea:focus-visible { outline: none; }
.composer:focus-within { border-color: color-mix(in srgb, var(--char) 55%, var(--line)); }
.composer button { flex: none; min-height: 44px; }

/* ---- pills & filters ---- */
.pill { font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; color: var(--muted); background: var(--panel); display: inline-flex; align-items: center; gap: 6px; }
.list li .pill { background: var(--panel-2); }
.pill[data-status="completed"], .pill[data-tone="ok"] { color: var(--ok); background: var(--ok-soft) !important; }
.pill[data-status="failed"], .pill[data-status="cancelled"], .pill[data-tone="danger"] { color: var(--danger); background: var(--danger-soft) !important; }
.pill[data-status="waiting_approval"], .pill[data-tone="warn"] { color: var(--warn); background: var(--warn-soft) !important; }
.pill[data-tone="info"] { color: var(--accent-text); background: var(--accent-soft) !important; }
.pill[data-status="queued"]::before, .pill[data-status="running"]::before, .pill[data-status="planning"]::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--char); animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.filters button { min-height: 38px; padding: 0 16px; font-size: 14px; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--ink-text); }
.activity li .pill { white-space: nowrap; }
#activity-more { margin-top: 14px; }

/* ---- lists ---- */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.list li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.list li .row + * { margin-top: 6px; }
.list li > * + * { margin-top: 4px; }
.list > li.muted:only-child {
  background: transparent; box-shadow: none; border: 1.5px dashed var(--line-strong); text-align: center; padding: 28px 16px;
}
.amount { font: 800 30px/1.15 var(--font-display); letter-spacing: -.03em; margin: 6px 0; }
#approval-list li .row:last-child { margin-top: 14px; justify-content: flex-end; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: calc(110px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--ink-text);
  padding: 12px 18px; border-radius: 999px; max-width: min(92vw, 520px); box-shadow: var(--shadow-float); z-index: 30; font-size: 15px; font-weight: 600;
}
.toast[data-kind="error"] { background: var(--danger); color: #fff; }
.toast[data-kind="error"] { color: #1b0a08; }

/* ---- devices ---- */
#pair-qr { background: #fff; border-radius: 14px; padding: 8px; image-rendering: pixelated; }

/* ---- footer: legal + Instagram ---- */
.legal-links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 2px; padding: 2px 16px max(8px, env(safe-area-inset-bottom)); color: var(--muted); }
.legal-links a { color: var(--muted); min-height: 32px; display: inline-flex; align-items: center; gap: 5px; padding: 0 6px; text-decoration: none; font-weight: 500; }
.legal-links a:hover { color: var(--text); text-decoration: underline; }
.legal-links .social .ico { width: 17px; height: 17px; }


/* ---- composer pill: + · text · mic · call (send replaces call while typing) ---- */
.composer { align-items: center; padding: 6px; gap: 4px; border-radius: 999px; background: var(--panel-2); }
.composer textarea { padding: 10px 6px; min-height: 44px; max-height: 30vh; font-size: 16.5px; }
.icon-btn { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; background: transparent; color: var(--text); }
.icon-btn:hover:not(:disabled) { background: var(--panel-3); }
.icon-btn .ico { width: 24px; height: 24px; }
.call-btn, .send-btn { width: 46px; height: 46px; min-height: 0; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; flex: none; }
.call-btn { background: #3a3b3f; color: #8d8e8a; cursor: not-allowed; }
.call-btn:hover:not(:disabled) { background: #3a3b3f; }
.call-btn .ico { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.send-btn { background: var(--ink); color: var(--ink-text); display: none; }
.send-btn:hover:not(:disabled) { background: var(--ink); filter: brightness(.9); }
.send-btn .ico { stroke-width: 2.4; }
.composer.has-text .send-btn { display: inline-grid; }
.composer.has-text .call-btn { display: none; }
@supports selector(:has(a)) {
  .composer:has(textarea:not(:placeholder-shown)) .send-btn { display: inline-grid; }
  .composer:has(textarea:not(:placeholder-shown)) .call-btn { display: none; }
}
#view-chat .chat-empty .muted { color: var(--muted); }
body[data-view="chat"] .legal-links { display: none; }

@media (min-width: 900px) {
  /* Desktop: the drawer becomes a persistent sidebar, the tab bar and hamburger go away. */
  body[data-signed-in="yes"] { padding-left: 300px; }
  body[data-signed-in="yes"] .drawer { width: 300px; animation: none; box-shadow: none; }
  body[data-signed-in="yes"] #menu-btn, body[data-signed-in="yes"] #tabbar { display: none !important; }
  body:has(#tabbar:not([hidden])) main { padding-bottom: 24px; }
  body:has(#tabbar:not([hidden])) #view-chat { padding-bottom: 0; }
}
@media (max-width: 560px) {
  main { padding: 8px 14px; }
  .msg { max-width: 86%; }
  .narrow { margin: 20px auto; }
  h1 { font-size: 27px; }
  .chat-empty h2 { font-size: 26px; }
  .companion-hero img { --size: 140px; }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
  body:has(#tabbar:not([hidden])) .legal-links { padding-bottom: calc(86px + max(10px, env(safe-area-inset-bottom))); }
}

/* ---- splash v2 (splash.js): the green companion (id pip, shown as "Amadeus") runs in over the ARPEO wordmark,
   brakes at the centre, hops and leaps into the chat header avatar. The dashed trail is real load progress
   (its width is set from JS); while loading continues he jogs in place. Without JS it fades by itself. ---- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(90% 50% at 50% 40%, #12201a 0%, transparent 70%), #070808;
  animation: splash-out .38s ease 1.62s forwards; transition: opacity .38s ease;
}
/* splash.js takes over the timing; this is only a fail-safe if something never finishes. */
.splash.js { animation: splash-out .4s ease 9s forwards; }
.splash.out { opacity: 0; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
.splash-stage { position: relative; width: 100%; height: 250px; overflow: hidden; }
.splash-runner { position: absolute; left: 0; bottom: 70px; width: 96px; height: 128px; transform: translateX(-110px); }
.splash:not(.js) .splash-runner { animation: run-across 1.6s cubic-bezier(.3, .1, .6, .9) forwards; }
@keyframes run-across { from { transform: translateX(-110px); } to { transform: translateX(calc(100vw + 30px)); } }
.splash-pip {
  position: absolute; inset: 0; background: url("/splash/pip-run.webp") 0 0 / 800% 100% no-repeat;
  animation: run-cycle .44s steps(8) infinite; transform-origin: 50% 100%;
}
@keyframes run-cycle { from { background-position: 0 0; } to { background-position: 114.2857% 0; } }
/* Brake: a quick squash as he stops; jog: a looping hop in place; hop: one bigger hop before the leap. */
.splash-runner.brake .splash-pip { animation: run-cycle .44s steps(8) infinite paused, brake .2s ease-out; }
.splash-runner.jog .splash-pip { animation: run-cycle .44s steps(8) infinite, jog .44s ease-in-out infinite; }
.splash-runner.hop .splash-pip { animation: hop .36s cubic-bezier(.3, .7, .4, 1) forwards; background-position: 28.57% 0; }
@keyframes brake { 50% { transform: scale(1.1, .88) skewX(-8deg); } }
@keyframes jog { 50% { transform: translateY(-12px); } }
@keyframes hop { 0% { transform: scale(1.08, .9); } 45% { transform: translateY(-34px) scale(.95, 1.06); } 100% { transform: translateY(-22px); } }
.splash-trail {
  position: absolute; left: 0; bottom: 64px; width: 0; height: 12px; transition: width .35s cubic-bezier(.3, .7, .3, 1);
  background:
    repeating-linear-gradient(90deg, #8b8f8a 0 14px, transparent 14px 26px) 0 0 / 100% 2px no-repeat,
    radial-gradient(circle, #8b8f8a 1.5px, transparent 2px) 0 7px / 34px 6px repeat-x,
    radial-gradient(circle, #8b8f8a 1px, transparent 1.5px) 17px 9px / 47px 4px repeat-x;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .25) 45%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, .25) 45%, #000 100%);
}
.splash-static { display: none; margin: 0 auto; width: 120px; height: 160px; }
.splash-word {
  position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: .32em;
  font: 800 30px/1 var(--font-display); letter-spacing: 0; color: #cfd2cd;
}
.splash-l { display: inline-block; opacity: .5; transition: color .25s, opacity .25s, text-shadow .25s; }
.splash-l.lit { color: #7ee08a; opacity: 1; text-shadow: 0 0 14px rgba(110, 220, 125, .75), 0 0 2px rgba(110, 220, 125, .9); animation: letter-bounce .42s cubic-bezier(.3, .7, .4, 1.4); }
@keyframes letter-bounce { 40% { transform: translateY(-7px); } }
.flyer { position: fixed; z-index: 101; margin: 0; pointer-events: none; }
/* View Transitions: the runner and the header avatar share this name; the app fades/scales in under it. */
.vt-hero { view-transition-name: companion-hero; }
::view-transition-group(companion-hero) { animation-duration: .62s; animation-timing-function: cubic-bezier(.3, .6, .25, 1); }
::view-transition-old(root) { animation: splash-fade .4s ease both; }
::view-transition-new(root) { animation: ui-in .55s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes splash-fade { to { opacity: 0; } }
@keyframes ui-in { from { opacity: 0; transform: scale(.96); } }
.splash[data-mode="still"] .splash-runner, .splash[data-mode="still"] .splash-trail { display: none; }
.splash[data-mode="still"] .splash-static { display: block; position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); }
.splash[data-mode="still"] .splash-l { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .splash { animation: splash-out .3s ease .6s forwards !important; animation-duration: .3s !important; }
  .splash.js { animation-delay: 9s !important; }
  .splash-runner, .splash-trail { display: none; }
  .splash-static { display: block; position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* Read-aloud voice and dictation */
.meta .listen[aria-pressed="true"] { border-color: var(--accent, #3b82f6); }
.composer .mic { min-width: 44px; }
.composer .mic.listening { outline: 2px solid #dc2626; outline-offset: 1px; }
.row-check { display: flex; gap: 8px; align-items: center; }
.row-check input[type="checkbox"] { width: auto; flex: none; margin: 0; }

/* ---------------------------------------------------------- Package P: layered memory */
.spacer { flex: 1 1 auto; }
.row.wrap { flex-wrap: wrap; }
.pill-sensitive { background: var(--danger-soft); color: var(--danger); }
.m2 h2 { margin-bottom: 4px; }
.m2-search input[type="search"] { flex: 1 1 240px; min-width: 0; }
.m2-results:not([hidden]) { margin-bottom: 12px; }
.m2-layer { background: var(--ink); color: var(--ink-text); }
.m2-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 8px 0; }
.m2-tabs::-webkit-scrollbar { display: none; }
.m2-tab { border-radius: 999px; background: transparent; border: 1px solid var(--line); white-space: nowrap; }
.m2-tab[aria-selected="true"] { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.m2-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; }
.m2-pane .list > li { padding: 12px 0; }
.share-form input[type="email"] { flex: 1 1 180px; min-width: 0; }
.m2-settings summary { cursor: pointer; font-weight: 600; }
.m2-settings[open] summary { margin-bottom: 12px; }
.m2-notice { margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--panel-2); font-size: 0.9em; }

/* Package Q: Rutinas */
#routines-body > .card { margin-bottom: 1rem; }
#routines-body label.row { gap: .5rem; align-items: center; justify-content: flex-start; flex-wrap: nowrap; }
#routines-body input[type="checkbox"] { width: 1.2rem; height: 1.2rem; flex: none; margin: 0; }
#routines-body .warn { color: var(--warn, #a15c00); }
#routine-preview[data-tone="danger"] { color: var(--danger); }
#routines-body textarea, #routines-body input:not([type="checkbox"]):not([type="file"]), #routines-body select { width: 100%; }
#routines-body .row input[type="time"] { width: auto; }

/* Package S: link styled as a button (Drive card), picker page result tones. */
a.button { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 20px; border-radius: 999px; font: 700 15px/1.2 var(--font); text-decoration: none; background: var(--panel-2); color: var(--text); }
a.button.primary { background: var(--ink); color: var(--ink-text); }
#picker-result li[data-tone="danger"] { color: var(--danger, #b42318); }

/* ================= UI v3 round 2 ================= */
/* ---- grouped settings list (Perfil and its subscreens) ---- */
.settings { max-width: 560px; margin: 0 auto; }
.stack-tight { display: flex; flex-direction: column; gap: 12px; }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.group + .group { margin-top: 12px; }
.stack-tight .group + .group { margin-top: 0; }
.sec-label { margin: 14px 4px 0; font: 700 13.5px/1.2 var(--font); letter-spacing: 0; color: var(--muted); }
.grow {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 12px 16px; text-align: left;
  background: transparent; border: 0; border-radius: 0; color: var(--text); text-decoration: none; font: inherit; font-weight: 500; position: relative;
}
.grow + .grow::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; border-top: 1px solid var(--line); }
.grow:hover:not(:disabled):not(.static):not(.is-disabled) { background: var(--panel-2); }
.grow .lead { width: 22px; height: 22px; color: var(--text); opacity: .9; }
.grow-text { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; }
.grow-title { font-size: 16px; overflow-wrap: anywhere; }
.grow-val { color: var(--muted); font-size: 15px; text-align: right; max-width: 55%; overflow-wrap: anywhere; }
.grow .chev { width: 18px; height: 18px; color: var(--muted); }
.grow.static .grow-text + .grow-val { margin-left: auto; }
.grow.is-disabled { color: var(--muted); }
.grow.is-disabled .grow-val { opacity: .7; }
.group .grow:not(:has(.lead)):not(:has(.avatar-round)):not(:has(.lead-badge))::before { left: 16px; }
.danger-text, .grow.danger-text, .text-btn.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.group-note { margin: 6px 6px 4px; }
.version { margin: 18px 0 4px; }
.ico.flip { transform: scaleX(-1); }
.lead-badge { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); }
.lead-badge.big { width: 56px; height: 56px; border-radius: 18px; }
.lead-badge.big .ico { width: 28px; height: 28px; }
.avatar-round { flex: none; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--panel-3); }
.avatar-round img { width: 44px; height: 44px; object-fit: contain; }
.profile-top { padding: 18px 18px 16px; }
.profile-top h2 { margin: 0 0 2px; font-size: 24px; }
.profile-top p { margin: 0; }
.subhead { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; margin: 0 0 14px; }
.subhead h2 { margin: 0; text-align: center; font-size: 19px; }
.subhead .round-btn { width: 44px; height: 44px; text-decoration: none; display: inline-grid; place-items: center; color: var(--text); }
.subhead-spacer { width: 44px; }
.account-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 22px; }
.text-btn { background: transparent; border: 0; font-weight: 700; font-size: 16px; min-height: 44px; padding: 0 18px; color: var(--text); }
.text-btn:hover:not(:disabled) { background: var(--panel-2); }
a.button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 999px; font-weight: 700; text-decoration: none; }
a.button.danger { background: var(--danger); color: #1a0b09; }
a.button.wide, .sheet button.wide { width: 100%; margin-top: 8px; }
.soon-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 28px 22px; }
.soon-card p { margin: 0; max-width: 34ch; }
.faq { display: block; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.faq p { margin: 6px 0 2px; }
.check { color: var(--accent-text); }
.check-spacer { width: 22px; }
/* iOS-like switch on a real checkbox (role=switch) */
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; margin: 0; border-radius: 999px; border: 0;
  background: var(--panel-3); position: relative; cursor: pointer; transition: background .2s;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #f3f3f1; box-shadow: 0 2px 4px rgba(0, 0, 0, .35); transition: transform .2s; }
.switch:checked { background: var(--char); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
label.grow { cursor: pointer; }

/* ---- connections: profile card, hub ---- */
.conn-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.conn-card-text { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.conn-icons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.conn-ico { flex: none; width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--panel-3); color: var(--text); }
.conn-ico.sm { width: 28px; height: 28px; border-radius: 9px; }
.conn-ico.sm .ico { width: 16px; height: 16px; }
.conn-ico.plus { border: 1.5px dashed var(--line-strong); background: transparent; color: var(--muted); }
.conn-ico[data-tint="blue"] { background: #1c2a40; color: #8fb4ff; }
.conn-ico[data-tint="red"] { background: #3a1d1d; color: #ff9b8f; }
.conn-ico[data-tint="amber"] { background: #3a2e14; color: #f0c060; }
.conn-ico[data-tint="green"] { background: #17301f; color: #7ee08a; }
.conn-ico[data-tint="violet"] { background: #29233f; color: #b9adff; }
.info-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; margin: 14px 0 4px; padding: 2px 0; scrollbar-width: none; scroll-snap-type: x proximity; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip { flex: none; min-height: 38px; border-radius: 999px; scroll-snap-align: start; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.active-row { display: flex; align-items: center; gap: 10px; margin: 12px 2px 6px; font-weight: 600; }
.active-row .conn-icons { flex: 1; }
.conn-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; }
.conn-row { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.conn-row:last-child { border-bottom: 0; }
.conn-row .grow-title { font-weight: 700; }
.conn-row .pill { flex: none; text-decoration: none; }
.add-btn { width: 40px; height: 40px; }
.conn-none { padding: 18px 4px; }
#view-hub { padding-bottom: 24px; }
#view-hub .conn-list { padding-bottom: 8px; }
.search-pill {
  position: sticky; bottom: 96px; display: flex; align-items: center; gap: 10px; margin: 18px auto 0; padding: 0 16px; min-height: 50px; max-width: 520px;
  border-radius: 999px; background: color-mix(in srgb, var(--panel-2) 82%, transparent); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3); box-shadow: var(--shadow-float);
}
.search-pill input { flex: 1; min-height: 46px; border: 0; background: transparent; padding: 0; font-size: 16px; }
.search-pill input:focus-visible { outline: none; }
.search-pill:focus-within { border-color: color-mix(in srgb, var(--char) 55%, var(--line)); }

/* ---- Archivo: segmented control, files, media grid, FAB ---- */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 6px 0 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.segmented [role="tab"] { min-height: 40px; border-radius: 999px; background: transparent; border: 0; font-weight: 700; color: var(--muted); }
.segmented [role="tab"][aria-selected="true"] { background: var(--panel-3); color: var(--text); box-shadow: var(--shadow); }
.day-group .sec-label { margin-top: 12px; }
.file-list, .media-grid { list-style: none; margin: 8px 0 0; padding: 0; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-row .grow-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-ico { flex: none; width: 44px; height: 44px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--panel-2); color: var(--accent-text); }
.file-ico[data-kind="pdf"] { color: #ff9b8f; }
.file-ico[data-kind="sheet"] { color: #7ee08a; }
.file-ico[data-kind="slides"] { color: #f0c060; }
.file-ico[data-kind="doc"] { color: #8fb4ff; }
.kebab { color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.media-tile { position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: var(--panel-2); }
.media-tile img { width: 100%; height: 100%; object-fit: cover; }
.media-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent-text);
  background: linear-gradient(145deg, color-mix(in srgb, var(--char) 26%, var(--panel-2)), var(--panel)); }
.media-ph .ico { width: 34px; height: 34px; opacity: .8; }
.media-ph[data-kind="video"] { background: linear-gradient(145deg, #29233f, var(--panel)); color: #b9adff; }
.media-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; font-size: 12.5px; font-weight: 600; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 18px; }
.empty-state p { margin: 0; max-width: 32ch; }
.archive-more { margin-top: 22px; }
.archive-more summary { cursor: pointer; font-weight: 700; color: var(--muted); min-height: 40px; display: flex; align-items: center; }
.fab {
  position: fixed; right: max(18px, calc(50vw - 362px)); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 12; width: 58px; height: 58px; padding: 0;
  border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--ink-text); box-shadow: var(--shadow-float);
}
.fab .ico { width: 26px; height: 26px; stroke-width: 2.2; }

/* ---- composer "+": frosted floating menu (Fotos, Cámara, Archivos, Conexiones) ---- */
.sheet.attach-sheet {
  left: max(12px, calc(50vw - 368px)); right: auto; bottom: calc(150px + env(safe-area-inset-bottom)); width: min(250px, calc(100vw - 24px));
  transform: none; padding: 8px; border: 1px solid color-mix(in srgb, #ffffff 10%, transparent); border-radius: 24px;
  background: color-mix(in srgb, var(--panel-2) 72%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4);
  animation: attach-pop .2s cubic-bezier(.2, .8, .2, 1); transform-origin: 10% 100%;
}
.sheet.attach-sheet[data-anchor="fab"] { left: auto; right: max(12px, calc(50vw - 368px)); bottom: calc(166px + env(safe-area-inset-bottom)); transform-origin: 90% 100%; }
@keyframes attach-pop { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: none; } }
.attach-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 50px; padding: 0 14px; border: 0; border-radius: 16px; background: transparent; color: var(--text); font-weight: 600; font-size: 16.5px; text-align: left; }
.attach-row:hover:not(:disabled) { background: color-mix(in srgb, #ffffff 8%, transparent); }
.attach-row .ico { width: 23px; height: 23px; }
body:has(.attach-sheet:not([hidden])) .sheet-backdrop { background: rgba(0, 0, 0, .3); }

/* ---- chat v3: header identity, approval card, compact status, option cards, pull-to-refresh ---- */
.companion-btn { flex-direction: row; gap: 10px; padding: 4px 14px 4px 6px; }
.companion-btn .companion img { --size: 44px; }
.companion-meta { align-items: flex-start; gap: 1px; }
.companion-name { background: transparent; box-shadow: none; padding: 0; font-size: 16px; }
.companion-role, .companion-status { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.msg.bot.needs-approval { border: 1.5px solid color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 6%, var(--bot-bubble)); }
.approval-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.approve-btn { width: 100%; min-height: 48px; background: var(--ink); color: var(--ink-text); }
.secondary-btn { min-height: 44px; padding: 0 18px; border-radius: 999px; background: transparent; border: 0; color: var(--muted); font-weight: 600; }
.secondary-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.pill.xs { font-size: 11.5px; padding: 2px 8px; }
.meta-done { justify-content: flex-end; }
.done-line { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.options { margin: 2px 0 0 40px; }
.options-label { margin: 0 0 6px 2px; }
.option-cards { list-style: none; margin: 0 -16px 0 0; padding: 2px 16px 6px 0; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.option-cards::-webkit-scrollbar { display: none; }
.option-cards li { flex: none; scroll-snap-align: start; }
.option-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 214px; min-height: 104px; height: 100%; padding: 14px 16px; text-align: left;
  border-radius: 20px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-weight: 500; white-space: normal;
}
.option-card:hover:not(:disabled) { background: var(--panel-2); border-color: color-mix(in srgb, var(--char) 40%, var(--line)); }
.option-card strong { font-size: 15.5px; line-height: 1.25; }
.option-card .small { font-size: 13.5px; line-height: 1.35; }
.option-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; font-weight: 800; }
.ptr { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px 0 8px; }
.ptr-track { position: relative; display: block; width: 100%; height: 26px; overflow: hidden; }
.ptr-trail { position: absolute; left: 0; bottom: 3px; height: 2px; width: 0; background: repeating-linear-gradient(90deg, var(--muted) 0 8px, transparent 8px 14px); transition: width .12s; }
.ptr-runner { position: absolute; bottom: 2px; left: 0; width: 18px; height: 24px; background: url("/splash/pip-run.webp") 0 0 / 800% 100% no-repeat; animation: run-cycle .44s steps(8) infinite; transform: translateX(-24px); }
.ptr[data-state="pulling"] .ptr-runner, .ptr[data-state="armed"] .ptr-runner { animation-play-state: paused; transform: translateX(calc(50vw - 40px)); }
.ptr[data-state="loading"] .ptr-runner { animation: run-cycle .44s steps(8) infinite, ptr-run 1.3s linear infinite; }
.ptr[data-state="loading"] .ptr-trail { width: 100%; animation: ptr-dash .44s linear infinite; }
@keyframes ptr-run { from { transform: translateX(-24px); } to { transform: translateX(min(100vw, 760px)); } }
@keyframes ptr-dash { to { background-position: -14px 0; } }
@media (prefers-reduced-motion: reduce) {
  .ptr-runner { display: none; }
  .sheet.attach-sheet { animation: none; }
}

/* ---- Step 11 UI fixes ---- */
/* The sticky top bar gets its own backdrop, so content scrolling under it (the round "Empezar"
   button in Rutinas, pills, cards) no longer shows over the header. */
.topbar {
  background: color-mix(in srgb, var(--base) 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
}
/* Google Drive Picker full-screen on phones (drive-picker.js also calls setSize on narrow screens). */
@media (max-width: 720px) {
  .picker-mobile .picker-dialog {
    top: 0 !important; left: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important;
    max-width: none !important; border-radius: 0 !important;
  }
  .picker-mobile .picker-dialog-content, .picker-mobile .picker-dialog-content iframe,
  .picker-mobile .picker-dialog iframe { width: 100% !important; height: 100% !important; }
}
