.calc-page {
  padding-top: 32px;
  padding-bottom: 64px;
}

.page-intro {
  text-align: center;
  margin-bottom: 24px;
}

.page-intro h1 {
  margin: 0 0 10px;
  font-size: 34px;
  color: #12245a;
}

.page-intro p {
  margin: 0;
  color: #7d8bb2;
  font-size: 16px;
}

.top-layout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 160px;
  gap: 20px;
  align-items: start;
  margin-bottom: 18px;
}

.main-column {
  min-width: 0;
}

.ad-box,
.mobile-ad {
  background: #fff;
  border: 1px solid #e6ebf5;
  border-radius: 18px;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-ad {
  display: none;
  min-height: 130px;
  margin-bottom: 16px;
}

.ad-inner {
  text-align: center;
  color: #95a1bf;
  font-size: 14px;
}

.ad-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.calculator-card,
.history-box,
.learn-more,
.donate-row {
  background: #fff;
  border: 1px solid #e6ebf5;
  border-radius: 18px;
}

.calculator-card {
  padding: 14px;
}

.calc-screen {
  background: linear-gradient(180deg, #071326 0%, #05101d 100%);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 12px;
}

.screen-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  margin-bottom: 10px;
  gap: 10px;
}

#expressionPreview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#display {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  text-align: right;
  font-size: 36px;
  font-weight: 600;
}

.calc-mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.mode-btn {
  border: 1px solid #dfe6f2;
  background: #fbfcff;
  border-radius: 10px;
  min-height: 34px;
  cursor: pointer;
  color: #5c6988;
  font-size: 13px;
}

.mode-btn.active {
  color: #1565ff;
  background: #f4f8ff;
  border-color: #cfe0ff;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.btn {
  min-height: 46px;
  border: 1px solid #dfe6f2;
  background: #fbfcff;
  border-radius: 10px;
  color: #394765;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover,
.mode-btn:hover,
.faq-question:hover,
.history-footer-btn:hover {
  background: #f4f8ff;
}

.btn.fn {
  color: #1565ff;
}

.btn.op {
  color: #1565ff;
  font-weight: 700;
}

.btn.equal {
  background: #1565ff;
  color: #fff;
  border-color: #1565ff;
}

.btn.zero {
  grid-column: span 2;
}

.content-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-box {
  padding: 12px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-title h2 {
  margin: 0;
  font-size: 16px;
  color: #1a2c63;
}

.history-icon {
  color: #7d8bb2;
}

.link-btn {
  border: none;
  background: transparent;
  color: #8b97b6;
  font-size: 13px;
  cursor: pointer;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid #e6ebf5;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}

.history-item {
  padding: 12px 14px;
  min-height: 72px;
  border-right: 1px solid #e6ebf5;
  font-size: 14px;
  color: #3f4c69;
  background: #fff;
}

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

.history-expression {
  display: block;
  margin-bottom: 6px;
}

.history-result {
  color: #6e7b98;
  font-weight: 600;
}

.history-footer-btn {
  width: 100%;
  min-height: 38px;
  border: 1px solid #e6ebf5;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  color: #2b3d76;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.donate-row {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: inherit;
}

.info-row-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.donate-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #eef4ff;
  color: #1565ff;
}

.donate-row h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: #18306b;
}

.donate-row p {
  margin: 0;
  color: #7d8bb2;
  font-size: 13px;
}

.row-arrow {
  color: #1565ff;
  font-size: 24px;
}

.learn-more {
  padding-top: 10px;
}

.learn-more h3 {
  margin: 0;
  padding: 0 14px 10px;
  color: #18306b;
  font-size: 17px;
}

.faq-item {
  border-top: 1px solid #e6ebf5;
}

.faq-question {
  width: 100%;
  border: none;
  background: #fff;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #2a3c73;
  font-size: 14px;
  cursor: pointer;
}

.faq-answer {
  display: none;
  padding: 0 14px 14px;
  color: #7d8bb2;
  font-size: 13px;
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  display: block;
}

.faq-item.open .faq-symbol {
  color: #1565ff;
  font-weight: 700;
}

.footer-pro {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 0.8fr 1.2fr;
  gap: 28px;
  align-items: start;
}

.footer-brand p,
.footer-note p,
.footer-note small,
.footer-pro a {
  color: #7d8bb2;
  font-size: 14px;
}

.footer-pro h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #18306b;
}

.footer-pro a {
  display: block;
  margin-bottom: 8px;
}

.footer-note-icon {
  font-size: 18px;
  margin-bottom: 8px;
}

.footer-note p {
  margin: 0 0 10px;
}

@media (max-width: 1100px) {
  .top-layout {
    grid-template-columns: 120px minmax(0, 1fr) 120px;
  }
}

@media (max-width: 900px) {
  .top-layout {
    grid-template-columns: 1fr;
  }

  .desktop-ad {
    display: none;
  }

  .mobile-ad {
    display: flex;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .history-item {
    border-right: none;
    border-bottom: 1px solid #e6ebf5;
  }

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

  .footer-pro {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .calc-page {
    padding-top: 20px;
  }

  .page-intro h1 {
    font-size: 30px;
  }

  .page-intro p {
    font-size: 15px;
  }

  .calculator-card {
    padding: 10px;
  }

  .calc-screen {
    padding: 14px;
  }

  #display {
    font-size: 28px;
  }

  .calc-grid {
    gap: 6px;
  }

  .btn {
    min-height: 42px;
    font-size: 14px;
  }

  .info-row-left {
    align-items: flex-start;
  }

  .donate-icon {
    width: 40px;
    height: 40px;
  }
}