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

:root {
  --primary: #4361ee;
  --primary-dark: #3a56d4;
  --secondary: #f72585;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  --light-gray: #e9ecef;
  --success: #4cc9f0;
  --border-radius: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s ease;
  --card-bg: white;
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.07);
  --subtle-bg: #f3f5f8;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1rem;
  transition: var(--transition);
}

/* 暗色模式样式 */
body.dark-mode {
  background: linear-gradient(135deg, #1a1e2c 0%, #0d1117 100%);
  color: #e1e6f0;
  --card-bg: #1e2535;
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
  --subtle-bg: #0d1117;
}

body.dark-mode .input-section {
  background: var(--card-bg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  color: #d0d7e8;
}

body.dark-mode textarea {
  background: #161b25;
  border-color: #2a3246;
  color: #d0d7e8;
}

body.dark-mode .stat-card {
  background: #161b25;
  border-color: #2a3246;
  color: #d0d7e8;
}

body.dark-mode .time-stats {
  background: #0a1a2f;
  border-left-color: #4cc9f0;
  color: #a8c7fa;
}

body.dark-mode .subtitle,
body.dark-mode .stat-label,
body.dark-mode .footer-links a {
  color: #a3aec9;
}

body.dark-mode .footer-links a:hover {
  color: #d0d7e8;
}

body.dark-mode .section-title {
  color: #8da2fb;
}

body.dark-mode .stat-value {
  color: #8da2fb;
}

body.dark-mode .btn-secondary {
  background: #161b25;
  color: #d0d7e8;
  border-color: #2a3246;
}

body.dark-mode .btn-secondary:hover {
  background: #1e2535;
}

body.dark-mode .detail-item {
  border-bottom-color: #2a3246;
}

body.dark-mode footer {
  border-top-color: #2a3246;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex: none;
  vertical-align: -0.125em;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.5rem;
  padding: 0.5rem 1rem;
  background: white;
  border-radius: 50px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

body.dark-mode .back-link {
  background: #1e2535;
  color: #8da2fb;
}

.back-link:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

body.dark-mode .back-link:hover {
  background: var(--primary);
  color: white;
}

.dark-mode-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #34495e;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 15px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s;
  z-index: 10;
}

body.dark-mode .dark-mode-toggle {
  background: #ecf0f1;
  color: #2c3e50;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.logo .icon {
  font-size: 2.8rem;
  color: var(--primary);
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.subtitle {
  color: var(--gray);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
  transition: var(--transition);
}

.main-visual-anchor {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
    gap: 1.25rem;
    align-items: stretch;
    margin: 2rem auto;
    padding: 1.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

body.dark-mode .main-visual-anchor {
    background: var(--card-bg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.anchor-primary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    padding: 0.25rem 0.25rem 0.25rem 0;
}

.anchor-eyebrow {
    color: var(--gray);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.main-visual-anchor .stat-value {
    font-size: 3.5rem; /* Largest font size */
    font-weight: 800; /* Boldest weight */
    color: var(--primary); /* Main brand color */
    line-height: 1; /* Adjust line height for large text */
    margin-bottom: 0.5rem;
}

body.dark-mode .main-visual-anchor .stat-value {
    color: #8da2fb; /* Dark mode equivalent of primary color */
}

.main-visual-anchor .stat-label {
    font-size: 1.2rem; /* Larger label */
    color: var(--gray);
}

.anchor-label {
    margin-bottom: 0;
}

.anchor-secondary-metrics {
    display: grid;
    gap: 0.85rem;
}

.anchor-metric {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem 1.1rem;
    border-radius: var(--border-radius);
    background: var(--subtle-bg);
    border: 1px solid var(--light-gray);
    min-height: 110px;
}

.anchor-metric-label {
    color: var(--gray);
    font-size: 0.92rem;
    margin-bottom: 0.4rem;
}

.anchor-metric-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.15;
}

body.dark-mode .main-visual-anchor .stat-label {
    color: #a3aec9;
}

body.dark-mode .anchor-eyebrow,
body.dark-mode .anchor-metric-label {
    color: #a3aec9;
}

body.dark-mode .anchor-metric {
    background: #161b25;
    border-color: #2a3246;
}

body.dark-mode .anchor-metric-value {
    color: #d0d7e8;
}

/* ===== 主容器布局改进 ===== */
/* 改进：从单列改为两列布局，提高空间利用率 */
.main-content {
  display: grid;
  grid-template-columns: 1fr;
  /* 两列布局 */
  gap: 2rem;
}



.input-section {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: var(--transition);
}

.result-panel {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.result-section {
  background: transparent; /* Remove background from parent result-section */
  border-radius: var(--border-radius);
  box-shadow: none; /* Remove shadow from parent result-section */
  padding: 0; /* Remove padding from parent result-section */
  transition: var(--transition);
}

.input-section:hover,
.result-section:hover {
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.12);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--light-gray);
  color: var(--primary);
  transition: var(--transition);
}

body.dark-mode .section-title {
  border-bottom-color: #2a3246;
}

.section-title .icon {
  font-size: 1.4rem;
}

.analysis-status {
  min-height: 1.4rem;
  margin: -0.5rem 0 1rem;
  font-size: 0.92rem;
  color: var(--gray);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.analysis-status.is-visible {
  opacity: 1;
}

.analysis-status.is-busy {
  color: var(--primary-dark);
}

.analysis-status.is-warning {
  color: #b26a00;
}

body.dark-mode .analysis-status {
  color: #a3aec9;
}

body.dark-mode .analysis-status.is-busy {
  color: #8da2fb;
}

body.dark-mode .analysis-status.is-warning {
  color: #f0d9a8;
}

textarea {
  width: 100%;
  height: 250px;
  padding: 1.25rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--border-radius);
  font-size: 1.05rem;
  resize: vertical;
  transition: var(--transition);
}

textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

body.dark-mode textarea:focus {
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.4);
}



.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--light);
  border-radius: var(--border-radius);
  padding: 1rem;
  text-align: center;
  transition: var(--transition);
  border: 1px solid var(--light-gray);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08);
}

