:root {
  --bg: #f5f5f7;
  --bg-secondary: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: #d2d2d7;
  --input-bg: #ffffff;
  --input-border: #c7c7cc;
  --input-focus-border: #0071e3;
  --bubble-user-bg: #0071e3;
  --bubble-user-text: #ffffff;
  --bubble-ai-bg: #ffffff;
  --bubble-ai-text: #1d1d1f;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.18);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --overlay-bg: rgba(0,0,0,0.5);
  --thinking-bg: #f9f9fb;
  --thinking-border: #e5e5ea;
  --tag-bg: #f0f0f5;
  --tag-text: #636366;
  --tag-active-bg: #e8f0fe;
  --tag-active-text: #0071e3;
  --tag-active-border: #0071e3;
  --send-btn-bg: #1d1d1f;
  --send-btn-text: #ffffff;
  --send-btn-hover: #333336;
  --scrollbar-thumb: #c1c1c6;
  --scrollbar-track: transparent;
  --modal-bg: #ffffff;
  --modal-text: #1d1d1f;
  --divider: #e5e5ea;
  --link-color: #0071e3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --border: #3a3a3c;
    --input-bg: #2c2c2e;
    --input-border: #48484a;
    --input-focus-border: #4da6ff;
    --bubble-user-bg: #4da6ff;
    --bubble-user-text: #ffffff;
    --bubble-ai-bg: #2c2c2e;
    --bubble-ai-text: #f5f5f7;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
    --accent: #4da6ff;
    --accent-hover: #5eb0ff;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --overlay-bg: rgba(0,0,0,0.7);
    --thinking-bg: #252527;
    --thinking-border: #3a3a3c;
    --tag-bg: #3a3a3c;
    --tag-text: #a1a1a6;
    --tag-active-bg: #1a3a5c;
    --tag-active-text: #4da6ff;
    --tag-active-border: #4da6ff;
    --send-btn-bg: #f5f5f7;
    --send-btn-text: #1c1c1e;
    --send-btn-hover: #e5e5ea;
    --scrollbar-thumb: #48484a;
    --scrollbar-track: transparent;
    --modal-bg: #2c2c2e;
    --modal-text: #f5f5f7;
    --divider: #3a3a3c;
    --link-color: #4da6ff;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 20px;
  min-height: 52px;
  flex-shrink: 0;
  z-index: 10;
}
.translate-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.25s ease;
  white-space: nowrap;
  letter-spacing: 0.3px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.translate-btn:hover {
  background: var(--tag-bg);
  border-color: var(--text-tertiary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.translate-btn:active { transform: scale(0.96); }
.translate-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.35s ease;
}
.translate-icon { font-size: 16px; line-height: 1; }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.welcome-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  transition: all 0.45s cubic-bezier(0.4,0,0.2,1);
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.welcome-section.faded {
  opacity: 0;
  pointer-events: none;
  flex: 0 0 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transform: translateY(-20px);
}

.ai-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
  margin-bottom: 20px;
  border: none;
  outline: none;
  background: transparent;
}

.welcome-text {
  text-align: center;
  transition: all 0.4s ease;
}
.welcome-line1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.welcome-line2 {
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 4px;
  white-space: nowrap;
}

.chat-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: none;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.chat-section.active {
  display: flex;
  opacity: 1;
}
.chat-section::-webkit-scrollbar { width: 5px; }
.chat-section::-webkit-scrollbar-track { background: var(--scrollbar-track); }
.chat-section::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: messageIn 0.3s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
@keyframes messageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.user { align-self: flex-end; }
.message.ai { align-self: flex-start; }

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.2px;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
}
.message.user .bubble {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 6px;
}
.message.ai .bubble {
  background: var(--bubble-ai-bg);
  color: var(--bubble-ai-text);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
}

