* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: var(--app-height); overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; overscroll-behavior: none; }
body { position: fixed; inset: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app { position: relative; width: 100%; height: var(--app-height); overflow: hidden; }
#workspace { position: absolute; inset: 0; display: flex; flex-direction: column; }

.topbar { flex: none; height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) calc(6px + var(--safe-r)) 0 calc(6px + var(--safe-l)); display: flex; align-items: center; gap: 2px; background: var(--bg); z-index: 5; }
.topbar .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }

#chat { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px calc(14px + var(--safe-r)) 12px calc(14px + var(--safe-l)); display: flex; flex-direction: column; gap: 14px; scroll-behavior: auto; -webkit-overflow-scrolling: touch; }
.messages > * { width: 100%; max-width: 820px; margin-inline: auto; flex: none; }
#scroll-down { position: absolute; right: 16px; bottom: 12px; z-index: 3; }

.dock { flex: none; background: var(--bg); padding: 4px calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); display: flex; flex-direction: column; gap: 8px; }
.dock > * { width: 100%; max-width: 820px; margin-inline: auto; }

.drawer { position: absolute; top: 0; bottom: 0; width: min(340px, 88vw); background: var(--surface); z-index: 30; display: flex; flex-direction: column; transition: transform 0.22s ease; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.drawer.left { left: 0; transform: translateX(-102%); border-right: 1px solid var(--line); }
.drawer.right { right: 0; width: min(440px, 100vw); transform: translateX(102%); border-left: 1px solid var(--line); }
.drawer.open { transform: none; }
.drawer-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.drawer-head .grow { flex: 1; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
#scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 25; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#scrim.on { opacity: 1; pointer-events: auto; }

#auth-view { position: absolute; inset: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); z-index: 40; }

#call-overlay { position: absolute; inset: 0; z-index: 60; background: #070a10; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 14px calc(24px + var(--safe-b)); color: #e8ecf3; }
#call-bar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--topbar-h) + var(--safe-t) + 8px); width: min(92vw, 460px); z-index: 45; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; background: rgba(23, 29, 40, 0.92); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); }

#modal-root { position: absolute; inset: 0; z-index: 70; pointer-events: none; }
#modal-root > * { pointer-events: auto; }
#toasts { position: absolute; left: 0; right: 0; bottom: calc(96px + var(--safe-b)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }

@media (min-width: 900px) {
  #workspace { flex-direction: column; }
  .drawer.left { width: 320px; }
}
