:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bg-0: #090b11;
  --bg-1: #0f1420;
  --bg-2: #121a28;
  --bg-3: #172134;
  --surface: rgba(17, 24, 39, 0.84);
  --surface-strong: rgba(12, 18, 30, 0.94);
  --border: rgba(160, 180, 220, 0.14);
  --border-strong: rgba(160, 180, 220, 0.24);
  --text: #edf2ff;
  --muted: #98a7c7;
  --accent: #5d7cff;
  --accent-2: #8f6bff;
  --assistant: #111925;
  --assistant-border: rgba(123, 148, 255, 0.12);
  --user: linear-gradient(180deg, #2e65ff 0%, #224fd0 100%);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --max-width: 1520px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(93, 124, 255, 0.18), transparent 22%),
    radial-gradient(circle at top right, rgba(143, 107, 255, 0.14), transparent 26%),
    linear-gradient(180deg, #0a0d14 0%, #0b1120 100%);
  color: var(--text);
  font-family: "Inter", sans-serif;
}

body {
  min-height: 100svh;
  overscroll-behavior-y: contain;
}

body.lightbox-open {
  overflow: hidden;
}

.shell {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(24px + var(--safe-top)) 24px calc(32px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(10, 15, 24, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-avatar {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7db6ff;
}

.brand h1,
.gallery-header h2,
.vrm-header h2 {
  margin: 3px 0 0;
  font-size: 25px;
  font-weight: 800;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.tab,
.ghost-btn,
.send-btn,
.ghost-link {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.tab {
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
}

.tab.is-active {
  background: rgba(108, 134, 255, 0.16);
  color: #f6f8ff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.character-switcher,
.drawer-character-switcher {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.character-switcher select,
.drawer-character-switcher select {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 10px 13px;
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
  outline: none;
}

.install-btn {
  background: rgba(93, 124, 255, 0.12);
  border-color: rgba(93, 124, 255, 0.24);
}

.is-hidden {
  display: none !important;
}

.ghost-btn,
.ghost-link {
  border-radius: 999px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.ghost-btn:hover,
.ghost-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 20px;
}

.status-strip-inline {
  margin: 0 0 18px;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.status-pill.ok {
  color: #dff7ec;
  background: rgba(72, 184, 125, 0.14);
  border-color: rgba(72, 184, 125, 0.22);
}

.status-pill.warn {
  color: #ffeec2;
  background: rgba(233, 175, 52, 0.12);
  border-color: rgba(233, 175, 52, 0.22);
}

.status-pill.bad {
  color: #ffd8d8;
  background: rgba(255, 103, 103, 0.12);
  border-color: rgba(255, 103, 103, 0.24);
}

.main {
  min-height: calc(100svh - 190px);
}

.panel {
  display: none;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: rgba(10, 15, 24, 0.64);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.tab-panel.is-active {
  display: block;
  pointer-events: auto;
}

.chat-layout {
  padding: 22px;
  min-height: calc(100svh - 248px);
}

.profile-card,
.mini-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 18px;
}

.profile-card {
  display: flex;
  gap: 16px;
}

.profile-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  object-fit: cover;
}

.profile-card h2 {
  margin: 4px 0 8px;
  font-size: 26px;
}

.profile-card p,
.mini-card-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.mini-card-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8eb9ff;
  margin-bottom: 8px;
}

.mini-card-value {
  font-size: 15px;
  font-weight: 600;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.mini-card-btn {
  margin-top: 14px;
}

.chat-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hub-drawer {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(12, 18, 30, 0.72);
  overflow: hidden;
}

.hub-drawer-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.hub-drawer-summary::-webkit-details-marker {
  display: none;
}

.hub-drawer-title-wrap {
  min-width: 0;
}

.hub-drawer-title {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.hub-drawer-summary-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.hub-drawer-preview {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: #dce7ff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.hub-drawer-caret {
  width: 12px;
  height: 12px;
  border-right: 2px solid #93a7d4;
  border-bottom: 2px solid #93a7d4;
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.hub-drawer[open] .hub-drawer-caret {
  transform: rotate(225deg);
}

.hub-drawer-content {
  padding: 0 20px 20px;
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.messages {
  flex: 1;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 12px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.message-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.user .message-avatar {
  display: none;
}

.message-row.user .message-body {
  align-items: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-width: min(80ch, 88%);
}

.message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #8092b8;
}

.route-chip {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(115, 138, 255, 0.14);
  border: 1px solid rgba(115, 138, 255, 0.18);
  color: #d9e3ff;
  font-size: 10px;
}

.model-chip {
  background: rgba(119, 255, 196, 0.1);
  border-color: rgba(119, 255, 196, 0.18);
  color: #d9fff1;
}

.message-bubble {
  border-radius: 24px;
  border: 1px solid var(--assistant-border);
  background: var(--assistant);
  padding: 16px 18px;
  line-height: 1.72;
  font-size: 15px;
  color: #eef3ff;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-row.user .message-bubble {
  background: var(--user);
  border-color: rgba(109, 152, 255, 0.24);
}

.message-bubble img {
  width: min(340px, 100%);
  display: block;
  border-radius: 18px;
  margin-top: 10px;
  cursor: zoom-in;
}

.message-bubble pre,
.message-bubble code {
  font-family: "IBM Plex Mono", monospace;
}

.message-bubble pre {
  margin: 12px 0 0;
  padding: 16px;
  border-radius: 18px;
  background: rgba(4, 9, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
}

.composer-shell {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding-top: 10px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 14px 14px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  background: rgba(8, 13, 22, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.22);
}

.composer-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.composer textarea {
  flex: 1;
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.6;
  min-height: 28px;
  max-height: 220px;
  font-size: 16px;
  padding-right: 42px;
}

.composer textarea::placeholder {
  color: #67799f;
}

.composer-image-btn,
.composer-attach-btn {
  flex: 0 0 auto;
}

.composer-attach-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: #9bb6ff;
  z-index: 2;
}

.composer-attach-btn.is-active {
  color: #f5fbff;
  border-color: rgba(101, 236, 187, 0.42);
  background: rgba(54, 187, 140, 0.18);
  box-shadow: 0 0 18px rgba(54, 187, 140, 0.16);
}

.message-upload-image {
  max-height: 420px;
  object-fit: cover;
}

.send-btn {
  min-width: 108px;
  border-radius: 18px;
  padding: 13px 18px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #5d7cff 0%, #8f6bff 100%);
  box-shadow: 0 14px 30px rgba(93, 124, 255, 0.32);
}

.gallery-header,
.vrm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 10px;
}

.vrm-live-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 24px 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.vrm-live-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
}

.vrm-live-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #82b4ff;
}

.vrm-live-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.vrm-live-status.ok {
  color: #8ff5cd;
}

.vrm-live-status.bad {
  color: #ff9aa8;
}

.vrm-live-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 24px 12px;
  max-height: min(32svh, 280px);
  overflow-y: auto;
  padding: 10px;
  border: 1px solid rgba(130, 180, 255, 0.18);
  border-radius: 20px;
  background: rgba(8, 13, 27, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  -webkit-overflow-scrolling: touch;
}

.vrm-live-log-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.vrm-live-entry {
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.vrm-live-entry-user {
  align-self: flex-end;
  max-width: 88%;
  border-color: rgba(88, 132, 255, 0.28);
  background: rgba(40, 102, 255, 0.18);
}

.vrm-live-entry-riko {
  align-self: flex-start;
  max-width: 92%;
  border-color: rgba(130, 180, 255, 0.22);
  background: rgba(130, 180, 255, 0.1);
}

.vrm-live-entry-system {
  align-self: stretch;
  border-color: rgba(255, 214, 102, 0.18);
  background: rgba(255, 214, 102, 0.08);
}

.vrm-live-log-label {
  display: block;
  margin-bottom: 3px;
  color: #8fb8ff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.vrm-live-log-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  padding: 10px 24px 24px;
}

.gallery-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  overflow: hidden;
}

.gallery-card img {
  width: 100%;
  display: block;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  cursor: zoom-in;
}

.gallery-card-copy {
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.vrm-frame-wrap {
  padding: 0 24px 24px;
}

.vrm-note {
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  line-height: 1.6;
}

#vrm-frame {
  width: 100%;
  min-height: calc(100svh - 180px);
  height: calc(100svh - 180px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: #08101d;
}

.vault-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  padding: 24px;
}

.vault-sidebar,
.vault-main {
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(10, 15, 24, 0.72);
  padding: 18px;
}

.vault-sidebar-header,
.vault-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.vault-main-header h3,
.vault-sidebar-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 800;
}

.vault-albums {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vault-album {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  color: var(--text);
}

.vault-album.is-active {
  border-color: rgba(93, 124, 255, 0.34);
  background: rgba(93, 124, 255, 0.12);
}

.vault-album-cover {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.04);
  flex: 0 0 56px;
}

.vault-album-copy {
  min-width: 0;
}

.vault-album-name {
  font-size: 15px;
  font-weight: 700;
}

.vault-album-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.vault-note {
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  line-height: 1.6;
}

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.vault-item {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(17, 24, 39, 0.84);
  overflow: hidden;
}

.vault-item-preview {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  background: rgba(255, 255, 255, 0.03);
}

.vault-item-file {
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  padding: 18px;
}

.vault-item-copy {
  padding: 14px;
}

.vault-item-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.vault-item-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.vault-main-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) 18px calc(20px + var(--safe-bottom));
  background: rgba(4, 7, 14, 0.92);
  backdrop-filter: blur(20px);
}

.auth-card {
  width: min(100%, 520px);
  border-radius: 30px;
  border: 1px solid var(--border);
  background: rgba(10, 15, 24, 0.96);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-header h2 {
  margin: 6px 0 8px;
  font-size: 30px;
  font-weight: 800;
}

.auth-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-toggle-row {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}

.auth-mode-btn {
  flex: 1;
}

.auth-mode-btn.is-active {
  background: rgba(93, 124, 255, 0.16);
  border-color: rgba(93, 124, 255, 0.24);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.auth-field input,
.auth-field textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
  outline: none;
}

.auth-field textarea {
  min-height: 92px;
  resize: vertical;
}

.auth-field input:focus,
.auth-field textarea:focus {
  border-color: rgba(93, 124, 255, 0.34);
}

.persona-card {
  width: min(100%, 680px);
  max-height: calc(100svh - 42px);
  overflow-y: auto;
}

.persona-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  color: #9cb8ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.persona-progress-dots {
  display: flex;
  flex: 1;
  gap: 6px;
}

.persona-progress-dot {
  height: 5px;
  flex: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.persona-progress-dot.is-active {
  background: linear-gradient(90deg, #ff4aa8, #8b6dff);
  box-shadow: 0 0 18px rgba(255, 74, 168, 0.24);
}

.persona-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.persona-start-step {
  gap: 16px;
}

.persona-section-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-align: center;
}

.persona-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.persona-choice {
  min-height: 86px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.persona-choice.is-active {
  background: rgba(93, 124, 255, 0.18);
  border-color: rgba(125, 182, 255, 0.36);
}

.persona-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.persona-card-grid-large {
  min-height: auto;
}

.persona-card-grid-large .persona-option-card {
  min-height: 240px;
  justify-content: center;
}

.persona-option-card {
  position: relative;
  overflow: hidden;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.persona-option-card.is-portrait-card {
  min-height: 198px;
  justify-content: flex-end;
  padding: 16px;
  border-radius: 22px;
  background: var(--persona-card-bg, rgba(255, 255, 255, 0.045));
}

.persona-style-grid .persona-option-card.is-portrait-card {
  min-height: 132px;
}

.persona-option-card.is-portrait-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 68% 24%, rgba(255, 255, 255, 0.18), transparent 18%),
    linear-gradient(to top, rgba(5, 8, 18, 0.88), rgba(5, 8, 18, 0.08) 62%, rgba(255, 255, 255, 0.04));
}

.persona-option-card.is-portrait-card .persona-option-visual {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--persona-card-bg, linear-gradient(135deg, rgba(93, 124, 255, 0.28), rgba(255, 74, 168, 0.18)));
  color: rgba(255, 255, 255, 0.34);
  font-size: 72px;
  text-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.persona-option-card.is-portrait-card .persona-option-visual::after {
  content: "";
  position: absolute;
  inset: 20% 22% 16%;
  border-radius: 44% 44% 20% 20%;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.32) 0 15%, transparent 16%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05));
  opacity: 0.84;
}

.persona-option-card.is-portrait-card .persona-option-visual.is-image::after {
  display: none;
}

.persona-option-card.is-portrait-card .persona-option-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.persona-option-card.is-portrait-card .persona-option-label,
.persona-option-card.is-portrait-card .persona-option-detail {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
}

.persona-option-card.is-portrait-card .persona-option-label {
  font-size: 21px;
}

.persona-option-card.is-portrait-card .persona-option-detail {
  color: rgba(226, 234, 255, 0.84);
}

.persona-option-card.is-active {
  background: linear-gradient(135deg, rgba(93, 124, 255, 0.24), rgba(89, 217, 163, 0.12));
  border-color: rgba(125, 182, 255, 0.48);
  box-shadow: 0 0 0 1px rgba(125, 182, 255, 0.14) inset;
}

.persona-option-card.is-portrait-card.is-active {
  border-color: rgba(255, 93, 180, 0.88);
  box-shadow:
    0 0 0 2px rgba(255, 93, 180, 0.36) inset,
    0 18px 45px rgba(255, 74, 168, 0.18);
}

.persona-option-card.is-portrait-card.is-active::after {
  content: "v";
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ff5db4;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(255, 93, 180, 0.34);
}

.persona-option-card.is-female {
  --persona-card-bg: linear-gradient(145deg, #f08bbb, #7f5dff 58%, #17233e);
}

.persona-option-card.is-male {
  --persona-card-bg: linear-gradient(145deg, #6fb6ff, #273e84 60%, #10172a);
}

.persona-option-card.is-trans-girl {
  --persona-card-bg: linear-gradient(145deg, #68d9ff, #ff8ad1 52%, #7c6bff);
}

.persona-option-card.is-trans-man {
  --persona-card-bg: linear-gradient(145deg, #9ee7ff, #88a5ff 52%, #ff8faf);
}

.persona-option-card.is-femboy {
  --persona-card-bg: linear-gradient(145deg, #ffaad5, #9f7cff 54%, #58d1ff);
}

.persona-option-card.is-riko {
  --persona-card-bg: linear-gradient(145deg, #5b3af0, #ff76bf 58%, #11192f);
}

.persona-option-card.is-realistic {
  --persona-card-bg: linear-gradient(145deg, #b88a6d, #3e5c82 58%, #10131d);
}

.persona-option-card.is-anime {
  --persona-card-bg: linear-gradient(145deg, #ff91d0, #8b6dff 54%, #2b88ff);
}

.persona-option-visual {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #dfe8ff;
  font-size: 18px;
  font-weight: 900;
}

.persona-option-visual.is-swatch {
  background: var(--persona-swatch);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.persona-option-label {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.persona-option-detail {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.persona-option-card.is-multi::after {
  content: "Tap to toggle";
  color: #9cb8ff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.persona-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.persona-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.persona-check-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.persona-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.persona-actions .send-btn,
.persona-actions .ghost-btn {
  width: 100%;
}

.create-ai-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.create-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.create-ai-header h2 {
  margin: 3px 0 0;
  font-size: 25px;
  font-weight: 800;
}

.create-ai-note {
  color: var(--muted);
  line-height: 1.6;
  max-width: 860px;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.character-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  grid-template-areas:
    "avatar copy"
    "avatar action";
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
}

.character-card.is-active {
  border-color: rgba(125, 182, 255, 0.34);
  background: rgba(93, 124, 255, 0.11);
}

.character-card-avatar {
  grid-area: avatar;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.character-card-copy {
  grid-area: copy;
  min-width: 0;
}

.character-card-copy h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.character-card-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.character-card-action {
  grid-area: action;
  align-self: end;
  width: fit-content;
  min-width: 88px;
}

.auth-submit-btn,
.auth-google-btn {
  width: 100%;
  margin-top: 10px;
}

.auth-note {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.auth-error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 103, 103, 0.24);
  background: rgba(255, 103, 103, 0.08);
  color: #ffd8d8;
  line-height: 1.5;
  font-size: 14px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  background: rgba(4, 7, 14, 0.94);
  backdrop-filter: blur(18px);
}

.lightbox-close {
  position: absolute;
  top: calc(18px + var(--safe-top));
  right: 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.lightbox-image {
  max-width: min(96vw, 980px);
  max-height: 82vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.lightbox-video {
  max-width: min(96vw, 980px);
  max-height: 82vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 20px;
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.lightbox-caption {
  max-width: min(92vw, 900px);
  color: #dce7ff;
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
}

/* ============================================================
   TABLET ≤1100px
   ============================================================ */
@media (max-width: 1100px) {
  .drawer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vault-shell {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MOBILE ≤820px
   THE REAL FIX: single-row topbar, hide actions, big text
   ============================================================ */
@media (max-width: 820px) {
  /* Shell: edge-to-edge */
  .shell {
    padding: calc(6px + var(--safe-top)) 6px calc(10px + var(--safe-bottom));
    max-width: none;
  }

  /* ── TOPBAR: single row, no wrapping ── */
  .topbar {
    position: sticky;
    top: calc(6px + var(--safe-top));
    z-index: 20;
    border-radius: 20px;
    padding: 10px 12px;
    gap: 10px;
    /* CRITICAL: no flex-wrap – topbar stays single row */
    flex-wrap: nowrap;
    min-height: 0;
  }

  /* Brand: compact */
  .brand {
    gap: 10px;
    flex-shrink: 0;
  }

  .brand-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand h1 {
    font-size: 20px;
    margin: 0;
  }

  .brand {
    flex: 1;
    min-width: 0;
  }

  .character-switcher {
    order: 2;
    display: flex;
    min-width: 104px;
    max-width: 118px;
  }

  .character-switcher span {
    display: none;
  }

  .character-switcher select {
    padding: 9px 10px;
    font-size: 12px;
  }

  .nav-drawer-toggle {
    order: 3;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  /* Tabs: fill remaining space in the single topbar row */
  .tabs {
    flex: 1;
    padding: 5px;
    gap: 4px;
    justify-content: stretch;
  }

  .tab {
    flex: 1;
    min-height: 52px;
    font-size: 15px;
    font-weight: 700;
    padding: 10px 6px;
    text-align: center;
  }

  /* Header actions: hidden on mobile – Warm/Clear moved to drawer */
  .header-actions {
    display: none;
  }

  .create-ai-header {
    align-items: stretch;
    flex-direction: column;
  }

  .persona-grid,
  .persona-card-grid,
  .persona-choice-grid,
  .persona-actions {
    grid-template-columns: 1fr;
  }

  .persona-card-grid-large {
    min-height: auto;
  }

  .persona-card-grid-large .persona-option-card {
    min-height: 180px;
  }

  .persona-start-step .persona-card-grid,
  .persona-start-step .persona-style-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .persona-start-step .persona-card-grid-large .persona-option-card {
    min-height: 158px;
  }

  .persona-start-step .persona-style-grid .persona-option-card {
    min-height: 118px;
  }

  /* ── PANEL ── */
  .panel {
    border-radius: 22px;
  }

  /* ── CHAT LAYOUT ── */
  .chat-layout {
    padding: 8px;
    min-height: calc(100svh - 120px);
  }

  /* ── HUB DRAWER ── */
  .hub-drawer {
    margin-bottom: 10px;
    border-radius: 18px;
  }

  .hub-drawer-summary {
    padding: 14px 16px;
    align-items: center;
  }

  .hub-drawer-title-wrap .eyebrow {
    font-size: 10px;
  }

  .hub-drawer-title {
    font-size: 17px;
    margin-top: 2px;
  }

  .hub-drawer-summary-right {
    gap: 10px;
  }

  .hub-drawer-preview {
    font-size: 13px;
    padding: 7px 12px;
  }

  .hub-drawer-content {
    padding: 0 14px 16px;
  }

  .drawer-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .status-strip-inline {
    margin-bottom: 12px;
  }

  /* ── MESSAGES: full width, phone-readable ── */
  .messages {
    padding: 8px 4px 16px;
    gap: 20px;
    min-height: 0;
  }

  .message-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
  }

  .message-body {
    /* nearly full width since avatar is small */
    max-width: calc(100% - 52px);
  }

  .message-row.user .message-body {
    max-width: 92%;
  }

  /* THE TEXT THAT FEELS TINY – make it obviously bigger */
  .message-bubble {
    border-radius: 20px;
    padding: 18px 20px;
    font-size: 20px;
    line-height: 1.75;
  }

  .message-bubble pre {
    font-size: 15px;
    line-height: 1.55;
  }

  .message-bubble img {
    width: 100%;
    max-width: 400px;
  }

  .message-meta {
    font-size: 13px;
    gap: 8px;
  }

  .route-chip {
    font-size: 12px;
    padding: 4px 9px;
  }

  /* ── COMPOSER: sticky bottom, big touch targets ── */
  .composer-shell {
    position: sticky;
    bottom: 0;
    z-index: 18;
    padding-top: 6px;
  }

  .composer {
    border-radius: 22px;
    padding: 14px 14px 14px 14px;
    gap: 10px;
  }

  .composer textarea {
    font-size: 20px;
    line-height: 1.6;
  }

  .composer-image-btn {
    min-height: 52px;
    min-width: 88px;
    font-size: 16px;
    padding: 0 14px;
    border-radius: 16px;
  }

  .send-btn {
    min-height: 52px;
    min-width: 88px;
    font-size: 17px;
    padding: 0 18px;
    border-radius: 16px;
  }

  /* ── STATUS PILLS ── */
  .status-pill {
    font-size: 14px;
    padding: 10px 14px;
  }

  /* ── PROFILE / MINI CARDS ── */
  .profile-card {
    padding: 16px;
    gap: 14px;
  }

  .profile-card-avatar {
    width: 60px;
    height: 60px;
    border-radius: 18px;
  }

  .profile-card h2 {
    font-size: 26px;
    margin: 4px 0 6px;
  }

  .profile-card p,
  .mini-card-copy {
    font-size: 16px;
  }

  .mini-card {
    padding: 16px;
  }

  .mini-card-title {
    font-size: 13px;
  }

  .mini-card-value {
    font-size: 17px;
  }

  /* ── GALLERY ── */
  .gallery-header {
    padding: 18px 14px 10px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 8px 14px 14px;
  }

  .gallery-card-copy {
    font-size: 14px;
    padding: 12px;
  }

  /* ── VRM ── */
  .vrm-header {
    padding: 18px 14px 10px;
  }

  .vrm-live-controls,
  .vrm-live-log {
    margin-left: 14px;
    margin-right: 14px;
  }

  .vrm-live-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .vrm-live-status {
    white-space: normal;
  }

  .vrm-frame-wrap {
    padding: 0 14px 14px;
  }

  .vrm-note {
    font-size: 15px;
    margin-bottom: 12px;
  }

  #vrm-frame {
    min-height: 76svh;
  }

  /* ── LIGHTBOX ── */
  .lightbox-close {
    font-size: 16px;
    padding: 12px 16px;
    min-height: 48px;
  }

  .lightbox-caption {
    font-size: 17px;
  }

.lightbox-image {
  max-width: 98vw;
  border-radius: 16px;
}
}

@media (hover: none) and (pointer: coarse) {
  html {
    font-size: 18px;
  }

  .shell {
    padding: calc(4px + var(--safe-top)) 4px calc(12px + var(--safe-bottom));
    max-width: none;
  }

  .topbar {
    padding: 10px 12px;
    gap: 8px;
    border-radius: 18px;
  }

  .brand {
    gap: 10px;
  }

  .brand-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .brand h1 {
    font-size: 20px;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  .tabs {
    gap: 5px;
    padding: 5px;
  }

  .tab {
    min-height: 56px;
    padding: 12px 8px;
    font-size: 17px;
    font-weight: 700;
  }

  .panel {
    border-radius: 22px;
  }

  .chat-layout {
    padding: 8px 6px;
    min-height: calc(100svh - 120px);
  }

  .hub-drawer {
    margin-bottom: 12px;
    border-radius: 18px;
  }

  .hub-drawer-summary {
    padding: 14px 16px;
    gap: 10px;
  }

  .hub-drawer-title {
    font-size: 18px;
  }

  .hub-drawer-preview {
    font-size: 14px;
    padding: 8px 12px;
  }

  .hub-drawer-content {
    padding: 0 14px 16px;
  }

  .status-strip {
    gap: 8px;
  }

  .status-pill {
    font-size: 15px;
    padding: 10px 14px;
  }

  .profile-card,
  .mini-card {
    padding: 16px;
  }

  .profile-card h2 {
    font-size: 26px;
  }

  .profile-card p,
  .mini-card-copy,
  .mini-card-value {
    font-size: 17px;
    line-height: 1.6;
  }

  .mini-card-title {
    font-size: 13px;
  }

  .ghost-btn,
  .ghost-link {
    min-height: 50px;
    padding: 12px 16px;
    font-size: 16px;
  }

  .messages {
    gap: 20px;
    padding: 8px 6px 18px;
  }

  .message-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
  }

  .message-body {
    max-width: calc(100% - 54px);
  }

  .message-row.user .message-body {
    max-width: 94%;
  }

  .message-meta {
    font-size: 14px;
    gap: 8px;
  }

  .route-chip {
    font-size: 12px;
    padding: 5px 10px;
  }

  .message-bubble {
    padding: 20px 22px;
    font-size: 22px;
    line-height: 1.8;
    border-radius: 22px;
  }

  .message-bubble pre {
    font-size: 16px;
    line-height: 1.6;
  }

  .message-bubble img {
    width: min(360px, 100%);
    max-width: 100%;
  }

  .composer-shell {
    padding-top: 8px;
  }

  .composer {
    gap: 10px;
    padding: 14px;
    border-radius: 22px;
  }

  .composer textarea {
    font-size: 22px;
    line-height: 1.55;
    min-height: 34px;
  }

  .composer-image-btn,
  .send-btn {
    min-height: 56px;
    min-width: 92px;
    font-size: 17px;
    padding: 0 18px;
    border-radius: 16px;
  }

  .gallery-header,
  .vrm-header {
    padding: 18px 14px 10px;
  }

  .gallery-header h2,
  .vrm-header h2 {
    font-size: 24px;
  }

  .gallery-grid {
    gap: 12px;
    padding: 8px 14px 14px;
  }

  .gallery-card-copy,
  .vrm-note,
  .lightbox-caption {
    font-size: 16px;
    line-height: 1.6;
  }

  .lightbox-close {
    min-height: 50px;
    font-size: 16px;
    padding: 12px 16px;
  }
}

/* ============================================================
   SMALL PHONES ≤560px
   Extra boost for compact devices
   ============================================================ */
@media (max-width: 560px) {
  .shell {
    padding: calc(4px + var(--safe-top)) 4px calc(10px + var(--safe-bottom));
  }

  .topbar {
    border-radius: 18px;
    padding: 9px 10px;
  }

  .brand-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .tab {
    min-height: 48px;
    font-size: 14px;
  }

  .panel {
    border-radius: 18px;
  }

  .chat-layout {
    padding: 6px;
  }

  .hub-drawer {
    border-radius: 16px;
    margin-bottom: 8px;
  }

  .hub-drawer-summary {
    padding: 12px 14px;
  }

  .hub-drawer-title {
    font-size: 16px;
  }

  .hub-drawer-content {
    padding: 0 12px 14px;
  }

  .hub-drawer-preview {
    font-size: 13px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .messages {
    padding: 6px 2px 14px;
    gap: 18px;
  }

  .message-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 10px;
  }

  .message-body {
    max-width: calc(100% - 46px);
  }

  .message-bubble {
    border-radius: 18px;
    padding: 16px 18px;
    font-size: 19px;
    line-height: 1.78;
  }

  .message-bubble pre {
    font-size: 14px;
  }

  .composer {
    border-radius: 20px;
    padding: 12px 12px 12px 12px;
    gap: 8px;
  }

  .composer textarea {
    font-size: 19px;
  }

  .composer-image-btn {
    min-height: 48px;
    min-width: 76px;
    font-size: 15px;
    padding: 0 12px;
  }

  .send-btn {
    min-height: 48px;
    min-width: 76px;
    font-size: 16px;
    padding: 0 16px;
  }

  .status-pill {
    font-size: 13px;
    padding: 9px 12px;
  }

  .profile-card h2 {
    font-size: 24px;
  }

  .profile-card p,
  .mini-card-copy,
  .mini-card-value {
    font-size: 16px;
  }

  .gallery-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 6px 10px 10px;
  }

  .vrm-note,
  .gallery-card-copy {
    font-size: 15px;
  }

  .lightbox {
    padding-left: 10px;
    padding-right: 10px;
  }

  .lightbox-image {
    max-width: 100%;
    border-radius: 14px;
  }

  .lightbox-caption {
    font-size: 16px;
  }
}

/* ============================================================
   TOUCH-DEVICE OVERRIDE
   If a phone browser keeps reporting a wide desktop viewport,
   still force the phone-sized layout.
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .shell {
    padding: calc(6px + var(--safe-top)) 6px calc(10px + var(--safe-bottom));
    max-width: none;
  }

  .topbar {
    position: sticky;
    top: calc(6px + var(--safe-top));
    z-index: 20;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 20px;
  }

  .brand {
    gap: 10px;
    flex-shrink: 0;
  }

  .brand-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand h1,
  .gallery-header h2,
  .vrm-header h2 {
    font-size: 20px;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  .tabs {
    flex: 1;
    justify-content: stretch;
    padding: 5px;
    gap: 4px;
  }

  .tab {
    flex: 1;
    min-height: 52px;
    font-size: 15px;
    font-weight: 700;
    padding: 10px 6px;
    text-align: center;
  }

  .header-actions {
    display: none;
  }

  .panel {
    border-radius: 22px;
  }

  .chat-layout {
    padding: 8px;
    min-height: calc(100svh - 120px);
  }

  .hub-drawer {
    margin-bottom: 10px;
    border-radius: 18px;
  }

  .hub-drawer-summary {
    padding: 14px 16px;
    align-items: center;
  }

  .hub-drawer-title {
    font-size: 17px;
    margin-top: 2px;
  }

  .hub-drawer-preview {
    font-size: 13px;
    padding: 7px 12px;
  }

  .hub-drawer-content {
    padding: 0 14px 16px;
  }

  .drawer-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .status-strip-inline {
    margin-bottom: 12px;
  }

  .messages {
    padding: 8px 4px 16px;
    gap: 20px;
    min-height: 0;
  }

  .message-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
  }

  .message-body {
    max-width: calc(100% - 52px);
  }

  .message-row.user .message-body {
    max-width: 92%;
  }

  .message-bubble {
    border-radius: 20px;
    padding: 18px 20px;
    font-size: 20px;
    line-height: 1.75;
  }

  .message-bubble pre {
    font-size: 15px;
    line-height: 1.55;
  }

  .message-bubble img {
    width: 100%;
    max-width: 400px;
  }

  .message-meta {
    font-size: 13px;
    gap: 8px;
  }

  .route-chip {
    font-size: 12px;
    padding: 4px 9px;
  }

  .composer-shell {
    position: sticky;
    bottom: 0;
    z-index: 18;
    padding-top: 6px;
  }

  .composer {
    border-radius: 22px;
    padding: 14px;
    gap: 10px;
  }

  .composer textarea {
    font-size: 20px;
    line-height: 1.6;
  }

  .composer-image-btn {
    min-height: 52px;
    min-width: 88px;
    font-size: 16px;
    padding: 0 14px;
    border-radius: 16px;
  }

  .send-btn {
    min-height: 52px;
    min-width: 88px;
    font-size: 17px;
    padding: 0 18px;
    border-radius: 16px;
  }

  .status-pill {
    font-size: 14px;
    padding: 10px 14px;
  }

  .profile-card {
    padding: 16px;
    gap: 14px;
  }

  .profile-card-avatar {
    width: 60px;
    height: 60px;
    border-radius: 18px;
  }

  .profile-card h2 {
    font-size: 26px;
    margin: 4px 0 6px;
  }

  .profile-card p,
  .mini-card-copy {
    font-size: 16px;
  }

  .mini-card {
    padding: 16px;
  }

  .mini-card-title {
    font-size: 13px;
  }

  .mini-card-value {
    font-size: 17px;
  }

  .gallery-header,
  .vrm-header {
    padding: 18px 14px 10px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 8px 14px 14px;
  }

  .gallery-card-copy {
    font-size: 14px;
    padding: 12px;
  }

  .vrm-frame-wrap {
    padding: 0 14px 14px;
  }

  .vrm-note {
    font-size: 15px;
    margin-bottom: 12px;
  }

  #vrm-frame {
    min-height: 76svh;
  }

  .lightbox-close {
    font-size: 16px;
    padding: 12px 16px;
    min-height: 48px;
  }

  .lightbox-caption {
    font-size: 17px;
  }

  .lightbox-image {
    max-width: 98vw;
    border-radius: 16px;
  }
}

html.android-app-shell,
body.android-app-shell {
  overflow: hidden;
  min-height: 100%;
  height: 100%;
}

body.android-app-shell .shell {
  max-width: none;
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

body.android-app-shell .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 0 0 14px 14px;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

body.android-app-shell .brand-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

body.android-app-shell .brand h1 {
  font-size: 18px;
}

body.android-app-shell .header-actions {
  display: flex;
  margin-left: auto;
  gap: 6px;
}

body.android-app-shell .tabs {
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
}

body.android-app-shell .tab {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
  flex: 0 0 auto;
  white-space: nowrap;
}

body.android-app-shell .tabs::-webkit-scrollbar {
  display: none;
}

/* Mobile/app shell navigation cleanup */
.nav-drawer-toggle,
.nav-drawer,
.nav-drawer-backdrop {
  display: none;
}

.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(88vw, 360px);
  z-index: 60;
  padding: calc(14px + var(--safe-top, 0px)) 14px calc(16px + var(--safe-bottom, 0px));
  background: rgba(8, 12, 20, 0.98);
  border-right: 1px solid rgba(156, 175, 255, 0.16);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
  transform: translateX(-105%);
  transition: transform 180ms ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-drawer.is-open {
  transform: translateX(0);
}

.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(5, 9, 16, 0.68);
}

.nav-drawer-backdrop.is-open {
  display: block;
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.nav-drawer-brand h2 {
  margin: 0;
  font-size: 1.15rem;
}

.nav-drawer-close {
  min-height: 44px;
}

.nav-drawer-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(156, 175, 255, 0.12);
}

.nav-drawer-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.nav-usage-label {
  margin-top: 14px;
}

.nav-drawer-link,
.nav-drawer-mini-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.realworld-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.nav-drawer-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 50px;
  margin-bottom: 8px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid rgba(156, 175, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 600;
}

.nav-drawer-link.is-active,
.nav-drawer-link.is-on {
  background: rgba(90, 112, 255, 0.18);
  border-color: rgba(126, 145, 255, 0.42);
}

.usage-card {
  margin-bottom: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(156, 175, 255, 0.14);
  background: rgba(12, 18, 30, 0.82);
  display: grid;
  gap: 10px;
}

.usage-card-title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8eb9ff;
}

.usage-card-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.usage-card-row strong {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
}

.usage-card-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.nav-drawer-thread-actions {
  margin-bottom: 10px;
}

.drawer-threads-list {
  display: grid;
  gap: 10px;
}

.vault-note[data-mode="working"] {
  color: #c5d5ff;
}

.vault-note[data-mode="success"] {
  color: #9af0c1;
}

.message-row.is-pending .message-bubble {
  opacity: 0.84;
}

body.android-app-shell .threads-panel,
body.riko-phone-ui .threads-panel {
  display: none !important;
}

body.android-app-shell .topbar,
body.riko-phone-ui .topbar {
  display: grid !important;
  grid-template-columns: auto 1fr auto !important;
  align-items: center !important;
  gap: 10px !important;
}

body.android-app-shell .tabs,
body.android-app-shell .header-actions,
body.android-app-shell .threads-toggle-btn,
body.riko-phone-ui .tabs,
body.riko-phone-ui .header-actions,
body.riko-phone-ui .threads-toggle-btn {
  display: none !important;
}

body.android-app-shell .nav-drawer-toggle,
body.riko-phone-ui .nav-drawer-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 18px;
  margin-left: auto;
}

body.android-app-shell .nav-drawer,
body.riko-phone-ui .nav-drawer {
  display: block;
}

body.android-app-shell .nav-drawer-backdrop,
body.riko-phone-ui .nav-drawer-backdrop {
  display: none;
}

body.android-app-shell .header-actions > :not(.gpu-top-btn) {
  display: none;
}

body.android-app-shell .main,
body.android-app-shell .tab-panel.is-active,
body.android-app-shell .chat-layout,
body.android-app-shell .chat-column {
  min-height: 0;
  height: 100%;
}

body.android-app-shell .main {
  flex: 1 1 auto;
  overflow: hidden;
}

body.android-app-shell .panel {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

body.android-app-shell .chat-layout {
  padding: 4px 4px 0;
}

body.android-app-shell .brand,
body.riko-phone-ui .brand {
  gap: 10px;
}

body.android-app-shell .brand-avatar,
body.riko-phone-ui .brand-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

body.android-app-shell .brand h1,
body.riko-phone-ui .brand h1 {
  font-size: 1.85rem;
}

body.android-app-shell .hub-drawer,
body.riko-phone-ui .hub-drawer {
  margin-top: 10px;
}

body.android-app-shell .messages {
  flex: 1 1 auto;
  min-height: 0;
  gap: 12px;
  padding: 6px 6px 12px;
}

body.android-app-shell .message-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
}

body.android-app-shell .message-body {
  max-width: calc(100% - 60px);
}

body.android-app-shell .message-row.user .message-body {
  max-width: 90%;
}

body.android-app-shell .message-meta {
  font-size: 11px;
  gap: 6px;
}

body.android-app-shell .route-chip {
  font-size: 10px;
  padding: 3px 7px;
}

body.android-app-shell .message-bubble {
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
}

body.android-app-shell .message-bubble pre {
  font-size: 12px;
  line-height: 1.45;
}

body.android-app-shell .composer-shell {
  position: sticky;
  bottom: 0;
  padding: 6px 6px calc(8px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 16, 32, 0) 0%, rgba(11, 16, 32, 0.94) 22%);
}

body.android-app-shell .composer {
  border-radius: 18px;
  padding: 8px;
  gap: 8px;
}

body.android-app-shell .composer textarea {
  font-size: 15px;
  line-height: 1.4;
  min-height: 24px;
}

body.android-app-shell .composer-image-btn,
body.android-app-shell .send-btn,
body.android-app-shell .ghost-btn {
  min-height: 42px;
  font-size: 13px;
  padding: 0 12px;
}

body.android-app-shell .gallery-grid {
  gap: 12px;
  padding: 10px 12px 16px;
}

body.android-app-shell .gallery-card-copy,
body.android-app-shell .vrm-note {
  font-size: 14px;
}

body.android-app-shell .hub-drawer-summary {
  padding: 12px 14px;
}

body.android-app-shell .hub-drawer-title {
  font-size: 14px;
}

body.android-app-shell .hub-drawer-preview,
body.android-app-shell .status-pill {
  font-size: 12px;
}

/* ============================================================
   FINAL LAYOUT OVERRIDES: threads rail, visible GPU button,
   Android app-shell fit
   ============================================================ */

.threads-toggle-btn,
.gpu-top-btn {
  flex: 0 0 auto;
}

.gpu-top-btn.is-on {
  background: rgba(79, 211, 156, 0.18);
  border-color: rgba(79, 211, 156, 0.36);
  color: #c7ffea;
}

.chat-layout {
  display: flex;
  gap: 18px;
  align-items: stretch;
}

.threads-panel {
  width: 296px;
  flex: 0 0 296px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(10, 14, 24, 0.92);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100svh - 220px);
  overflow: hidden;
}

.threads-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.threads-panel-header h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.threads-new-btn {
  min-height: 40px;
}

.threads-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.thread-item {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(128, 155, 255, 0.14);
  background: rgba(16, 24, 40, 0.86);
  border-radius: 18px;
  color: var(--text);
  text-align: left;
  padding: 8px;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.thread-item:hover {
  border-color: rgba(128, 155, 255, 0.34);
  background: rgba(18, 30, 52, 0.96);
  transform: translateY(-1px);
}

.thread-item.is-active {
  border-color: rgba(115, 138, 255, 0.46);
  background: rgba(39, 59, 114, 0.38);
  box-shadow: inset 0 0 0 1px rgba(115, 138, 255, 0.2);
}

.thread-item.is-pinned {
  border-color: rgba(125, 182, 255, 0.32);
}

.thread-item-main {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 6px 8px;
  font: inherit;
  cursor: pointer;
}

.thread-item-actions {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
}

.thread-item-action {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(128, 155, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: #dce7ff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.thread-item-menu {
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 20;
  display: none;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(7, 11, 20, 0.98);
  box-shadow: var(--shadow);
}

.thread-item-menu.is-open {
  display: grid;
  gap: 4px;
}

.thread-item-menu button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 10px 11px;
  cursor: pointer;
}

.thread-item-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.thread-item-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: #eef3ff;
}

.thread-item-meta {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: #93a7d4;
}

body.android-app-shell .shell {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

body.android-app-shell .topbar {
  margin-top: 0 !important;
  padding-top: 10px !important;
}

body.android-app-shell .main {
  min-height: 0;
}

body.android-app-shell .threads-panel {
  max-height: none;
}

body.android-app-shell .gpu-top-btn {
  min-width: 92px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

@media (max-width: 1100px) {
  .chat-layout {
    gap: 12px;
  }

  .threads-panel {
    width: 248px;
    flex-basis: 248px;
  }
}

@media (max-width: 820px) {
  .persona-grid,
  .persona-card-grid {
    grid-template-columns: 1fr;
  }

  .threads-toggle-btn {
    min-height: 50px;
    font-size: 15px;
    padding: 0 14px;
  }

  .gpu-top-btn {
    min-height: 50px;
    font-size: 15px;
    padding: 0 14px;
  }

  .chat-layout {
    position: relative;
    display: block;
  }

  .threads-panel {
    position: fixed;
    top: calc(82px + var(--safe-top));
    left: 10px;
    bottom: calc(10px + var(--safe-bottom));
    width: min(82vw, 320px);
    max-height: none;
    z-index: 40;
    transform: translateX(calc(-100% - 18px));
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 28px 54px rgba(0, 0, 0, 0.44);
  }

  .threads-panel.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  body.threads-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 14, 0.44);
    z-index: 35;
  }

  .thread-item-title {
    font-size: 16px;
  }

  .thread-item-meta {
    font-size: 13px;
  }
}

body.android-app-shell .drawer-grid {
  gap: 10px;
}

body.android-app-shell .profile-card,
body.android-app-shell .mini-card {
  padding: 12px;
}

body.android-app-shell .profile-card h2 {
  font-size: 20px;
}

body.android-app-shell .profile-card p,
body.android-app-shell .mini-card-copy,
body.android-app-shell .mini-card-value {
  font-size: 13px;
}

body.android-app-shell .topbar {
  top: 0 !important;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 8px 8px !important;
  gap: 6px !important;
  border-radius: 0 0 12px 12px !important;
}

body.android-app-shell .brand {
  gap: 8px !important;
  min-width: 0;
  flex: 0 1 auto;
}

body.android-app-shell .brand-avatar {
  width: 30px !important;
  height: 30px !important;
  flex: 0 0 30px !important;
  border-radius: 10px !important;
}

body.android-app-shell .brand h1 {
  font-size: 16px !important;
  line-height: 1.05 !important;
}

body.android-app-shell .brand .eyebrow {
  font-size: 9px !important;
}

body.android-app-shell .tabs {
  gap: 4px !important;
  padding: 4px !important;
  min-width: 0;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x !important;
  justify-content: flex-start !important;
  scrollbar-width: none !important;
}

body.android-app-shell .tab {
  min-height: 36px !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

body.android-app-shell .tabs::-webkit-scrollbar {
  display: none !important;
}

body.android-app-shell .threads-toggle-btn,
body.android-app-shell .gpu-top-btn {
  min-height: 36px !important;
  min-width: 68px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
  border-radius: 14px !important;
}

body.android-app-shell .messages {
  padding-top: 8px !important;
}

body.android-app-shell .message-avatar {
  width: 50px !important;
  height: 50px !important;
  flex: 0 0 50px !important;
}

body.android-app-shell .message-body {
  max-width: calc(100% - 64px) !important;
}

/* Final mobile shell authority */
[hidden] {
  display: none !important;
}

body.android-app-shell,
body.riko-phone-ui {
  overflow: hidden;
  background: #0b1020;
}

body.android-app-shell .shell,
body.riko-phone-ui .shell {
  width: 100vw !important;
  max-width: none !important;
  min-height: 100dvh !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  background: linear-gradient(180deg, #0b1020 0%, #0b1020 100%) !important;
}

body.android-app-shell .tabs,
body.android-app-shell .header-actions,
body.android-app-shell .hub-drawer,
body.android-app-shell .threads-panel,
body.android-app-shell .threads-toggle-btn,
body.android-app-shell .gpu-top-btn,
body.riko-phone-ui .tabs,
body.riko-phone-ui .header-actions,
body.riko-phone-ui .hub-drawer,
body.riko-phone-ui .threads-panel,
body.riko-phone-ui .threads-toggle-btn,
body.riko-phone-ui .gpu-top-btn {
  display: none !important;
}

body.android-app-shell .topbar,
body.riko-phone-ui .topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  margin: 0 !important;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px !important;
  border-radius: 0 !important;
  background: rgba(11, 16, 32, 0.98) !important;
  border-bottom: 1px solid rgba(126, 145, 255, 0.12);
}

body.android-app-shell .brand,
body.riko-phone-ui .brand {
  min-width: 0;
  gap: 10px !important;
}

body.android-app-shell .brand-avatar,
body.riko-phone-ui .brand-avatar {
  width: 54px !important;
  height: 54px !important;
  flex: 0 0 54px !important;
  border-radius: 18px !important;
}

body.android-app-shell .brand h1,
body.riko-phone-ui .brand h1 {
  font-size: 18px !important;
  line-height: 1.05 !important;
}

body.android-app-shell .brand .eyebrow,
body.riko-phone-ui .brand .eyebrow {
  font-size: 11px !important;
}

body.android-app-shell .nav-drawer-toggle,
body.riko-phone-ui .nav-drawer-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 18px;
}

body.android-app-shell .character-switcher,
body.riko-phone-ui .character-switcher {
  display: flex !important;
  min-width: 108px !important;
  max-width: 126px !important;
  margin-left: auto;
}

body.android-app-shell .character-switcher span,
body.riko-phone-ui .character-switcher span {
  display: none !important;
}

body.android-app-shell .character-switcher select,
body.riko-phone-ui .character-switcher select {
  min-height: 48px;
  border-radius: 18px;
  font-size: 13px;
  padding: 0 10px;
}

body.android-app-shell .main,
body.riko-phone-ui .main {
  min-height: 0 !important;
  height: calc(100dvh - 86px - env(safe-area-inset-top, 0px)) !important;
  overflow: hidden !important;
  padding: 0 !important;
}

body.android-app-shell .tab-panel,
body.riko-phone-ui .tab-panel {
  height: 100%;
  padding: 0 !important;
  overflow: hidden !important;
}

body.android-app-shell .chat-layout,
body.riko-phone-ui .chat-layout {
  display: block !important;
  height: 100% !important;
  padding: 0 !important;
}

body.android-app-shell .chat-column,
body.riko-phone-ui .chat-column {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  height: 100% !important;
  padding: 0 !important;
}

body.android-app-shell .messages,
body.riko-phone-ui .messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 14px 12px 170px !important;
  scroll-padding-bottom: 150px;
}

body.android-app-shell .message-avatar,
body.riko-phone-ui .message-avatar {
  width: 58px !important;
  height: 58px !important;
  flex: 0 0 58px !important;
}

body.android-app-shell .message-body,
body.riko-phone-ui .message-body {
  max-width: calc(100% - 72px) !important;
}

body.android-app-shell .composer-shell,
body.riko-phone-ui .composer-shell {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 22 !important;
  margin-top: auto !important;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  background: linear-gradient(180deg, rgba(11, 16, 32, 0) 0%, rgba(11, 16, 32, 0.94) 18%, rgba(11, 16, 32, 0.98) 100%) !important;
}

body.android-app-shell .composer,
body.riko-phone-ui .composer {
  border-radius: 22px !important;
  padding: 10px !important;
  gap: 10px !important;
  min-height: 78px !important;
}

body.android-app-shell .composer-input-wrap,
body.riko-phone-ui .composer-input-wrap {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

body.android-app-shell .composer textarea,
body.riko-phone-ui .composer textarea {
  font-size: 16px !important;
  line-height: 1.45 !important;
  min-height: 28px !important;
  padding-right: 38px !important;
}

body.android-app-shell .composer-image-btn,
body.android-app-shell .send-btn,
body.riko-phone-ui .composer-image-btn,
body.riko-phone-ui .send-btn {
  min-height: 50px !important;
  min-width: 88px !important;
  font-size: 15px !important;
}

body.android-app-shell .nav-drawer,
body.riko-phone-ui .nav-drawer {
  display: block !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  z-index: 60 !important;
  width: min(84vw, 360px) !important;
  max-width: 360px !important;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  background: rgba(7, 11, 20, 0.98) !important;
  transform: translateX(-110%) !important;
  transition: transform 180ms ease !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

body.android-app-shell .nav-drawer.is-open,
body.riko-phone-ui .nav-drawer.is-open {
  transform: translateX(0) !important;
}

body.android-app-shell .nav-drawer-backdrop,
body.riko-phone-ui .nav-drawer-backdrop {
  display: none !important;
  position: fixed !important;
  inset: 0 !important;
  z-index: 55 !important;
  background: rgba(3, 7, 14, 0.55) !important;
}

body.android-app-shell .nav-drawer-backdrop.is-open:not([hidden]),
body.riko-phone-ui .nav-drawer-backdrop.is-open:not([hidden]) {
  display: block !important;
}

body.android-app-shell .nav-drawer-backdrop[hidden],
body.riko-phone-ui .nav-drawer-backdrop[hidden] {
  display: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

body.android-app-shell .nav-drawer-section,
body.riko-phone-ui .nav-drawer-section {
  margin-top: 16px;
  padding-top: 16px;
}

body.android-app-shell .nav-drawer-link,
body.android-app-shell .nav-drawer-mini-btn,
body.riko-phone-ui .nav-drawer-link,
body.riko-phone-ui .nav-drawer-mini-btn {
  min-height: 52px !important;
  font-size: 15px !important;
}

body.android-app-shell .nav-profile-card .profile-card-avatar,
body.riko-phone-ui .nav-profile-card .profile-card-avatar {
  width: 58px !important;
  height: 58px !important;
  flex: 0 0 58px !important;
  border-radius: 18px !important;
}

body.android-app-shell .nav-status-strip,
body.riko-phone-ui .nav-status-strip {
  gap: 8px !important;
}

body.android-app-shell .nav-mini-card,
body.riko-phone-ui .nav-mini-card {
  padding: 14px !important;
}

body.android-app-shell .usage-card,
body.riko-phone-ui .usage-card {
  padding: 14px !important;
}

body.android-app-shell .usage-card-row,
body.riko-phone-ui .usage-card-row {
  font-size: 0.95rem !important;
}

body.android-app-shell .auth-overlay.is-hidden,
body.riko-phone-ui .auth-overlay.is-hidden {
  display: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

body.android-app-shell .auth-overlay,
body.riko-phone-ui .auth-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 90 !important;
  display: grid;
  place-items: center;
  padding: 18px !important;
  background: rgba(7, 11, 20, 0.74) !important;
}

body.android-app-shell .nav-status-strip,
body.riko-phone-ui .nav-status-strip {
  display: none !important;
}

body.android-app-shell .auth-card,
body.riko-phone-ui .auth-card {
  width: min(100%, 420px) !important;
  max-height: calc(100dvh - 36px) !important;
  overflow-y: auto !important;
}

body.android-app-shell .vault-shell,
body.riko-phone-ui .vault-shell {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  height: 100% !important;
  padding: 12px !important;
  overflow: hidden !important;
}

body.android-app-shell .vault-sidebar,
body.riko-phone-ui .vault-sidebar,
body.android-app-shell .vault-main,
body.riko-phone-ui .vault-main {
  min-height: 0 !important;
  overflow: hidden !important;
}

body.android-app-shell .vault-main,
body.riko-phone-ui .vault-main {
  display: flex !important;
  flex-direction: column !important;
}

body.android-app-shell .vault-albums,
body.riko-phone-ui .vault-albums {
  max-height: 180px !important;
  overflow-y: auto !important;
}

body.android-app-shell .vault-grid,
body.riko-phone-ui .vault-grid {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
}

/* ============================================================
   FINAL ANDROID / PHONE SHELL OVERRIDE
   Keep the app simple: top brand + menu, scrollable drawer,
   chat/galleries below, no old status drawer or desktop tabs.
   ============================================================ */
body.android-app-shell .tabs,
body.android-app-shell .header-actions,
body.android-app-shell .hub-drawer,
body.android-app-shell .status-strip,
body.android-app-shell .status-strip-inline,
body.riko-phone-ui .tabs,
body.riko-phone-ui .header-actions,
body.riko-phone-ui .hub-drawer,
body.riko-phone-ui .status-strip,
body.riko-phone-ui .status-strip-inline {
  display: none !important;
}

body.android-app-shell .shell,
body.riko-phone-ui .shell {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100dvh !important;
  height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

body.android-app-shell .topbar,
body.riko-phone-ui .topbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 30 !important;
  flex: 0 0 auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin: 0 !important;
  padding: calc(10px + var(--safe-top)) 14px 12px !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  border-top: 0 !important;
  box-shadow: none !important;
  background: rgba(8, 12, 21, 0.98) !important;
}

body.android-app-shell .brand,
body.riko-phone-ui .brand {
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

body.android-app-shell .main,
body.riko-phone-ui .main {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

body.android-app-shell .panel,
body.android-app-shell .tab-panel.is-active,
body.riko-phone-ui .panel,
body.riko-phone-ui .tab-panel.is-active {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
}

body.android-app-shell .chat-layout,
body.android-app-shell .chat-column,
body.riko-phone-ui .chat-layout,
body.riko-phone-ui .chat-column {
  height: 100% !important;
  min-height: 0 !important;
  padding: 0 !important;
}

body.android-app-shell .messages,
body.riko-phone-ui .messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y pinch-zoom !important;
  padding: 12px 12px 220px !important;
}

body.android-app-shell .message-avatar,
body.riko-phone-ui .message-avatar {
  width: 70px !important;
  height: 70px !important;
  flex: 0 0 70px !important;
  border-radius: 18px !important;
}

body.android-app-shell .message-body,
body.riko-phone-ui .message-body {
  max-width: calc(100% - 84px) !important;
}

body.android-app-shell .message-row.user .message-body,
body.riko-phone-ui .message-row.user .message-body {
  max-width: 92% !important;
}

body.android-app-shell .composer-shell,
body.riko-phone-ui .composer-shell {
  flex: 0 0 auto !important;
  position: relative !important;
  bottom: auto !important;
  margin-top: 0 !important;
  padding: 8px 10px calc(10px + var(--safe-bottom)) !important;
  background: rgba(8, 12, 21, 0.98) !important;
}

body.android-app-shell .composer,
body.riko-phone-ui .composer {
  margin: 0 !important;
}

body.android-app-shell .composer-input-wrap,
body.riko-phone-ui .composer-input-wrap {
  position: relative !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

body.android-app-shell .composer-input-wrap textarea,
body.riko-phone-ui .composer-input-wrap textarea {
  width: 100% !important;
  padding-right: 38px !important;
}

body.android-app-shell .composer-attach-btn,
body.riko-phone-ui .composer-attach-btn {
  position: absolute !important;
  right: 4px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border-radius: 12px !important;
  font-size: 14px !important;
  z-index: 2 !important;
}

body.android-app-shell .nav-drawer,
body.riko-phone-ui .nav-drawer {
  display: block !important;
  width: min(86vw, 380px) !important;
  max-width: 380px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

body.android-app-shell .nav-drawer-backdrop,
body.riko-phone-ui .nav-drawer-backdrop {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.android-app-shell .nav-drawer-backdrop.is-open:not([hidden]),
body.riko-phone-ui .nav-drawer-backdrop.is-open:not([hidden]) {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.android-app-shell .vault-shell,
body.riko-phone-ui .vault-shell {
  display: block !important;
  gap: 12px !important;
  height: auto !important;
  min-height: 100% !important;
  padding: 12px !important;
  overflow: visible !important;
  padding-bottom: calc(132px + var(--safe-bottom)) !important;
}

body.android-app-shell .vault-sidebar,
body.riko-phone-ui .vault-sidebar,
body.riko-phone-ui .vault-main {
  min-height: 0 !important;
  height: auto !important;
  overflow: visible !important;
}

body.android-app-shell .vault-sidebar,
body.riko-phone-ui .vault-sidebar {
  flex: 0 0 auto !important;
  max-height: none !important;
  overflow: visible !important;
}

body.android-app-shell .vault-main,
body.riko-phone-ui .vault-main {
  flex: 0 0 auto !important;
  min-height: 0 !important;
  display: block !important;
  overflow: visible !important;
}

body.android-app-shell .vault-grid,
body.riko-phone-ui .vault-grid {
  flex: 0 0 auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  max-height: none !important;
  padding-bottom: calc(132px + var(--safe-bottom)) !important;
}

body.android-app-shell .tab-panel[data-panel="vault"].is-active,
body.android-app-shell .tab-panel[data-panel="gallery"].is-active,
body.android-app-shell .tab-panel[data-panel="vrm"].is-active,
body.riko-phone-ui .tab-panel[data-panel="vault"].is-active,
body.riko-phone-ui .tab-panel[data-panel="gallery"].is-active,
body.riko-phone-ui .tab-panel[data-panel="vrm"].is-active {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
}

body.android-app-shell .gallery-grid,
body.riko-phone-ui .gallery-grid {
  padding-bottom: calc(132px + var(--safe-bottom)) !important;
}

body.android-app-shell .vrm-live-log,
body.riko-phone-ui .vrm-live-log {
  margin-left: 14px !important;
  margin-right: 14px !important;
  max-height: 28dvh !important;
}

body.android-app-shell #vrm-frame,
body.riko-phone-ui #vrm-frame {
  min-height: 70dvh !important;
}

body.android-app-shell .tab-panel[data-panel="vrm"].is-active,
body.riko-phone-ui .tab-panel[data-panel="vrm"].is-active {
  overflow: hidden !important;
}

body.android-app-shell .tab-panel[data-panel="vrm"] .vrm-header,
body.riko-phone-ui .tab-panel[data-panel="vrm"] .vrm-header {
  padding: 8px 10px !important;
}

body.android-app-shell .tab-panel[data-panel="vrm"] .vrm-frame-wrap,
body.riko-phone-ui .tab-panel[data-panel="vrm"] .vrm-frame-wrap {
  height: calc(100% - 54px) !important;
  padding: 0 !important;
}

body.android-app-shell #vrm-frame,
body.riko-phone-ui #vrm-frame {
  display: block !important;
  width: 100% !important;
  min-height: 0 !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 0 !important;
}

body.android-app-shell .tab-panel[data-panel="vrm"].is-active,
body.riko-phone-ui .tab-panel[data-panel="vrm"].is-active {
  height: 100% !important;
  padding: 0 !important;
}

body.android-app-shell .tab-panel[data-panel="vrm"] .vrm-header,
body.riko-phone-ui .tab-panel[data-panel="vrm"] .vrm-header {
  display: none !important;
}

body.android-app-shell .tab-panel[data-panel="vrm"] .vrm-frame-wrap,
body.riko-phone-ui .tab-panel[data-panel="vrm"] .vrm-frame-wrap {
  height: 100% !important;
  min-height: 0 !important;
  border-radius: 0 !important;
}