body.dark-mode .stat-card:hover {
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.5rem 0;
  transition: var(--transition);
}

body.dark-mode .stat-value {
  color: #8da2fb;
}

.stat-label {

  font-size: 0.9rem;

  color: var(--gray);

  transition: var(--transition);

}



.detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.35rem 1rem;
}

.metric-explainer {
  padding: 0.9rem 1rem;
  border-radius: var(--border-radius);
  background: var(--subtle-bg);
  color: var(--gray);
  font-size: 0.92rem;
  line-height: 1.6;
}

.metric-explainer strong {
  color: var(--dark);
}



.time-stats {
  margin-top: 0.5rem;
  border-left: 4px solid var(--success);
  transition: var(--transition);
  padding: 1rem 0 1rem 1rem;
}



body.dark-mode .time-stats {

  border-left-color: #4cc9f0;

}



.time-stats h3 {

  color: var(--primary-dark);

  margin-bottom: 1rem;

  display: flex;

  align-items: center;

  gap: 8px;

  transition: var(--transition);

}



body.dark-mode .time-stats h3 {

  color: #8da2fb;

}

body.dark-mode .metric-explainer {
  background: #161b25;
  color: #a3aec9;
}

body.dark-mode .metric-explainer strong {
  color: #d0d7e8;
}



.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--light-gray);
  transition: var(--transition);
}

body.dark-mode .detail-item {
  border-bottom-color: #2a3246;
}

.detail-item:last-child {
  border-bottom: none;
}

.result-layers {
  display: grid;
  gap: 1rem;
}

.result-block {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--border-radius);
  padding: 1.15rem 1.2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.result-block-core {
  border-color: rgba(67, 97, 238, 0.18);
  box-shadow: 0 8px 24px rgba(67, 97, 238, 0.08);
}

.result-block-header {
  margin-bottom: 0.9rem;
}

.result-block-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin: 0 0 0.35rem;
}

.result-block-header p {
  color: var(--gray);
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.55;
}

body.dark-mode .result-block {
  background: #1e2535;
  border-color: #2a3246;
  box-shadow: none;
}

body.dark-mode .result-block-core {
  border-color: rgba(141, 162, 251, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

body.dark-mode .result-block-header h3 {
  color: #8da2fb;
}

body.dark-mode .result-block-header p {
  color: #a3aec9;
}



.btn-group {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--light);
  color: var(--dark);
  border: 1px solid var(--light-gray);
}

.btn-secondary:hover {
  background: var(--light-gray);
}

body.dark-mode .btn-secondary {
  background: #161b25;
  color: #d0d7e8;
  border-color: #2a3246;
}

body.dark-mode .btn-secondary:hover {
  background: #1e2535;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--light-gray);
}

footer {
  text-align: center;
  margin-top: 3rem;
  color: var(--gray);
  font-size: 0.9rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--light-gray);
  transition: var(--transition);
}

body.dark-mode footer {
  border-top-color: #2a3246;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  text-decoration: underline;
}

#customWpm {
  width: 60px;
  text-align: center;
  border-radius: 5px;
  border: 1px solid var(--light-gray);
  background-color: var(--light);
  color: var(--dark);
}

body.dark-mode #customWpm {
  background-color: #161b25;
  border-color: #2a3246;
  color: #d0d7e8;
}

/* 
 * 通知提示样式 - 支持三种类型
 * 配合 script.js 的 showNotification() 函数使用
 */

/* 通知容器基础样式 */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;

  /* 过渡动画：opacity 变化时平滑过渡 */
  transition: opacity 0.3s ease-in-out;

  /* 初始状态：隐藏 */
  opacity: 0;
  pointer-events: none;

  /* 显示内容 */
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 通知显示状态 */
.notification.show {
  opacity: 1;
  pointer-events: auto;
}

/* 
 * 成功类型通知 - 绿色
 * 用于：复制成功、操作完成等正面反馈
 */