.thinking-block {
  margin-bottom: 10px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--thinking-border);
  background: var(--thinking-bg);
}
.thinking-block summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  transition: background 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary::marker { display: none; }
.thinking-block summary:hover { background: var(--tag-bg); }
.arrow-icon {
  display: inline-block;
  transition: transform 0.3s;
  font-size: 10px;
  color: var(--text-tertiary);
}
.thinking-block[open] .arrow-icon { transform: rotate(90deg); }
.thinking-icon-sm { font-size: 15px; }
.thinking-content {
  padding: 0 14px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  border-top: 1px solid var(--thinking-border);
  margin-top: 4px;
  padding-top: 10px;
  white-space: pre-wrap;
  font-style: italic;
  opacity: 0.85;
  min-height: 1em;
}

.bottom-section {
  flex-shrink: 0;
  padding: 8px 20px 12px;
  background: var(--bg);
  border-top: 1px solid transparent;
  transition: border-color 0.4s;
  z-index: 5;
}
.bottom-section.has-chat { border-top-color: var(--border); }

.input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.textarea-wrapper { width: 100%; }
.chat-input {
  width: 100%;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s;
  outline: none;
  letter-spacing: 0.2px;
}
.chat-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}
@media (prefers-color-scheme: dark) {
  .chat-input:focus { box-shadow: 0 0 0 3px rgba(77,166,255,0.2); }
}
.chat-input::placeholder { color: var(--text-tertiary); opacity: 0.7; }

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.deep-think-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid transparent;
  background: var(--tag-bg);
  color: var(--tag-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.25s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.2px;
}
.deep-think-btn:hover {
  background: var(--tag-active-bg);
  color: var(--tag-active-text);
}
.deep-think-btn.active {
  background: var(--tag-active-bg);
  color: var(--tag-active-text);
  border-color: var(--tag-active-border);
  font-weight: 600;
}
.deep-think-icon { font-size: 16px; line-height: 1; }

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--send-btn-bg);
  color: var(--send-btn-text);
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  transition: all 0.25s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.send-btn:hover { background: var(--send-btn-hover); transform: scale(1.05); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.4; pointer-events: none; }
.send-arrow { line-height: 1; }

.footer-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.2px;
  text-align: center;
}
.footer-info a {
  color: var(--link-color);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 1px solid transparent;
}
.footer-info a:hover { border-bottom-color: var(--link-color); opacity: 0.85; }
.footer-separator { color: var(--text-tertiary); opacity: 0.5; user-select: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlayIn 0.35s;
}
.modal-overlay.hidden { display: none; }
@keyframes overlayIn { from { opacity: 0; backdrop-filter: blur(0); } to { opacity: 1; backdrop-filter: blur(8px); } }
.modal-dialog {
  background: var(--modal-bg);
  border-radius: 20px;
  padding: 28px 26px 22px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.4s cubic-bezier(0.22,0.61,0.36,1);
  border: 1px solid var(--border);
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(30px) scale(0.94); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.2px; color: var(--text-primary); }
.modal-body { font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; max-height: 40vh; overflow-y: auto; margin-bottom: 20px; padding-right: 4px; }
.modal-body p { margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  flex: 1; min-width: 120px; padding: 11px 18px; border-radius: 22px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; letter-spacing: 0.2px; transition: all 0.25s; text-align: center;
}
.btn-accept { background: var(--accent); color: #fff; }
.btn-accept:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,113,227,0.35); }
.btn-reject { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-reject:hover { background: var(--danger); color: #fff; }

@media (max-width: 600px) {
  .top-bar { padding: 10px 14px; min-height: 44px; }
  .translate-btn { padding: 7px 11px; font-size: 12px; border-radius: 18px; }
  .welcome-line1 { font-size: 22px; }
  .welcome-line2 { font-size: 15px; }
  .ai-logo-img { width: 80px; height: 80px; margin-bottom: 16px; }
  .chat-section { padding: 12px 14px; }
  .bubble { padding: 10px 14px; font-size: 14px; }
  .bottom-section { padding: 6px 14px 10px; }
  .deep-think-btn { padding: 6px 12px; font-size: 12px; }
  .send-btn { width: 36px; height: 36px; font-size: 18px; }
  .footer-info { font-size: 10px; }
}

@media (max-width: 380px) {
  .welcome-line1 { font-size: 20px; }
  .welcome-line2 { font-size: 14px; }
  .ai-logo-img { width: 64px; height: 64px; }
}