/* SystemBars provides --safe-area-inset-* on older Android WebViews. */
:root {
  --ui-safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --ui-safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
}
.phone-shell > .top-bar {
  height: calc(56px + var(--ui-safe-top));
  padding: calc(6px + var(--ui-safe-top)) max(14px, env(safe-area-inset-right)) 6px max(14px, env(safe-area-inset-left));
  gap: 4px;
}
.phone-shell:not(.chat-mode) > .top-bar {
  height: var(--ui-safe-top);
  padding: 0;
  visibility: hidden;
}
.top-bar .chat-locator-rail, .top-bar #serverStatus {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  max-width: none;
  padding: 6px;
  border: 0;
  border-radius: 50%;
  color: var(--accent);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none;
}
.top-bar .chat-locator-rail[hidden] { display: none; }
.top-bar .chat-locator-rail svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gateway-flower { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.25; }
.gateway-petals { transform-origin: 24px 24px; transition: transform .65s ease, opacity .4s; }
.gateway-bud { opacity: 0; transition: opacity .45s; }
.offline .gateway-petals { transform: scale(.12); opacity: 0; }
.offline .gateway-bud { opacity: 1; }
.connecting .gateway-petals { animation: chrysanthemum-bloom 2.4s ease-in-out infinite; }
.connecting .gateway-bud { animation: chrysanthemum-bud 2.4s ease-in-out infinite; }
.gateway-status-label, #chatLocatorDot { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes chrysanthemum-bloom { 0%,100% { transform: scale(.12) rotate(-18deg); opacity: 0; } 50%,70% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes chrysanthemum-bud { 0%,100% { opacity: 1; } 40%,75% { opacity: 0; } }
.message .message-reasoning, .message .message-tools {
  padding: 0;
  margin: 6px 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.message .message-reasoning > summary, .message .message-tools > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 36px;
  padding: 4px 0;
  list-style: none;
  font-size: 13px;
  font-weight: 400;
  color: #777b7a;
  cursor: pointer;
}
.message summary::-webkit-details-marker { display: none; }
.message .message-reasoning > summary::after, .message .message-tools > summary::after { content: "›"; font: 18px system-ui; color: inherit; }
.message .message-reasoning > :not(summary), .message .message-tools > :not(summary) { display: none; }
.activity-sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 680px);
  max-width: 100%;
  max-height: calc(100dvh - var(--ui-safe-top) - 20px);
  height: min(66dvh, 680px);
  margin: 0 auto;
  padding: 10px 22px max(20px, var(--ui-safe-bottom));
  border: 0;
  border-radius: 24px 24px 0 0;
  background: #fafbf9;
  color: var(--ink);
  box-shadow: 0 -12px 60px #0002;
  overflow: hidden;
}
.activity-sheet[open] { display: flex; flex-direction: column; animation: activity-rise .24s ease-out; }
.activity-sheet::backdrop { background: #0005; }
.activity-sheet-handle { width: 32px; height: 4px; flex: 0 0 4px; margin: 0 auto 10px; border-radius: 8px; background: #cccfcd; }
.activity-sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; }
.activity-sheet h2 { font-size: 17px; margin: 0; }
.activity-sheet header button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #777; font: 28px system-ui; }
.activity-sheet-content { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; overflow-wrap: anywhere; }
.activity-sheet .message-reasoning-content { padding: 0; max-height: none; color: #656b68; line-height: 1.85; }
.activity-sheet .message-tools-list { padding: 0; }
.activity-sheet .message-tool-result { max-height: none; }
@keyframes activity-rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Fan of translucent cards inspired by codebykay101's Uiverse reference.
   Touch expands vertically; hovering never changes the selection state. */
#memoryView.memory-at-entrance > :not(.memory-entrance) { display: none !important; }
.memory-entrance { width: 100%; margin: auto 0; padding: 28px 0 20px; text-align: center; }
.memory-entrance[hidden], .memory-entrance-back[hidden] { display: none; }
.memory-entrance .eyebrow { color: var(--accent-ink); letter-spacing: .26em; font-size: 11px; }
.memory-entrance h1 { margin: 12px 0 8px; font-size: 30px; }
.memory-entrance-hint { color: var(--muted); font-size: 13px; margin: 12px 0 24px; }
.memory-deck { position: relative; width: min(100%, 400px); height: 300px; margin: 0 auto; transition: height .55s ease; }
.memory-entry-card {
  position: absolute;
  top: 36px;
  left: calc(50% - 83px);
  width: 166px;
  height: 210px;
  padding: 26px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border: 1px solid #ffffff80;
  border-radius: 16px;
  color: var(--accent-ink);
  background: linear-gradient(145deg, #ffffff65, #ffffff0a);
  box-shadow: 0 18px 28px #123d3022, inset 0 1px #ffffff75;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateX(var(--card-x)) rotate(var(--card-angle));
  transition: transform .55s ease, top .55s ease, width .55s ease, height .55s ease, left .55s ease;
  cursor: pointer;
}
.memory-entry-card:nth-child(1) { --card-x: -40px; --card-angle: -12deg; }
.memory-entry-card:nth-child(2) { --card-x: 40px; --card-angle: 12deg; }
.memory-entry-card svg { width: 40px; height: 40px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.memory-entry-card strong { font-size: 20px; font-weight: 400; }
.memory-entry-card small { display: none; font-size: 12px; color: var(--muted); }
.memory-deck.is-expanded { height: 256px; }
.memory-deck.is-expanded .memory-entry-card { left: 4%; width: 92%; height: 112px; transform: none; flex-direction: row; justify-content: flex-start; gap: 20px; padding: 20px 26px; }
.memory-deck.is-expanded .memory-entry-card:nth-child(1) { top: 0; }
.memory-deck.is-expanded .memory-entry-card:nth-child(2) { top: 130px; }
.memory-deck.is-expanded .memory-entry-card small { display: block; margin-top: 8px; }
.memory-deck.is-expanded .memory-entry-card span { text-align: left; }
.memory-deck-toggle, .memory-entrance-back { min-height: 44px; padding: 8px 14px; border: 0; background: transparent; color: var(--accent-ink); font-size: 13px; cursor: pointer; }
.memory-entrance-back { align-self: flex-start; }
@media (prefers-reduced-motion: reduce) { .gateway-petals, .gateway-bud, .activity-sheet[open], .memory-entry-card, .memory-deck { animation: none; transition: none; } .connecting .gateway-petals { opacity: .6; } }
