:root { --bg: #ffffff; --surface: #f4f4f5; --border: #e4e4e7; --text: #18181b; --text-muted: #71717a; --primary: #3b82f6; --primary-hover: #2563eb; --radius: 8px; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
.app { display: flex; flex-direction: column; max-width: 1350px; margin: 0 auto; width: 100%; min-height: 100vh; }
.header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.header h1 { margin: 0; font-size: 1.25rem; }
.header-actions { display: flex; gap: 8px; }
.main { flex: 1; overflow: auto; display: flex; flex-direction: column; padding: 16px; }
.messages { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.export-actions { display: flex; gap: 8px; justify-content: center; padding: 16px 0; border-top: 1px solid var(--border); margin-top: 16px; }

.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: #fff; border-radius: 8px; max-width: 500px; width: 90%; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1.2rem; }
.btn-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; padding: 0; line-height: 1; }
.btn-close:hover { color: #333; }
.modal-body { padding: 20px; line-height: 1.6; }
.modal-body p { margin: 0 0 12px 0; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: var(--radius); word-break: break-word; position: relative; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.msg-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; }
.msg.user .msg-meta { color: rgba(255,255,255,0.8); }
.msg-content { line-height: 1.5; white-space: pre-wrap; padding-bottom: 28px; }
.msg-duration { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.msg.user .msg-duration { color: rgba(255,255,255,0.7); border-top-color: rgba(255,255,255,0.2); }
.msg-copy-btn { position: absolute; bottom: 4px; right: 4px; padding: 2px; border-radius: 4px; border: none; background: transparent; color: inherit; cursor: pointer; z-index: 100; display: flex; align-items: center; justify-content: center; opacity: 0.7; transition: opacity 0.2s; width: 20px; height: 20px; }
.msg-copy-btn:hover { opacity: 1; }
.msg.user .msg-copy-btn { color: rgba(255,255,255,0.8); }
.msg.user .msg-copy-btn:hover { color: #fff; }

.btn-icon { display: flex; align-items: center; justify-content: center; padding: 8px 10px; }
.msg-content a { color: inherit; text-decoration: underline; }
.msg.user .msg-content a { color: #fff; }
.code-block-wrap { position: relative; margin: 8px 0; border-radius: var(--radius); overflow: hidden; background: #f4f4f5; border: 1px solid var(--border); }
.code-block-wrap pre { margin: 0; padding: 12px 16px; overflow-x: auto; font-size: 0.875rem; }
.btn-copy { position: absolute; top: 8px; right: 8px; padding: 4px 8px; font-size: 0.75rem; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.img-block { margin: 8px 0; }
.img-block img { max-width: 100%; max-height: 400px; display: block; border-radius: var(--radius); }
.msg-image { margin-bottom: 8px; }
.msg-image img { max-width: 100%; max-height: 300px; display: block; border-radius: var(--radius); object-fit: contain; }
.mermaid-wrap { margin: 12px 0; padding: 12px; background: #fff; border-radius: var(--radius); overflow-x: auto; }
.footer { flex-shrink: 0; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.image-preview-wrap { padding: 8px 0; }
.image-preview { position: relative; display: inline-block; }
.image-preview img { max-width: 100px; max-height: 80px; border-radius: var(--radius); border: 1px solid var(--border); object-fit: cover; }
.image-preview .btn-icon { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; padding: 0; line-height: 1; border-radius: 50%; background: #ef4444; color: #fff; border: none; }
.input-wrap { display: flex; flex-direction: column; gap: 8px; }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 1rem; resize: none; font-family: inherit; }
.input:focus { outline: none; border-color: var(--primary); }
.input-actions { display: flex; align-items: center; justify-content: space-between; }
.input-actions-left { display: flex; gap: 4px; }
.btn { padding: 8px 14px; border-radius: var(--radius); font-size: 0.875rem; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-icon { padding: 8px 10px; }
.btn-icon.recording { background: #ef4444; color: #fff; border-color: #ef4444; animation: pulse 1s infinite; }
.button-group { display: flex; gap: 4px; }
.btn-stop { padding: 8px 10px; background: #ef4444; color: #fff; border-color: #ef4444; display: none; }
.btn-stop.visible { display: inline-flex; }
.btn-stop:hover { background: #dc2626; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.status { text-align: center; padding: 8px; font-size: 0.875rem; color: var(--text-muted); }
.status.error { color: #f87171; }
@media (max-width: 640px) { .header { padding: 10px 12px; } .msg { max-width: 92%; } .footer { padding: 10px 12px; } }

@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { 
    background: #fff !important; 
    margin: 0 !important; 
    padding: 20px !important;
    display: block !important;
  }
  .app { 
    display: block !important; 
    max-width: 100% !important; 
    min-height: auto !important; 
    margin: 0 !important;
  }
  .header { 
    display: block !important; 
    border-bottom: 1px solid #e4e4e7 !important; 
    padding: 0 0 12px 0 !important; 
    margin: 0 0 20px 0 !important;
  }
  .header h1 { margin: 0 !important; font-size: 1.25rem !important; }
  .main { 
    display: block !important; 
    overflow: visible !important; 
    flex: none !important;
    padding: 0 !important;
  }
  .messages { 
    display: flex !important; 
    flex-direction: column !important;
    gap: 16px !important;
  }
  .msg { 
    page-break-inside: avoid !important;
    max-width: 85% !important;
  }
  .msg.user { 
    align-self: flex-end !important;
    background: var(--primary) !important; 
    color: #fff !important;
  }
  .msg.assistant { 
    align-self: flex-start !important;
    background: var(--surface) !important; 
    border: 1px solid var(--border) !important;
  }
  .msg-content { 
    padding-bottom: 28px !important;
    line-height: 1.5 !important;
    white-space: pre-wrap !important;
  }
  .msg-meta { 
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
  }
  .msg.user .msg-meta { 
    color: rgba(255,255,255,0.8) !important;
  }
  .msg-duration { 
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
    margin-top: 8px !important;
    padding-top: 8px !important;
    border-top: 1px dashed var(--border) !important;
  }
  .msg.user .msg-duration { 
    color: rgba(255,255,255,0.7) !important;
    border-top-color: rgba(255,255,255,0.2) !important;
  }
  .footer, .export-actions, .msg-copy-btn, .btn-copy, .status { 
    display: none !important; 
  }
}
