    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

    :root {
      --bg-primary: #081c15;
      --bg-secondary: #102a23;
      --bg-tertiary: #1b4332;
      --surface: rgba(138, 203, 136, 0.07);
      --surface-hover: rgba(138, 203, 136, 0.12);
      --border: rgba(138, 203, 136, 0.2);
      --text-primary: #e8f5e9;
      --text-secondary: rgba(232, 245, 233, 0.75);
      --text-muted: rgba(232, 245, 233, 0.55);
      --accent: #2a9d8f;
      --accent-hover: #3bc4b3;
      --user-bubble: linear-gradient(135deg, #2a9d8f 0%, #5e8c61 100%);
      --ai-bubble: rgba(42, 157, 143, 0.1);
      --reasoning-bg: rgba(42, 157, 143, 0.1);
      --reasoning-border: rgba(42, 157, 143, 0.3);
      --success: #10b981;
      --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
      --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
      --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: var(--bg-primary);
      color: var(--text-primary);
      line-height: 1.6;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    a,
    a:link,
    a:visited,
    a:hover,
    a:active {
      color: inherit;
      text-decoration: none;
    }

    @keyframes animate-particles {
      0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
        border-radius: 0;
      }

      100% {
        transform: translateY(-1000px) rotate(720deg);
        opacity: 0;
        border-radius: 50%;
      }
    }

    .background-particles {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      margin: 0;
      padding: 0;
      z-index: 0;
    }

    .background-particles li {
      position: absolute;
      display: block;
      list-style: none;
      width: 20px;
      height: 20px;
      background: rgba(138, 203, 136, 0.15);
      animation: animate-particles 25s linear infinite;
      bottom: -150px;
    }

    .background-particles li:nth-child(1) {
      left: 25%;
      width: 80px;
      height: 80px;
      animation-delay: 0s;
    }

    .background-particles li:nth-child(2) {
      left: 10%;
      width: 20px;
      height: 20px;
      animation-delay: 2s;
      animation-duration: 12s;
    }

    .background-particles li:nth-child(3) {
      left: 70%;
      width: 20px;
      height: 20px;
      animation-delay: 4s;
    }

    .background-particles li:nth-child(4) {
      left: 40%;
      width: 60px;
      height: 60px;
      animation-delay: 0s;
      animation-duration: 18s;
    }

    .background-particles li:nth-child(5) {
      left: 65%;
      width: 20px;
      height: 20px;
      animation-delay: 0s;
    }

    .background-particles li:nth-child(6) {
      left: 75%;
      width: 110px;
      height: 110px;
      animation-delay: 3s;
      background: rgba(255, 255, 255, 0.1);
    }

    .background-particles li:nth-child(7) {
      left: 35%;
      width: 150px;
      height: 150px;
      animation-delay: 7s;
    }

    .background-particles li:nth-child(8) {
      left: 50%;
      width: 25px;
      height: 25px;
      animation-delay: 15s;
      animation-duration: 45s;
    }

    .background-particles li:nth-child(9) {
      left: 20%;
      width: 15px;
      height: 15px;
      animation-delay: 2s;
      animation-duration: 35s;
      background: rgba(255, 255, 255, 0.15);
    }

    .background-particles li:nth-child(10) {
      left: 85%;
      width: 150px;
      height: 150px;
      animation-delay: 0s;
      animation-duration: 11s;
    }

    .header {
      padding: 3rem 1.5rem;
      background: rgba(16, 42, 35, 0.85);
      transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      flex-direction: column;
      align-items: center;
      position: sticky;
      top: 0;
      z-index: 100;
      transition: all 1.5s ease;
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      overflow: hidden;
      -webkit-mask-image: linear-gradient(to bottom, black 95%, transparent 100%);
      mask-image: linear-gradient(to bottom, black 95%, transparent 100%);
    }

    .header.collapsed {
      padding-top: 0;
      padding-bottom: 0;
      max-height: 0;
      border-bottom-width: 0;
      opacity: 0;
      transform: translateY(-20%);
    }

    .header-content,
    .upload-area {
      position: relative;
      z-index: 1;
      width: 100%;
      max-width: 900px;
    }

    .header-content {
      max-width: 900px;
      margin: 0 auto;
      padding: 0 1.5rem;
    }

    .header h1 {
      font-size: 1.5rem;
      font-weight: 600;
      margin-bottom: 1rem;
      background: linear-gradient(135deg, var(--accent), var(--accent-hover));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .upload-area {
      position: relative;
      background: var(--surface);
      border: 2px dashed var(--border);
      border-radius: 12px;
      padding: 1.5rem;
      text-align: center;
      transition: all 0.3s ease;
      cursor: pointer;
    }

    .upload-area:hover {
      background: var(--surface-hover);
      border-color: var(--accent);
      transform: translateY(-1px);
    }

    .upload-area.dragover {
      background: rgba(42, 157, 143, 0.1);
      border-color: var(--accent);
      transform: scale(1.02);
    }

    .upload-icon {
      width: 48px;
      height: 48px;
      margin: 0 auto 1rem;
      background: var(--accent);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.5rem;
    }

    .upload-text {
      font-size: 1rem;
      font-weight: 500;
      margin-bottom: 0.5rem;
    }

    .upload-hint {
      font-size: 0.875rem;
      color: var(--text-muted);
    }

    #jsonUpload {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      cursor: pointer;
    }

    .main-content {
      flex: 1;
      max-width: 900px;
      margin: 0 auto;
      padding: 2rem 1.5rem;
      width: 100%;
    }

    .empty-state {
      text-align: center;
      padding: 4rem 2rem;
      color: var(--text-muted);
    }

    .chat-container {
      display: flex;
      flex-direction: column;
      gap: 1.5rem;
    }

    .date-divider {
      display: flex;
      align-items: center;
      margin: 2rem 0 1rem;
    }

    .date-divider::before,
    .date-divider::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }

    .date-label {
      padding: 0.5rem 1rem;
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: 20px;
      font-size: 0.75rem;
      font-weight: 500;
      color: var(--text-secondary);
      margin: 0 1rem;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .message {
      display: flex;
      gap: 1rem;
      align-items: flex-start;
      animation: slideIn 0.3s ease-out;
    }

    .message.user {
      flex-direction: row-reverse;
      justify-content: flex-start;
    }

    @keyframes slideIn {
      from {
        opacity: 0;
        transform: translateY(10px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .avatar {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 600;
      font-size: 0.875rem;
      position: relative;
      overflow: hidden;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      background-color: transparent;
    }

    .avatar.user {
      background: var(--user-bubble);
      color: white;
    }

    .avatar.ai {
      background-color: var(--surface);
      border: 1px solid var(--border);
      color: var(--accent);
    }

    .avatar::before {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
      transform: translateX(-100%);
      transition: transform 0.6s;
    }

    .message:hover .avatar::before {
      transform: translateX(100%);
    }

    .content-wrapper {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      max-width: calc(100% - 60px);
    }

    .content-wrapper.user {
      align-items: flex-end;
    }

    .message-header {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      margin-bottom: 0.5rem;
      font-size: 0.75rem;
      color: var(--text-muted);
    }

    .message.user .message-header {
      justify-content: flex-end;
    }

    .sender-name {
      font-weight: 500;
      color: var(--text-secondary);
      cursor: pointer;
      position: relative;
      user-select: none;
      transition: color 0.2s ease;
    }

    .sender-name:hover {
      color: var(--accent);
    }

    .message.user .sender-name:hover::after {
      left: auto;
      right: 0;
      transform: translateX(0);
    }

    .sender-name:hover::before {
      content: '';
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
      border: 4px solid transparent;
      border-top-color: var(--border);
      z-index: 1000;
      margin-bottom: 0.1rem;
      pointer-events: none;
    }

    .message.user .sender-name:hover::before {
      left: auto;
      right: 1rem;
      transform: translateX(0);
    }

    @keyframes tooltipFadeIn {
      from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
      }

      to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
      }
    }

    .timestamp {
      font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    }

    .bubble {
      position: relative;
      padding: 1rem 1.25rem;
      border-radius: 16px;
      font-size: 0.95rem;
      line-height: 1.5;
      word-wrap: break-word;
      backdrop-filter: blur(10px);
      transition: all 0.2s ease;
      display: inline-block;
      width: fit-content;
      max-width: 80%;
    }

    .bubble.user {
      background: var(--user-bubble);
      color: white;
      border-bottom-right-radius: 4px;
      box-shadow: var(--shadow-md);
    }

    .bubble.ai {
      background: var(--ai-bubble);
      border: 1px solid var(--border);
      border-bottom-left-radius: 4px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }

    .bubble.ai::before {
      content: '';
      position: absolute;
      top: 0;
      left: -100%;
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
      transition: left 0.5s;
    }

    .bubble.ai:hover::before {
      left: 100%;
    }

    .bubble.ai:hover {
      background: var(--surface-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-lg);
    }

    .reasoning {
      margin-top: 0.75rem;
      padding: 1rem;
      background: var(--reasoning-bg);
      border: 1px solid var(--reasoning-border);
      border-radius: 12px;
      font-size: 0.875rem;
      line-height: 1.6;
      color: var(--text-secondary);
      white-space: pre-wrap;
      opacity: 0;
      max-height: 0;
      overflow: hidden;
      transition: all 0.3s ease;
      backdrop-filter: blur(10px);
    }

    .reasoning.show {
      opacity: 1;
      max-height: 500px;
      overflow-y: auto;
    }

    .reasoning::-webkit-scrollbar {
      width: 4px;
    }

    .reasoning::-webkit-scrollbar-track {
      background: transparent;
    }

    .reasoning::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 2px;
    }

    .click-hint {
      position: absolute;
      top: 0.5rem;
      right: 0.75rem;
      font-size: 0.625rem;
      background: rgba(0, 0, 0, 0.3);
      color: var(--text-muted);
      padding: 0.25rem 0.5rem;
      border-radius: 8px;
      opacity: 0;
      transition: opacity 0.2s;
      pointer-events: none;
    }

    .bubble.ai:hover .click-hint {
      opacity: 1;
    }

    .stats {
      display: flex;
      justify-content: center;
      gap: 2rem;
      padding: 1.5rem;
      background: var(--surface);
      border-radius: 12px;
      margin-top: 2rem;
      font-size: 0.875rem;
    }

    .stat-item {
      text-align: center;
    }

    .stat-value {
      display: block;
      font-size: 1.5rem;
      font-weight: 600;
      color: var(--accent);
    }

    .stat-label {
      color: var(--text-muted);
    }

    @media (max-width: 768px) {

      .header-content,
      .main-content {
        padding-left: 1rem;
        padding-right: 1rem;
      }

      .content-wrapper {
        max-width: calc(100% - 50px);
      }

      .bubble {
        max-width: 85vw;
      }

      .message {
        gap: 0.75rem;
      }

      .avatar {
        width: 36px;
        height: 36px;
        font-size: 0.75rem;
      }

      .sender-name:hover::after {
        max-width: 150px;
      }
    }

    .loading {
      display: none;
      text-align: center;
      padding: 2rem;
      color: var(--text-muted);
    }

    .loading.show {
      display: block;
    }

    .spinner {
      width: 32px;
      height: 32px;
      border: 3px solid var(--border);
      border-top: 3px solid var(--accent);
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin: 0 auto 1rem;
    }

    @keyframes spin {
      0% {
        transform: rotate(0deg);
      }

      100% {
        transform: rotate(360deg);
      }
    }

    .action-buttons-container {
      display: flex;
      flex-direction: column;
      gap: 1rem;
      max-width: 400px;
      margin: 1rem auto 0;
    }

    .action-button {
      position: relative;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 1rem;
      text-align: center;
      transition: all 0.3s ease;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 1rem;
      color: var(--text-primary);
      font-family: inherit;
      font-size: 1rem;
      width: fit-content;
      margin-left: auto;
      margin-right: auto;
    }

    .action-button:hover {
      background: var(--surface-hover);
      border-color: var(--accent);
      transform: translateY(-2px);
    }

    .action-button.dragover {
      background: rgba(42, 157, 143, 0.1);
      border-color: var(--accent);
      transform: scale(1.02);
    }

    .action-button input[type="file"] {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      cursor: pointer;
    }

    .upload-icon {
      width: 44px;
      height: 44px;
      flex-shrink: 0;
      background: linear-gradient(135deg, var(--accent), var(--accent-hover));
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.3rem;
      color: var(--text-primary);
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
      transition: transform 0.2s ease;
    }

    .action-button:hover .upload-icon {
      transform: scale(1.1);
    }

    .button-text-content {
      flex-grow: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
    }

    .upload-text {
      font-size: 0.95rem;
      font-weight: 500;
      margin-bottom: 0.25rem;
    }

    .upload-hint {
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .qr-scanner-modal {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(8px);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      flex-direction: column;
      gap: 1.5rem;
    }

    #qrVideo {
      width: 100%;
      max-width: 600px;
      height: auto;
      border-radius: 12px;
      box-shadow: var(--shadow-xl);
      border: 1px solid var(--border);
    }

    .scanner-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
    }

    .scanner-overlay::before {
      content: '';
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 60%;
      padding-top: 60%;
      max-width: 400px;
      max-height: 400px;
      box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
      border-radius: 24px;
    }

    .scanner-overlay::after {
      content: '';
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 60%;
      height: 2px;
      max-width: 400px;
      background: linear-gradient(90deg, transparent, var(--accent), transparent);
      border-radius: 2px;
      animation: scan-line 2.5s infinite ease-in-out;
    }

    @keyframes scan-line {
      0% {
        top: 20%;
      }

      50% {
        top: 80%;
      }

      100% {
        top: 20%;
      }
    }

    #closeScanner {
      width: auto;
      max-width: none;
      padding: 0.75rem 2rem;
      pointer-events: auto;
      background: var(--bg-tertiary);
    }

    .scanner-controls {
      display: flex;
      gap: 1rem;
      position: relative;
      z-index: 10;
      align-items: center;
    }

    @media (max-width: 768px) {
      :root {
        --shadow-lg: 0 8px 12px -3px rgba(0, 0, 0, 0.1), 0 3px 5px -2px rgba(0, 0, 0, 0.05);
        --shadow-xl: 0 15px 20px -5px rgba(0, 0, 0, 0.1), 0 8px 8px -5px rgba(0, 0, 0, 0.04);
      }

      body {
        font-size: 15px;
      }

      .header {
        padding: 1.5rem 1rem;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
      }

      .header-content {
        padding: 0 1rem;
      }

      .header h1 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
      }

      .upload-area {
        padding: 1rem;
      }

      .upload-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
      }

      .upload-text {
        font-size: 0.95rem;
      }

      .upload-hint {
        font-size: 0.8rem;
      }

      .main-content {
        padding: 1.5rem 1rem;
      }

      .empty-state {
        padding: 3rem 1rem;
      }

      .chat-container {
        gap: 1.25rem;
      }

      .date-divider {
        margin: 1.5rem 0 0.75rem;
      }

      .date-label {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
        margin: 0 0.5rem;
      }

      .message {
        gap: 0.75rem;
      }

      .avatar {
        width: 36px;
        height: 36px;
      }

      .content-wrapper {
        max-width: calc(100% - 36px - 0.75rem);
      }

      .message-bubble {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
      }

      .message-header {
        gap: 0.5rem;
        font-size: 0.7rem;
      }

      .reasoning-toggle {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
      }

      .reasoning-content {
        padding: 0.75rem;
      }

      .image-grid {
        gap: 0.5rem;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      }

      #scrollToBottomBtn {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
      }

      .context-menu {
        min-width: 180px;
      }
    }

    @media (max-width: 480px) {
      body {
        font-size: 14px;
      }

      .header,
      .main-content {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
      }

      .header-content {
        padding: 0 0.5rem;
      }

      .message-bubble {
        border-radius: 16px;
      }

      .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
      }

      #image-viewer-modal .modal-content {
        padding: 10px;
      }

      #image-viewer-modal #image-viewer-caption {
        font-size: 0.8rem;
        padding: 8px;
      }
    }

    /* Page Footer */
    .page-footer {
      padding: 0.5rem 0.5rem;
      text-align: center;
      color: var(--text-muted);
      font-size: 0.875rem;
      margin-top: auto;
    }

    .page-footer .credits {
      font-size: 0.75rem;
      opacity: 0.7;
      margin-top: 0.5rem;
    }