.notification.success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  border-left: 4px solid #28a745;
  color: #155724;
}

/* 
 * 错误类型通知 - 红色
 * 用于：复制失败、操作出错等负面反馈
 */
.notification.error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  border-left: 4px solid #dc3545;
  color: #721c24;
}

/* 
 * 警告类型通知 - 黄色
 * 用于：需要权限授权、环境限制等警告信息
 */
.notification.warning {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  border-left: 4px solid #ffc107;
  color: #856404;
}

/* 暗色模式下的通知样式 */
body.dark-mode .notification.success {
  background-color: #1e4620;
  border-color: #2d6a2f;
  color: #a3e9a8;
}

body.dark-mode .notification.error {
  background-color: #522a2a;
  border-color: #6d3c3c;
  color: #f0a9a9;
}

body.dark-mode .notification.warning {
  background-color: #553d1f;
  border-color: #7a5a2e;
  color: #f0d9a8;
}

/* Input Area Controls */
.input-controls {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.mode-picker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

.mode-picker-label {
  color: var(--gray);
  font-size: 0.92rem;
  font-weight: 600;
}

.mode-picker-group {
  display: inline-flex;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--light-gray);
  background: var(--subtle-bg);
  gap: 0.25rem;
}

.mode-option {
  border: none;
  background: transparent;
  color: var(--gray);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.mode-option:hover {
  color: var(--dark);
}

.mode-option.is-active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.input-mode-hint {
  margin-bottom: 1rem;
  color: var(--gray);
  font-size: 0.92rem;
  line-height: 1.5;
}

body.dark-mode .mode-picker-label,
body.dark-mode .input-mode-hint {
    color: #a3aec9;
}

body.dark-mode .mode-picker-group {
    background: #161b25;
    border-color: #2a3246;
}

body.dark-mode .mode-option {
    color: #a3aec9;
}

body.dark-mode .mode-option:hover {
    color: #d0d7e8;
}

body.dark-mode .mode-option.is-active {
    background: #25304a;
    color: #8da2fb;
    box-shadow: none;
}


/* 
 * 响应式设计：平板设备（768px 以下改为单列）
 */
@media (max-width: 768px) {
  .main-visual-anchor {
    grid-template-columns: 1fr;
  }

  .anchor-primary {
    text-align: center;
    padding-right: 0;
  }

  .main-content {
    grid-template-columns: 1fr;
    /* 改回单列 */
  }

  .mode-picker-group {
    width: 100%;
  }

  .mode-option {
    flex: 1 1 0;
    text-align: center;
  }

  .notification {
    top: 10px;
    right: 10px;
    left: 10px;
    font-size: 13px;
    padding: 12px 16px;
  }
}

/* 
 * 响应式设计：超小屏幕（480px 以下）
 */
@media (max-width: 480px) {
  .notification {
    top: 5px;
    right: 5px;
    left: 5px;
    font-size: 12px;
    padding: 10px 14px;
  }
}

.legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Detailed stats number styling */
.detail-item span:last-child {
  margin-left: 8px; /* Buffer space */
  font-weight: 500; /* Bolder numbers */
}

/* Dynamic font sizes for large numbers */
.font-size-small {
  font-size: 0.9em !important;
}

.font-size-smaller {
  font-size: 0.8em !important;
}

/* 拖拽导入视觉反馈 */
.input-section {
    position: relative; /* 使其可以容纳绝对定位的子元素 */
}

.drag-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(230, 245, 255, 0.8);
    border: 2px dashed var(--primary);
    border-radius: var(--border-radius);
    display: none; /* 默认不显示 */
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: bold;
    pointer-events: none; /* 确保它不会干扰其他鼠标事件 */
    z-index: 10; /* 确保覆盖层在其他内容之上 */
    transition: all 0.2s ease-in-out;
}
body.dark-mode .drag-over-overlay {
    background-color: rgba(13, 17, 23, 0.8);
    color: #8da2fb;
    border-color: #8da2fb;
}
.drag-over-overlay .icon {
    margin-right: 10px;
    font-size: 1.5em;
}

.notification-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 当 .drag-over 类被添加到 .input-section 时，显示覆盖层 */
.input-section.drag-over .drag-over-overlay {
    display: flex;
}
.input-section.drag-over {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2); /* 拖拽时的焦点效果 */
}
body.dark-mode .input-section.drag-over {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.4);
}

/* 文本构成分析 */
.composition-stats {
}
body.dark-mode .composition-stats {
}

.density-progress-bar {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--light-gray);
}
body.dark-mode .density-progress-bar {
    background-color: #0d1117;
}

.density-segment {
    height: 100%;
    transition: width 0.5s ease-in-out;
}

#densityChinese { background-color: var(--primary); }
#densityEnglish { background-color: var(--secondary); }
#densityNumbers { background-color: var(--success); }
#densityOther { background-color: var(--light-gray); }
body.dark-mode #densityOther { background-color: #30363d; }

.density-legend {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
}
.density-legend li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}
