:root {
  --bg: #08111d;
  --bg-soft: #10243b;
  --panel: rgba(11, 26, 42, 0.82);
  --panel-strong: rgba(9, 21, 35, 0.94);
  --border: rgba(255, 255, 255, 0.14);
  --text: #f6f9fc;
  --muted: #d1dbe7;
  --muted-strong: #e7eef6;
  --accent: #ffb347;
  --accent-strong: #ff7e5f;
  --accent-cool: #79e3ff;
  --focus: #a3ecff;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
  --font-sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", "Liberation Mono", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(121, 227, 255, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 126, 95, 0.16), transparent 30%),
    linear-gradient(145deg, #040912 0%, #08111d 42%, #10243b 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.skip-link:focus {
  width: auto;
  height: auto;
  padding: 12px 16px;
  margin: 12px;
  clip: auto;
  background: #ffffff;
  color: #08111d;
  border-radius: 12px;
  z-index: 10;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 28px 20px 148px;
  isolation: isolate;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.58;
  z-index: -1;
  animation: drift 12s ease-in-out infinite;
}

.ambient-one {
  top: 6%;
  left: 4%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(255, 179, 71, 0.42), transparent 70%);
}

.ambient-two {
  right: 3%;
  bottom: 10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(121, 227, 255, 0.3), transparent 70%);
  animation-delay: -5s;
}

.page-main,
.site-footer {
  width: min(1220px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.display-caption,
.history-count,
.history-time,
.history-intro,
.display-tip,
.card-kicker {
  color: var(--muted);
}

.page-main {
  display: grid;
  gap: 24px;
}

.calculator-page {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.82fr);
  gap: 24px;
  align-items: stretch;
}

.calculator-page > * {
  min-width: 0;
}

.history-card,
.content-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(16, 36, 59, 0.76), rgba(8, 20, 34, 0.94));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.history-card::before,
.content-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 26%),
    linear-gradient(330deg, rgba(255, 255, 255, 0.02), transparent 42%);
  pointer-events: none;
}

.eyebrow,
.card-kicker {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--accent-cool);
}

.panel-title,
.history-header h2,
.content-card h2 {
  margin: 0;
  line-height: 1.3;
  font-weight: 700;
}

.panel-title {
  font-size: clamp(1.7rem, 2.4vw, 2.1rem);
  letter-spacing: 0;
}

.history-header h2,
.content-card h2 {
  font-size: clamp(1.6rem, 2.4vw, 2rem);
}

.content-card p,
.faq-item p,
.feature-list span {
  margin: 0;
  color: var(--muted);
}

.calculator-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  padding: clamp(14px, 2vw, 20px);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(9, 22, 36, 0.86), rgba(7, 17, 29, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.calculator-panel {
  display: grid;
  gap: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.panel-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  min-width: 0;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
  max-width: 100%;
  position: relative;
}

.mode-menu {
  position: relative;
}

.menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  list-style: none;
}

.menu-toggle::-webkit-details-marker {
  display: none;
}

.mode-menu[open] .menu-toggle {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
}

.menu-toggle-icon {
  font-size: 0.95rem;
}

.mode-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  min-width: 176px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 20, 34, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 8px;
}

.mode-option {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.mode-option:hover,
.mode-option:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.mode-option.is-active {
  background: rgba(121, 227, 255, 0.14);
  border-color: rgba(121, 227, 255, 0.32);
}

.scientific-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 12px);
}

.scientific-grid[hidden] {
  display: none !important;
}

.scientific {
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  background: linear-gradient(180deg, rgba(121, 227, 255, 0.14), rgba(255, 255, 255, 0.03));
}

.scientific-toggle.is-active {
  background: rgba(121, 227, 255, 0.18);
  border-color: rgba(121, 227, 255, 0.48);
  box-shadow: inset 0 0 0 1px rgba(121, 227, 255, 0.18);
}

