﻿:root {
  --app-vh: 100vh;

  /* Design tokens (UI-only; should not affect logic) */
  --c-bg: #f8fafc;          /* slate-50 */
  --c-surface: #ffffff;
  --c-border: #e5e7eb;      /* gray-200 */
  --c-text: #111827;        /* gray-900 */
  --c-muted: #6b7280;       /* gray-500 */
  --c-muted2: #9ca3af;      /* gray-400 */
  --c-primary: #2563eb;     /* blue-600 */
  --c-primary-2: #1d4ed8;   /* blue-700 */
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-1: 0 1px 0 rgba(17,24,39,0.05), 0 10px 30px rgba(17,24,39,0.08);
}
html, body {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}
/* 隐藏滚动条但保留滚动功能 */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.app-shell {
  height: var(--app-vh);
  display: flex;
  flex-direction: column;
}
.app-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.layout {
  flex: 1 1 auto;
  min-height: 0;
}
.left-pane,
.right-pane {
  height: 100%;
}
.left-pane {
  display: flex;
  flex-direction: column;
}
.right-pane {
  height: 100%;
}
.panel-grow {
  flex: 1 1 auto;
  min-height: 0;
}
.message-enter { animation: slideIn 0.24s cubic-bezier(.2,.8,.2,1); }
@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #9ca3af;
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
 .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
 @keyframes bounce {
   0%, 80%, 100% { transform: translateY(0); }
   40% { transform: translateY(-8px); }
 }
 .message-content pre {
   background: #f3f4f6;
   border: 1px solid #e5e7eb;
   border-radius: 10px;
   padding: 12px;
   margin: 10px 0;
   overflow-x: auto;
   font-size: 13px;
 }

 /* iOS-ish message bubble styling (UI-only) */
 .ios-bubble {
   border-radius: 20px;
   min-width: 0;
   box-shadow: 0 1px 0 rgba(17,24,39,0.05), 0 10px 24px rgba(17,24,39,0.06);
 }
 .ios-bubble--incoming {
   background: #ffffff;
   border: 1px solid var(--c-border);
   color: var(--c-text);
 }
 .ios-bubble--outgoing {
   background: var(--c-primary);
   border: 1px solid rgba(37, 99, 235, 0.35);
   color: #ffffff;
 }

 input[type="checkbox"] { accent-color: var(--c-primary); }

 /* Reduce motion for accessibility */
 @media (prefers-reduced-motion: reduce) {
   *, *::before, *::after {
     animation-duration: 0.01ms !important;
     animation-iteration-count: 1 !important;
     transition-duration: 0.01ms !important;
     scroll-behavior: auto !important;
   }
 }

 /* Subtle iOS-like press feedback (UI-only) */
 :where(button, a).pressable:active { transform: scale(0.98); }

 /* Accessible focus ring (UI-only) */
 :where(button, a, input, textarea, select):focus-visible {
   outline: 2px solid rgba(37, 99, 235, 0.55);
   outline-offset: 2px;
   border-radius: 12px;
 }
 .message-content code {
   font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
 }
 .message-content .inline-code {
   background: #e5e7eb;
   padding: 2px 6px;
   border-radius: 4px;
   font-size: 13px;
 }
 .message-content {
   line-height: 2.2;
   overflow-wrap: anywhere;
   word-break: break-word;
 }
 .message-content p {
   margin: 8px 0;
   overflow-wrap: anywhere;
   word-break: break-word;
 }
 .message-content ul, .message-content ol {
   margin: 8px 0;
   padding-left: 20px;
 }
  .message-content a {
    color: var(--c-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
    word-break: break-all;
  }
  .ios-bubble--outgoing .message-content a { color: rgba(255,255,255,0.92); }

  .message-content blockquote {
    border-left: 3px solid #d1d5db;
    padding-left: 12px;
    margin: 10px 0;
    color: #6b7280;
  }
  .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
  }
  .message-content th, .message-content td {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
    text-align: left;
  }
  .message-content th {
    background: #f3f4f6;
    font-weight: 600;
  }
  .message-content tr:nth-child(even) {
    background: #f9fafb;
  }
  .message-content tr:hover {
    background: #f3f4f6;
  }
  .message-image {
    max-width: min(260px, 72vw);
    max-height: 260px;
    border-radius: 10px;
    margin: 8px 0;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #fff;
  }
  .message-image:hover {
    border-color: #2563eb;
  }
  .image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn 0.2s ease;
  }
  .image-lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 4px 40px rgba(0,0,0,0.5);
    object-fit: contain;
  }
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  .image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #d1d5db;
    background: #fff;
  }
  .image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(239, 68, 68, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
  }
  .image-preview-item .remove-btn:hover {
    background: rgb(239, 68, 68);
  }

  /* Mobile Bottom Sheet behavior for the right pane */
  @media (max-width: 1023px) {
    #rightPane.mobile-open {
      display: block;
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      top: 12vh;
      z-index: 20;
      border-top-left-radius: 20px;
      border-top-right-radius: 20px;
      overflow: hidden;
      overflow-y: auto;
      background: rgb(255, 255, 255); /* white */
      box-shadow: 0 -10px 30px rgba(0,0,0,.20);
    }
    #rightPane.mobile-open > div[data-panel] {
      border-radius: 0 !important;
    }
  }
