/* 计算器样式 */

/* 主容器 */
.calculator {
  max-width: 320px;
  margin: 0 auto;
  padding: 16px;
}

/* 显示屏 */
.display {
  background: var(--display-bg, #1c1c1e);
  padding: 20px;
  border-radius: 16px;
  text-align: right;
  margin-bottom: 8px;
}

.expression {
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result {
  color: #ffffff;
  font-size: 48px;
  font-weight: 300;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 历史记录 */
.history-section {
  margin-bottom: 8px;
}

.toggle-history {
  width: 100%;
  padding: 8px 16px;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #666666;
  transition: background 0.2s;
}

.toggle-history:hover {
  background: #eeeeee;
}

.toggle-history:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.history-list {
  background: #f8f8f8;
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.history-list.hidden {
  display: none;
}

.history-item {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid #e0e0e0;
  transition: background 0.2s;
}

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

.history-item:hover {
  background: #e8e8e8;
}

.history-expression {
  color: #666666;
  font-size: 14px;
}

.history-result {
  color: #333333;
  font-size: 16px;
  font-weight: 500;
}

.history-empty {
  padding: 16px;
  text-align: center;
  color: #666666;
  font-size: 14px;
}

.history-clear-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 8px 16px;
  padding: 6px;
  background: #ff3b30;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.history-clear-btn:hover {
  background: #d32f2f;
}

/* 按钮网格 */
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 10px;
}

/* 0键占两格 */
.btn.zero {
  grid-column: span 2;
  border-radius: 36px;
}

/* 快捷按钮 */
.shortcut-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 10px;
  margin-top: 8px;
}

/* 基础按钮 */
.btn {
  height: 60px;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.btn:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* 数字键 */
.btn.number {
  background: #f0f0f0;
  color: #333333;
}

.btn.number:active {
  background: #d8d8d8;
}

/* 运算符 */
.btn.operator {
  background: #ff9500;
  color: #ffffff;
}

.btn.operator:active {
  background: #e68600;
}

.btn.operator.active {
  background: #ffb84d;
  box-shadow: 0 0 10px rgba(255, 149, 0, 0.5);
}

/* 功能键 */
.btn.function {
  background: #a5a5a5;
  color: #333333;
}

.btn.function:active {
  background: #8a8a8a;
}

/* 快捷键 */
.btn.shortcut {
  background: #d4d4d2;
  color: #333333;
  font-size: 16px;
  border-radius: 8px;
  height: 44px;
}

.btn.shortcut:active {
  background: #c0c0be;
}

/* 使用说明 */
.guide {
  max-width: 320px;
  margin: 24px auto;
  padding: 0 16px;
}

.guide h2 {
  font-size: 18px;
  color: #333333;
  margin-bottom: 12px;
}

.guide ul {
  padding-left: 20px;
}

.guide li {
  color: #666666;
  line-height: 1.6;
  margin-bottom: 6px;
}

/* FAQ */
.faq {
  max-width: 320px;
  margin: 24px auto;
  padding: 0 16px;
}

.faq h2 {
  font-size: 18px;
  color: #333333;
  margin-bottom: 12px;
}

.faq-item {
  margin-bottom: 12px;
}

.faq-item .q {
  color: #333333;
  font-weight: 500;
  margin-bottom: 4px;
}

.faq-item .a {
  color: #666666;
  line-height: 1.5;
}

/* 更多工具 */
.more-tools {
  max-width: 320px;
  margin: 24px auto;
  padding: 0 16px;
}

.more-tools h2 {
  font-size: 18px;
  color: #333333;
  margin-bottom: 12px;
}

.more-tools .links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.more-tools .links a {
  color: #007aff;
  text-decoration: none;
  padding: 8px 16px;
  background: #f0f0f0;
  border-radius: 8px;
  font-size: 14px;
}

.more-tools .links a:hover {
  background: #e0e0e0;
}

/* 页脚 */
footer {
  text-align: center;
  padding: 24px 16px;
  color: #999999;
  font-size: 14px;
}

/* 响应式适配 */
@media (max-width: 375px) {
  .calculator {
    padding: 10px;
  }

  .btn {
    height: 52px;
    font-size: 22px;
  }

  .result {
    font-size: 40px;
  }

  .buttons {
    gap: 8px;
    padding: 8px;
  }

  .btn.shortcut {
    height: 40px;
    font-size: 14px;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .btn.number {
    background: #3a3a3c;
    color: #ffffff;
  }

  .btn.number:active {
    background: #48484a;
  }

  .btn.function {
    background: #636366;
    color: #ffffff;
  }

  .btn.function:active {
    background: #545458;
  }

  .btn.shortcut {
    background: #48484a;
    color: #ffffff;
  }

  .btn.shortcut:active {
    background: #545458;
  }

  .toggle-history,
  .history-list,
  .history-item {
    background: #2c2c2e;
    border-color: #3a3a3c;
    color: #ffffff;
  }

  .toggle-history:hover {
    background: #3a3a3c;
  }

  .history-item:hover {
    background: #3a3a3c;
  }

  .history-expression {
    color: #999999;
  }

  .history-result {
    color: #ffffff;
  }

  .guide,
  .faq,
  .more-tools {
    background: #1c1c1e;
    border-radius: 12px;
    padding: 16px;
    margin: 16px auto;
  }

  .guide h2,
  .faq h2,
  .more-tools h2 {
    color: #ffffff;
  }

  .guide li,
  .faq-item .a {
    color: #999999;
  }

  .faq-item .q {
    color: #ffffff;
  }

  .more-tools .links a {
    background: #2c2c2e;
    color: #0a84ff;
  }

  .more-tools .links a:hover {
    background: #3a3a3c;
  }

  footer {
    background: #1c1c1e;
    color: #666666;
  }
}
