body.portal-home {
  --ai-accent: var(--mobile-orange, var(--home-portfolio-accent, #f18f01));
  --ai-accent-line: rgba(241, 143, 1, .38);
  --ai-ink: var(--mobile-text, var(--home-portfolio-ink, #252525));
  --ai-muted: var(--mobile-muted, var(--home-portfolio-muted, #707070));
  --ai-line: var(--mobile-line, var(--home-portfolio-line, rgba(89, 73, 55, .22)));
}
.portal-home .portal-hero { position: relative; }
.home-ai-trigger {
  position: absolute; left: 26px; top: 24px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 54px; min-height: 36px; padding: 6px 16px; border: 1px solid var(--ai-accent-line);
  border-radius: 12px; background: #fff7eb; color: var(--ai-accent); cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: 15px; line-height: 1.2; letter-spacing: .04em;
}
.home-ai-trigger:hover { background: #ffedcf; }
.home-ai-dialog {
  width: min(880px, calc(100vw - 28px)); height: min(800px, calc(100dvh - 36px));
  max-width: none; max-height: none; padding: 0; border: 1px solid var(--ai-line);
  border-radius: 22px; background: #f5f4f1; color: var(--ai-ink);
  box-shadow: 0 24px 100px #423b3240; overflow: hidden;
}
.home-ai-dialog::backdrop { background: #29251f80; backdrop-filter: blur(3px); }
.home-ai-shell { display: flex; flex-direction: column; height: 100%; }
.home-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px; background: white; border-bottom: 1px solid var(--ai-line); }
.home-ai-head h2 { margin: 0; font-size: 21px; }
.home-ai-head p { margin: 5px 0 0; color: var(--ai-muted); font-size: 13px; }
.home-ai-head-actions { display: flex; gap: 6px; }
.home-ai-dialog button { cursor: pointer; font-family: inherit; }
.home-ai-dialog button:disabled { cursor: default; opacity: .5; }
.home-ai-small { padding: 8px 10px; border: 1px solid var(--ai-line); border-radius: 9px; background: white; color: var(--ai-ink); font-size: 12px; white-space: nowrap; }
.home-ai-close { min-width: 36px; font-size: 20px; }
.home-ai-primary { border: 0; border-radius: 10px; padding: 12px 18px; background: var(--ai-accent); color: white; font-size: 14px; font-weight: 700; }
.home-ai-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.home-ai-content[hidden], .home-ai-progress[hidden], .home-ai-dialog [hidden] { display: none !important; }
.home-ai-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px; }
.home-ai-message { margin: 0 0 20px; min-width: 0; }
.home-ai-message-label { margin: 0 0 6px; font-size: 11px; font-weight: 700; color: var(--ai-muted); }
.home-ai-message.is-user { margin-left: 12%; }
.home-ai-message.is-user .home-ai-message-label { text-align: right; }
.home-ai-message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; font-size: 14px; background: white; border: 1px solid var(--ai-line); border-radius: 14px; padding: 14px 16px; }
.home-ai-message.is-user .home-ai-message-body { background: #fff4e4; border-color: var(--ai-accent-line); }
.home-ai-message.is-error .home-ai-message-body { color: #9c3434; background: #fff5f5; }
.home-ai-result { margin-top: 10px; background: white; border: 1px solid var(--ai-line); border-radius: 12px; overflow: hidden; }
.home-ai-result summary { cursor: pointer; padding: 12px 14px; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.home-ai-table-wrap { overflow-x: auto; max-height: 320px; overflow-y: auto; }
.home-ai-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.home-ai-table th, .home-ai-table td { padding: 9px 12px; border-bottom: 1px solid #efeeeb; text-align: left; }
.home-ai-table th { position: sticky; top: 0; background: #f4f1ec; z-index: 1; }
.home-ai-result-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; font-size: 12px; color: var(--ai-muted); }
.home-ai-download { display: inline-block; padding: 8px 12px; background: #fff7eb; border: 1px solid var(--ai-accent-line); border-radius: 8px; color: var(--ai-accent); text-decoration: none; font-weight: 700; font-size: 12px; }
.home-ai-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.home-ai-progress { display: flex; align-items: center; gap: 9px; padding: 10px 22px; font-size: 12px; color: var(--ai-muted); }
.home-ai-spinner { width: 13px; height: 13px; border: 2px solid #efdfc6; border-top-color: var(--ai-accent); border-radius: 50%; animation: homeAiSpin .8s linear infinite; flex: 0 0 auto; }
.home-ai-elapsed { margin-left: auto; color: var(--ai-muted); white-space: nowrap; }
.home-ai-compose { display: flex; gap: 9px; padding: 14px 20px max(14px, env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--ai-line); }
.home-ai-compose textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 120px; padding: 11px 12px; box-sizing: border-box; border: 1px solid var(--ai-line); border-radius: 11px; font-family: inherit; font-size: 16px; line-height: 1.45; }
.home-ai-compose .home-ai-primary { align-self: flex-end; min-height: 44px; white-space: nowrap; }
@keyframes homeAiSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .home-ai-spinner { animation: none; } }
@media (max-width: 600px) {
  .home-ai-trigger { left: 16px; top: 16px; min-width: 44px; min-height: 32px; padding: 5px 12px; }
  .home-ai-dialog { margin: 0; width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .home-ai-head { padding: 16px; }
  .home-ai-head h2 { font-size: 18px; }
  .home-ai-head p { font-size: 12px; }
  .home-ai-messages { padding: 16px; }
  .home-ai-compose { padding-left: 12px; padding-right: 12px; }
  .home-ai-progress { padding-left: 16px; padding-right: 16px; }
  .home-ai-message-body { padding: 12px; }
}

.home-ai-dialog button:focus-visible, .home-ai-dialog a:focus-visible,
.home-ai-trigger:focus-visible, .home-ai-dialog textarea:focus-visible, .home-ai-dialog input:focus-visible {
  outline: 2px solid var(--ai-accent); outline-offset: 2px;
}
.home-ai-dialog .home-ai-microphone {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 42px;
  align-self: flex-end; width: 42px; height: 44px; padding: 0;
  border: 1px solid var(--ai-accent-line); border-radius: 10px;
  background: #fff7eb; color: var(--ai-accent);
}
.home-ai-dialog .home-ai-microphone.is-listening { background: var(--ai-accent); color: white; }
.home-ai-voice-status { margin: 0; padding: 8px 20px; color: var(--ai-muted); font-size: 12px; }
.home-ai-attachment-bar { padding: 10px 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--ai-line); }
.home-ai-attachment-hint { color: var(--ai-muted); font-size: 12px; }
#homeAiAttachments { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; width: 100%; }
.home-ai-attachment { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 8px; border: 1px solid var(--ai-line); border-radius: 8px; font-size: 12px; }
.home-ai-attachment > span { overflow-wrap: anywhere; min-width: 0; }
.home-ai-attachment button { flex-shrink: 0; border: 0; background: transparent; font-size: 18px; cursor: pointer; }
.home-ai-share-file { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; width: 100%; }
.home-ai-share-file code { display: block; width: 100%; overflow-wrap: anywhere; user-select: all; font-size: 12px; }
.mobile-app-body .mobile-app-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mobile-app-body .mobile-app-title { font-size: clamp(20px, 6.9vw, 38px); }
.mobile-app-body .home-ai-trigger { position: static; flex: 0 0 auto; min-width: 44px; min-height: 34px; padding: 6px 12px; font-size: 13px; }
@media (max-width: 600px) {
  .home-ai-compose { gap: 6px; }
  .home-ai-compose .home-ai-primary { padding-inline: 12px; }
}
