*, *::before, *::after { box-sizing: border-box; }
    html { background: transparent; -webkit-tap-highlight-color: transparent; }
    body {
      margin: 0;
      font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      font-size: 16px;
      line-height: 1.5;
      color: #0f172a;
      background: transparent;
      min-height: 100vh;
      min-height: 100dvh;
      display: flex;
      flex-direction: column;
    }
    .chat-header {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 20;
      flex-shrink: 0;
      padding: 10px 12px;
      background: rgba(255, 255, 255, 0.92);
      backdrop-filter: blur(10px);
      border-bottom: 1px solid #e5e7eb;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      min-height: 56px;
    }
    .chat-logo-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      position: static;
      left: auto;
    }
    .chat-logo-link img {
      width: 34px;
      height: 34px;
      object-fit: contain;
      display: block;
    }
    .chat-header-right {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      min-width: 0;
      flex: 1;
    }
    .chat-model-btn {
      position: static;
      right: auto;
      top: auto;
      transform: none;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      max-width: min(46vw, 180px);
      padding: 7px 10px;
      border: 1px solid #e2e8f0;
      border-radius: 999px;
      background: #fff;
      color: #0f172a;
      font-size: 12px;
      font-weight: 600;
      font-family: inherit;
      cursor: pointer;
      white-space: nowrap;
      overflow: hidden;
    }
    .chat-model-btn i.fa-cubes { color: #7c5cfc; font-size: 12px; flex-shrink: 0; }
    .chat-model-caret { font-size: 10px; color: #94a3b8; flex-shrink: 0; }
    .chat-model-btn span {
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .chat-model-btn:hover { background: #f8fafc; border-color: #c7d2fe; }

    .talk-ai-btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
      padding: 7px 12px;
      border: 1px solid #c7d2fe;
      border-radius: 999px;
      background: linear-gradient(135deg, #7c5cfc 0%, #5b7cfa 100%);
      color: #fff;
      font-size: 11px;
      font-weight: 700;
      font-family: inherit;
      cursor: pointer;
      white-space: nowrap;
      box-shadow: 0 6px 16px rgba(124, 92, 252, 0.28);
    }
    .talk-ai-btn i { font-size: 12px; }
    .talk-ai-btn:hover { filter: brightness(1.05); }
    .talk-ai-btn.is-open {
      background: #fff;
      color: #4f46e5;
      border-color: #a5b4fc;
      box-shadow: none;
    }

    .talk-panel {
      position: fixed;
      top: 56px;
      left: 0;
      right: 0;
      z-index: 19;
      background: rgba(255, 255, 255, 0.98);
      border-bottom: 1px solid #e5e7eb;
      box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
      max-height: min(62vh, 460px);
      overflow-y: auto;
    }
    .talk-panel[hidden] { display: none !important; }
    .talk-panel-inner {
      position: relative;
      max-width: 520px;
      margin: 0 auto;
      padding: 14px 16px 18px;
    }
    .talk-panel-close {
      position: absolute;
      top: 10px;
      right: 10px;
      z-index: 2;
      width: 32px;
      height: 32px;
      border: none;
      border-radius: 50%;
      background: rgba(15, 23, 42, 0.55);
      color: #fff;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .talk-panel-close:hover { background: rgba(15, 23, 42, 0.75); }
    .talk-panel-img {
      width: 100%;
      height: auto;
      max-height: 280px;
      object-fit: contain;
      border-radius: 16px;
      display: block;
      background: #0b0b0f;
    }
    .talk-panel-caption {
      margin: 10px 0 12px;
      font-size: 13px;
      font-weight: 600;
      color: #334155;
      text-align: center;
    }
    .talk-panel-stores {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      flex-wrap: wrap;
    }
    .talk-panel-stores .store-badge-link img,
    .talk-panel-stores .store-badge-locked img {
      height: 40px;
      width: auto;
      display: block;
    }
    .talk-panel-stores .store-badge-link {
      display: inline-block;
      line-height: 0;
      transition: transform 0.15s ease, opacity 0.15s ease;
    }
    .talk-panel-stores .store-badge-link:hover {
      transform: translateY(-1px);
      opacity: 0.92;
    }
    .talk-panel-stores .store-badge-locked {
      position: relative;
      display: inline-block;
      line-height: 0;
      cursor: not-allowed;
    }
    .talk-panel-stores .store-badge-locked img {
      filter: grayscale(0.35);
      opacity: 0.7;
    }
    .talk-panel-stores .store-badge-lock-overlay {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      background: rgba(15, 23, 42, 0.45);
      border-radius: 8px;
      color: #fff;
      font-size: 11px;
      font-weight: 700;
    }
    .messages-wrap {
      flex: 1;
      overflow-y: auto;
      padding: 16px 20px;
      padding-top: 72px;
      padding-bottom: 180px;
    }
    body.talk-panel-open .messages-wrap {
      padding-top: 340px;
    }

    @media (max-width: 420px) {
      .talk-ai-btn { padding: 7px 10px; font-size: 10px; }
      .chat-model-btn { max-width: min(38vw, 140px); }
    }
    .messages-wrap > .message:first-child {
      margin-top: 8px;
    }
    .message {
      display: flex;
      flex-direction: column;
      margin-bottom: 16px;
      max-width: 85%;
    }
    @media (min-width: 480px) {
      .message { max-width: 360px; }
    }
    .message.user { margin-left: auto; margin-right: 0; }
    .message.assistant { margin-left: 0; margin-right: auto; }
    .message-bubble {
      padding: 12px 16px;
      border-radius: 18px;
      font-size: 15px;
      line-height: 1.55;
      word-wrap: break-word;
      max-width: 100%;
      overflow-x: auto;
      overflow-y: visible;
      -webkit-overflow-scrolling: touch;
    }
    .message.user .message-bubble {
      background: #ffffff;
      border: 1px solid rgba(148,163,184,0.45);
      color: #0f172a;
      border-top-right-radius: 4px;
    }
    .message.assistant .message-bubble {
      background: linear-gradient(135deg, #4a90e2 0%, #7c5cfc 55%, #b066fe 100%);
      border: 1px solid rgba(255,255,255,0.15);
      color: #fff;
      border-top-left-radius: 4px;
      box-shadow: 0 8px 24px rgba(124, 92, 252, 0.28);
    }
    .message-bubble .image-container {
      min-height: 80px;
      margin-top: 10px;
      margin-bottom: 4px;
    }
    .message-bubble .message-img,
    .message-bubble img {
      max-width: 100%;
      width: auto;
      height: auto;
      min-height: 60px;
      max-height: 260px;
      border-radius: 12px;
      margin-top: 8px;
      margin-bottom: 4px;
      display: block;
      object-fit: contain;
      vertical-align: middle;
    }
    .message-bubble .message-img:first-child,
    .message-bubble img:first-child { margin-top: 0; }
    .message-bubble .attached-images {
      margin-top: 10px;
      padding: 8px 0;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      min-height: 80px;
    }
    .message-bubble .attached-images img {
      width: 120px;
      height: 120px;
      object-fit: cover;
      margin: 0;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.15);
      display: block;
    }
    .message.assistant .output-images {
      width: 100%;
      margin-bottom: 12px;
      display: flex;
      flex-wrap: nowrap;
      gap: 12px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      padding-bottom: 4px;
    }
    .message.assistant .output-images img {
      width: 200px;
      min-width: 200px;
      height: 160px;
      object-fit: cover;
      border-radius: 20px;
      border: 1px solid rgba(255,255,255,0.2);
      display: block;
      cursor: pointer;
      flex-shrink: 0;
    }
    .message.assistant .output-images img:hover { opacity: 0.9; }
    .message.assistant .message-bubble p { margin: 0.5em 0; }
    .message.assistant .message-bubble p:first-child { margin-top: 0; }
    .message.assistant .message-bubble p:last-child { margin-bottom: 0; }
    .message.assistant .message-bubble h1, .message.assistant .message-bubble h2, .message.assistant .message-bubble h3,
    .message.assistant .message-bubble h4 { margin: 0.75em 0 0.35em; font-size: 1em; font-weight: 600; line-height: 1.3; }
    .message.assistant .message-bubble h1:first-child, .message.assistant .message-bubble h2:first-child,
    .message.assistant .message-bubble h3:first-child, .message.assistant .message-bubble h4:first-child { margin-top: 0; }
    .message.assistant .message-bubble ul, .message.assistant .message-bubble ol {
      margin: 0.5em 0; padding-left: 1.4em; line-height: 1.5;
    }
    .message.assistant .message-bubble li { margin: 0.25em 0; }
    .message.assistant .message-bubble strong { font-weight: 600; }
    .message.assistant .message-bubble em { font-style: italic; }
    .message.assistant .message-bubble a { color: rgba(255,255,255,0.95); text-decoration: underline; }
    .message.assistant .message-bubble code {
      background: rgba(0,0,0,0.25); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; font-family: ui-monospace, monospace;
    }
    .message.assistant .message-bubble pre {
      background: rgba(0,0,0,0.25); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 0.6em 0; font-size: 0.9em;
    }
    .message.assistant .message-bubble pre code { background: none; padding: 0; }
    .message.assistant .message-bubble blockquote {
      border-left: 3px solid rgba(255,255,255,0.5); margin: 0.5em 0; padding-left: 12px; opacity: 0.95;
    }
    .message.assistant .message-bubble hr { border: none; border-top: 1px solid rgba(255,255,255,0.3); margin: 0.8em 0; }
    .message.assistant .message-bubble .table-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      margin: 0.5em 0;
      max-width: 100%;
    }
    .message.assistant .message-bubble table { border-collapse: collapse; margin: 0; font-size: 0.9em; min-width: 200px; }
    .message.assistant .message-bubble th, .message.assistant .message-bubble td { border: 1px solid rgba(255,255,255,0.3); padding: 6px 8px; text-align: left; }
    .typing-dots {
      display: inline-flex;
      gap: 4px;
      padding: 4px 0;
    }
    .typing-dots span {
      width: 6px;
      height: 6px;
      background: rgba(99,102,241,0.7);
      border-radius: 50%;
      animation: typing 1.4s ease-in-out infinite both;
    }
    .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
    .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes typing { 0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }
    .input-bar-wrap {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 10;
      padding: 12px 14px;
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
      background: transparent;
    }
    .input-bar {
      max-width: 720px;
      margin: 0 auto;
      background: rgba(255,255,255,0.9);
      border: 1px solid rgba(148,163,184,0.4);
      border-radius: 22px;
      padding: 6px 12px 6px 14px;
      display: flex;
      flex-direction: column;
      gap: 2px;
      box-shadow: 0 8px 24px rgba(14,165,233,0.08);
    }
    .input-attach-wrap {
      display: flex;
      flex-direction: column;
      min-width: 0;
    }
    .input-images {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 4px;
    }
    .input-images img {
      width: 48px;
      height: 48px;
      object-fit: cover;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.1);
    }
    .input-images .img-remove {
      position: absolute;
      top: -6px;
      right: -6px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #374151;
      color: #fff;
      border: none;
      cursor: pointer;
      font-size: 12px;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
    }
    .input-images .img-wrap { position: relative; }
    .input-text-row {
      position: relative;
      min-height: 36px;
      display: flex;
      align-items: center;
    }
    .input-text-row .placeholder {
      position: absolute;
      left: 6px;
      color: #94a3b8;
      font-size: 16px;
      pointer-events: none;
      opacity: 0.9;
    }
    .input-field {
      width: 100%;
      min-height: 36px;
      padding: 8px 6px;
      background: transparent;
      border: none;
      color: #0f172a;
      font-size: 16px;
      font-family: inherit;
      resize: none;
      outline: none;
      line-height: 1.4;
    }
    .input-field::placeholder { color: #9CA3AF; }
    .input-icon-row {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-wrap: nowrap;
    }
    .input-icon-row .spacer { flex: 1; min-width: 8px; }
    .input-btn {
      width: 40px;
      height: 40px;
      border: none;
      border-radius: 50%;
      background: transparent;
      color: #0f172a;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.2s, color 0.2s;
      flex-shrink: 0;
    }
    .input-btn:hover { background: rgba(99,102,241,0.1); color: #0f172a; }
    .input-btn.attach { color: #64748b; }
    .input-btn.models {
      color: #64748b;
      width: auto;
      min-width: 40px;
      padding: 0 10px;
      border-radius: 999px;
      border: 1px solid #e2e8f0;
      background: #fff;
      font-size: 12px;
      font-weight: 600;
      gap: 6px;
    }
    .input-btn.models:hover { color: #4f46e5; border-color: #c7d2fe; background: #eef2ff; }
    .input-btn.mic {
      background: linear-gradient(135deg, #7c5cfc 0%, #5b7cfa 100%);
      color: #fff;
    }
    .input-btn.mic.listening {
      background: #EF4444;
      color: #fff;
    }
    .input-btn.send {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: linear-gradient(135deg, #7c5cfc 0%, #5b7cfa 100%);
      color: #fff;
      border: 1px solid rgba(255,255,255,0.2);
      box-shadow: 0 6px 18px rgba(124, 92, 252, 0.35);
    }
    .input-btn.send:hover:not(:disabled) { filter: brightness(1.05); }
    .input-btn.send:disabled { opacity: 0.5; cursor: not-allowed; }
    .input-btn i { font-size: 18px; }
    .input-btn.send i { font-size: 16px; }
    .error-msg { color: #F87171; font-size: 14px; margin-top: 8px; padding: 0 4px; max-width: 720px; margin-left: auto; margin-right: auto; }
