:root {
  --bg: #eef1f7;
  --card: #ffffff;
  --ink: #1f2633;
  --muted: #6b7486;
  --muted-2: #98a1b3;
  --accent: #4f6bf5;
  --accent-2: #7a5cf0;
  --danger: #e5484d;
  --key: #f1f3f9;
  --key-hover: #e4e8f4;
  --fn-bg: #e9edfb;
  --fn-ink: #3d55d6;
  --border: #e6eaf4;
  --radius: 20px;
  --shadow: 0 8px 30px rgba(31, 38, 51, .08);
  --mono: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.ad-side {
  width: 200px;
  flex: 0 0 200px;
  min-height: 1px;
}

.main {
  flex: 1;
  min-width: 0;
  max-width: 800px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.page-head {
  text-align: center;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: .5px;
  background: linear-gradient(120deg, #2a3245, #4f6bf5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-head .sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.calc-display {
  background: linear-gradient(160deg, #1b2233, #131927);
  border-radius: 14px;
  padding: 14px 16px 12px;
  color: #eef1f8;
}

.display-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 26px;
}

.mem-flag {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 9px;
  border-radius: 999px;
  line-height: 1.6;
}

.angle-mode {
  font-size: 12px;
  font-weight: 600;
  color: #9aa6c4;
  letter-spacing: .1em;
}

.ghost-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .22);
  color: #cdd6ea;
  font-size: 12px;
  padding: 3px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}

.ghost-btn:hover { background: rgba(255, 255, 255, .12); }

.expr-input {
  width: 100%;
  margin-top: 4px;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 28px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 2px 0;
  caret-color: #7d9bff;
}

.expr-input::placeholder {
  color: rgba(255, 255, 255, .32);
  font-weight: 400;
}

.preview {
  min-height: 28px;
  text-align: right;
  font-size: 18px;
  color: #8f9cbf;
  font-family: var(--mono);
  word-break: break-all;
}

.preview.error { color: #ff9a9a; font-size: 14px; }

.noscript {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin: 12px 0 0;
}

.mem-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.pad-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

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

.std-pad {
  flex: 1 1 248px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.key {
  border: none;
  border-radius: 12px;
  background: var(--key);
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  font-family: inherit;
  height: 48px;
  min-width: 0;
  cursor: pointer;
  transition: background .15s, transform .06s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}

.key:hover { background: var(--key-hover); }

.key:active { transform: scale(.95); }

.key:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.key.fn {
  background: var(--fn-bg);
  color: var(--fn-ink);
  font-size: 14.5px;
}

.key.fn:hover { background: #dde4fa; }

.key.mem {
  color: #5a6478;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}

.key.util { background: #e9ecf4; }

.key.util.danger { color: var(--danger); }

.key.op {
  background: #eef0fe;
  color: var(--accent);
  font-size: 21px;
}

.key.togglable.active { background: var(--accent); color: #fff; }

.key.eq {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(79, 107, 245, .35);
}

.key.eq:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.seo-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-top: 22px;
}

.seo-section h2 { font-size: 20px; margin: 28px 0 14px; }

.seo-section h2:first-child { margin-top: 0; }

/* SEO 内容区（页面底部） */
.seo-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  color: #374151;
  font-size: 14px;
  line-height: 1.9;
}

.seo-content h2 {
  font-size: 17px;
  color: #1f2937;
  margin: 22px 0 10px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}

.seo-content h2:first-child { margin-top: 0; }

.seo-content h3 {
  font-size: 14px;
  color: #1f2937;
  margin: 14px 0 4px;
}

.seo-content ul,
.seo-content ol { padding-left: 22px; }

.seo-content li { margin-bottom: 4px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.feature {
  background: #f6f8fd;
  border-radius: 12px;
  padding: 14px 16px;
}

.feature h3 { margin: 0 0 4px; font-size: 15px; color: #2a3245; }

.feature p { margin: 0; font-size: 13.5px; color: #66708a; }

.steps { margin: 0; padding-left: 22px; color: #4a5468; font-size: 14.5px; }

.steps li { margin-bottom: 6px; }

.steps code, .seo-section code {
  background: #eef1f8;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: var(--mono);
  font-size: 13px;
  color: #3d55d6;
}

kbd {
  background: #eef1f8;
  border: 1px solid #d9dfef;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12px;
  font-family: var(--mono);
  color: #3d465c;
}

details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  background: #fafbfe;
}

details:last-of-type { margin-bottom: 0; }

summary { font-weight: 600; cursor: pointer; font-size: 15px; }

summary:hover { color: var(--accent); }

details p { color: #5c6678; font-size: 14px; margin: 8px 0 0; }

@media (max-width: 1200px) {
  .ad-side { display: none; }
}

@media (max-width: 860px) {
  .page { padding: 16px 12px 40px; }

  .calc-card { padding: 14px; }

  .page-head h1 { font-size: 24px; }

  .page-head .sub { font-size: 13px; }

  .expr-input { font-size: 22px; }

  .preview { font-size: 16px; }

  .key { height: 46px; font-size: 18px; }

  .key.fn { font-size: 13.5px; }

  .seo-section { padding: 20px 18px; }

  .seo-section h2 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .key { transition: none; }
}