.floating-scale {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 20, 34, 0.94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.floating-scale-btn {
  min-width: 86px;
  min-height: 46px;
  font-weight: 700;
}

.display-panel {
  width: 100%;
  min-height: clamp(204px, 24vw, 244px);
  padding: clamp(16px, 2vw, 20px);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    linear-gradient(145deg, rgba(21, 44, 69, 0.98), rgba(8, 19, 31, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.noscript-card {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 179, 71, 0.28);
  background: rgba(255, 179, 71, 0.12);
  color: #fff4df;
}

.display-meta,
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.display-caption {
  font-size: 0.9rem;
}

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

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.ghost-btn:hover,
.ghost-btn:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.ghost-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.expression,
.result {
  overflow: hidden;
  width: 100%;
  text-overflow: clip;
  white-space: nowrap;
}

.expression {
  margin-top: 18px;
  min-height: 1.4em;
  color: #d7e5f4;
  font-family: var(--font-mono);
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1.4;
}

.result {
  margin-top: 14px;
  min-height: 1.12em;
  font-size: clamp(2.35rem, 7vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.12;
}

.display-tip {
  margin: 10px 0 0;
  font-size: 0.92rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 12px);
}

.key {
  min-height: clamp(54px, 10vw, 68px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  color: var(--text);
  font-size: clamp(1.1rem, 2.6vw, 1.45rem);
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.key:hover,
.key:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 14px 30px rgba(0, 0, 0, 0.2);
}

.key:active {
  transform: translateY(0);
}

.number {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
}

.utility {
  color: #eef7ff;
  background: linear-gradient(180deg, rgba(121, 227, 255, 0.18), rgba(255, 255, 255, 0.04));
}

.operator {
  color: #fff4df;
  background: linear-gradient(180deg, rgba(255, 179, 71, 0.22), rgba(255, 255, 255, 0.04));
}

.accent {
  color: #201109;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.history-card,
.content-card {
  padding: 26px 24px;
}

.archive-card {
  display: grid;
  gap: 14px;
}

.history-intro {
  margin: 18px 0 0;
  font-size: 0.96rem;
}

.archive-intro {
  margin-top: 0;
}

.history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

.history-export {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.history-export-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.history-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-export-status {
  min-height: 1.4em;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.export-btn {
  min-width: 104px;
  min-height: 42px;
  font-weight: 700;
}

.history-summary-copy {
  display: grid;
  gap: 4px;
}

.history-summary-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.history-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  min-height: 280px;
  max-height: 640px;
  overflow: auto;
  padding-right: 6px;
}

.archive-history-list {
  margin-top: 4px;
  max-height: 560px;
}

.history-list::-webkit-scrollbar {
  width: 10px;
}

.history-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.history-item,
.history-empty,
.feature-list li,
.faq-item {
  width: 100%;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.history-item {
  position: relative;
  display: grid;
  align-items: stretch;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.history-item:hover,
.history-item:focus-within {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
}

.history-item.is-selected {
  border-color: rgba(121, 227, 255, 0.88);
  background: rgba(121, 227, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(121, 227, 255, 0.2);
}

.history-item.is-selected::after {
  content: "已选";
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(121, 227, 255, 0.18);
  color: #dff8ff;
  font-size: 0.78rem;
  font-weight: 700;
}

.history-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, auto);
  align-items: start;
  gap: 16px;
}

.history-note,
.history-delete,
.history-select {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
}

.history-note,
.history-delete {
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92em;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.history-note {
  justify-self: stretch;
  max-width: none;
  border: 1px solid rgba(121, 227, 255, 0.24);
  background: rgba(121, 227, 255, 0.14);
  color: #eaf8ff;
  text-align: left;
}

.history-note.is-empty {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.history-note:hover,
.history-note:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(121, 227, 255, 0.52);
  background: rgba(121, 227, 255, 0.18);
}

.history-note.is-empty:hover,
.history-note.is-empty:focus-visible {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.1);
}

.history-delete {
  min-width: 104px;
  width: 104px;
  justify-self: end;
  border: 1px solid rgba(255, 126, 95, 0.28);
  background: rgba(255, 126, 95, 0.12);
  color: #ffe2d8;
  text-align: center;
}

.history-delete:hover,
.history-delete:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 126, 95, 0.5);
  background: rgba(255, 126, 95, 0.18);
}

.archive-history-actions {
  grid-template-columns: minmax(0, 1fr);
}

.archive-history-note {
  max-width: none;
}

.archive-history-select {
  padding-right: 0;
}

.history-select {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1.1fr) minmax(88px, auto);
  align-items: start;
  gap: 12px;
  padding: 2px 56px 0 0;
  text-align: left;
  cursor: pointer;
}

.history-expression {
  color: #dbe7f3;
  font-family: var(--font-mono);
  font-size: 0.98rem;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.35;
  max-height: calc(1.35em * 2);
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.history-result {
  font-size: 1.34rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.3;
  max-height: calc(1.3em * 2);
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-time {
  min-width: 88px;
  align-self: center;
  justify-self: end;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.history-empty p,
.history-empty span {
  margin: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.content-card {
  display: grid;
  gap: 14px;
}

.content-card p {
  font-size: 0.98rem;
  line-height: 1.8;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.feature-list li {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
}

.feature-list strong {
  font-size: 1.02rem;
  color: var(--text);
}

.faq-card {
  align-content: start;
}

.faq-list {
  display: grid;
  gap: 14px;
}

.faq-item {
  padding: 0 18px;
}

.faq-item summary {
  cursor: pointer;
  padding: 16px 0;
  list-style: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item p {
  padding: 0 0 16px;
}

.site-footer {
  margin-top: 22px;
  padding: 0 4px;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

html[data-ui-scale="2"] .calculator-page .panel-title {
  font-size: clamp(1.95rem, 2.9vw, 2.4rem);
}

html[data-ui-scale="2"] .calculator-page .panel-summary,
html[data-ui-scale="2"] .calculator-page .panel-actions-label,
html[data-ui-scale="2"] .calculator-page .display-caption,
html[data-ui-scale="2"] .calculator-page .display-tip,
html[data-ui-scale="2"] .calculator-page .history-intro,
html[data-ui-scale="2"] .calculator-page .history-summary-label,
html[data-ui-scale="2"] .calculator-page .history-time {
  font-size: 1rem;
}

html[data-ui-scale="2"] .calculator-page .expression {
  font-size: clamp(1.35rem, 3.4vw, 2.2rem);
}

html[data-ui-scale="2"] .calculator-page .result {
  font-size: clamp(2.75rem, 8vw, 5rem);
}

html[data-ui-scale="2"] .calculator-page .key {
  min-height: clamp(60px, 11vw, 78px);
  font-size: clamp(1.2rem, 3vw, 1.65rem);
}

html[data-ui-scale="2"] .calculator-page .ghost-btn,
html[data-ui-scale="2"] .calculator-page .history-item {
  font-size: 1rem;
}

html[data-ui-scale="2"] .calculator-page .history-expression {
  font-size: 1.05rem;
}

html[data-ui-scale="2"] .calculator-page .history-note,
html[data-ui-scale="2"] .calculator-page .history-delete {
  font-size: 0.96em;
}

html[data-ui-scale="2"] .calculator-page .history-result,
html[data-ui-scale="2"] .calculator-page .history-summary-value {
  font-size: 1.55rem;
}

html[data-ui-scale="3"] .calculator-page .panel-title {
  font-size: clamp(2.15rem, 3.2vw, 2.7rem);
}

html[data-ui-scale="3"] .calculator-page .panel-summary,
html[data-ui-scale="3"] .calculator-page .panel-actions-label,
html[data-ui-scale="3"] .calculator-page .display-caption,
html[data-ui-scale="3"] .calculator-page .display-tip,
html[data-ui-scale="3"] .calculator-page .history-intro,
html[data-ui-scale="3"] .calculator-page .history-summary-label,
html[data-ui-scale="3"] .calculator-page .history-time {
  font-size: 1.08rem;
}

html[data-ui-scale="3"] .calculator-page .expression {
  font-size: clamp(1.5rem, 3.9vw, 2.45rem);
}

html[data-ui-scale="3"] .calculator-page .result {
  font-size: clamp(3rem, 9vw, 5.4rem);
}

html[data-ui-scale="3"] .calculator-page .key {
  min-height: clamp(64px, 12vw, 84px);
  font-size: clamp(1.28rem, 3.2vw, 1.8rem);
}

html[data-ui-scale="3"] .calculator-page .ghost-btn,
html[data-ui-scale="3"] .calculator-page .history-item {
  font-size: 1.04rem;
}

html[data-ui-scale="3"] .calculator-page .history-expression {
  font-size: 1.1rem;
}

html[data-ui-scale="3"] .calculator-page .history-note,
html[data-ui-scale="3"] .calculator-page .history-delete {
  font-size: 1em;
}

html[data-ui-scale="3"] .calculator-page .history-result,
html[data-ui-scale="3"] .calculator-page .history-summary-value {
  font-size: 1.68rem;
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(14px, -20px, 0) scale(1.06);
  }
}

@media (max-width: 1040px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .calculator-page {
    grid-template-columns: 1fr;
  }

  .history-card,
  .content-card {
    padding: 22px 20px;
  }

  .history-list {
    min-height: 220px;
    max-height: none;
  }

  .archive-history-list {
    max-height: none;
  }

  .panel-actions {
    justify-content: flex-start;
    margin-left: 0;
  }

  .scientific-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 18px 14px 138px;
  }

  .history-card,
  .content-card {
    border-radius: 24px;
  }

  .history-card,
  .content-card {
    padding: 20px 18px;
  }

  .calculator-card {
    padding: 14px;
  }

  .display-panel {
    padding: 18px 16px;
  }

  .display-meta {
    flex-wrap: wrap;
  }

  .display-caption {
    width: 100%;
  }

  .history-header,
  .history-tools,
  .history-summary,
  .history-summary-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .key {
    border-radius: 16px;
  }

  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .panel-heading,
  .panel-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .mode-menu-panel {
    right: auto;
    left: 0;
  }

  .floating-scale {
    right: 14px;
    bottom: 14px;
    padding: 10px;
  }

  .scientific-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .history-item {
    gap: 10px;
  }

  .history-select {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(76px, auto);
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 12px 10px 104px;
  }

  .site-footer {
    padding: 0;
  }

  .history-card,
  .content-card {
    padding: 16px 14px;
    border-radius: 20px;
  }

  .calculator-card {
    padding: 10px;
    border-radius: 18px;
  }

  .display-panel {
    padding: 14px 12px;
    border-radius: 18px;
  }

  .controls-grid {
    gap: 8px;
  }

  .scientific-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .history-summary,
  .history-export,
  .history-item,
  .history-empty,
  .feature-list li,
  .faq-item {
    border-radius: 16px;
  }

  .history-item {
    gap: 8px;
    padding: 12px 10px;
  }

  .history-item.is-selected::after {
    display: none;
  }

  .history-expression {
    font-size: 0.9rem;
  }

  .history-result {
    font-size: 1.05rem;
  }

  .history-list {
    min-height: auto;
    padding-right: 2px;
  }

  .history-export-actions {
    width: 100%;
  }

  .export-btn {
    min-width: 0;
    flex: 1 1 calc(33.333% - 7px);
  }

  .history-summary-actions .ghost-btn {
    width: 100%;
  }

  .panel-summary {
    width: 100%;
  }

  .history-note,
  .history-delete {
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .history-actions {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .archive-history-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-delete {
    min-width: 0;
    width: 100%;
    justify-self: stretch;
  }

  .history-select {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(64px, auto);
    gap: 8px;
    padding-right: 0;
  }

  .history-time {
    font-size: 0.78rem;
    min-width: 64px;
    align-self: start;
    justify-self: end;
    text-align: right;
  }

  .mode-menu {
    width: 100%;
  }

  .menu-toggle {
    justify-content: space-between;
    width: 100%;
  }

  .mode-menu-panel {
    left: 0;
    right: 0;
    min-width: 0;
  }

  .floating-scale {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .floating-scale-btn {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding: 10px 8px 94px;
  }

  .history-card,
  .content-card {
    padding: 14px 12px;
  }

  .calculator-card {
    padding: 8px;
  }

  .display-panel {
    padding: 12px 10px;
  }

  .expression {
    font-size: 1.05rem;
  }

  .result {
    font-size: 2rem;
  }

  .key {
    min-height: 48px;
    font-size: 1rem;
    border-radius: 14px;
  }

  .history-item {
    gap: 6px;
  }

  .history-note,
  .history-delete {
    min-height: 40px;
    padding: 7px 8px;
  }

  .history-export {
    padding: 14px 12px;
  }

  .history-expression {
    font-size: 0.82rem;
  }

  .history-result {
    font-size: 0.94rem;
  }

  .history-time {
    font-size: 0.72rem;
    min-width: 56px;
  }

  .history-select {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.94fr) minmax(56px, auto);
    gap: 6px;
  }

  .export-btn {
    min-height: 40px;
    font-size: 0.92rem;
  }

  .history-export-status {
    font-size: 0.82rem;
  }

  .scientific-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .floating-scale {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
