.sci-page .container { max-width: 1120px; }
.sci-page .sci-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.sci-page h1 { font-size: clamp(28px, 4vw, 36px); font-weight: 750; letter-spacing: -0.03em; }
.sci-page .subtitle { font-size: 16px; color: var(--text-secondary); max-width: 42rem; margin: 0 auto 28px; }

.sc-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.75fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}

.sc-calc {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  scroll-margin-top: 84px;
}

.sc-display {
  position: relative;
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: #e2e8f0;
  border-radius: 18px;
  padding: 16px 16px 14px;
  min-height: 128px;
  margin-bottom: 14px;
  overflow: hidden;
}
[data-theme="dark"] .sc-display {
  background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}
.sc-display::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% 40%;
  height: 90px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.28), transparent 70%);
  pointer-events: none;
}
.sc-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}
.sc-flag {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.35);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
  cursor: pointer;
  opacity: 0.42;
  min-height: 22px !important;
  width: auto !important;
  max-width: none !important;
  transition: transform .16s ease, opacity .16s ease, background .16s ease, color .16s ease;
}
.sc-flag.is-on {
  opacity: 1;
  color: #fff;
  background: rgba(99, 102, 241, 0.85);
  border-color: transparent;
}
.sc-flag[data-flag="shift"].is-on { background: #f97316; }
.sc-flag[data-flag="hyp"].is-on { background: #06b6d4; }
.sc-flag[data-flag="mem"].is-on { background: #22c55e; }
.sc-expr {
  min-height: 22px;
  font-size: 13px;
  color: #93c5fd;
  text-align: right;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  position: relative;
  z-index: 1;
}
.sc-value {
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 700;
  letter-spacing: -0.04em;
  text-align: right;
  line-height: 1.15;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  position: relative;
  z-index: 1;
  padding-left: 76px;
}
.sc-display.is-flash .sc-value { animation: sc-flash .32s ease; }
.sc-display.is-error { animation: sc-shake .38s ease; }
.sc-copy {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  border: 0;
  background: rgba(255,255,255,.08);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  min-height: 32px !important;
  width: auto !important;
}

.sc-keys {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.sc-key {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 48px !important;
  width: auto !important;
  max-width: none !important;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 4px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  transition: transform .12s ease, box-shadow .16s ease, filter .16s ease, background .16s ease, color .16s ease, border-color .16s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.sc-key .sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ea580c;
  line-height: 1;
  min-height: 10px;
}
.sc-key .main { line-height: 1.1; }
.sc-key:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}
.sc-key:active,
.sc-key.is-pressed {
  transform: scale(0.92);
  filter: brightness(1.08);
}
.sc-key.k-fn { background: #eef2ff; color: #3730a3; }
.sc-key.k-op { background: var(--accent-blue); color: #fff; border-color: transparent; }
.sc-key.k-eq { background: var(--accent-green); color: #fff; border-color: transparent; font-size: 20px; }
.sc-key.k-ac { background: #fee2e2; color: #b91c1c; }
.sc-key.k-del { background: #ffedd5; color: #c2410c; }
.sc-key.k-shift { background: #fff7ed; color: #c2410c; }
.sc-key.k-shift.is-on,
.sc-key.k-mode.is-on {
  background: #f97316;
  color: #fff;
  border-color: transparent;
}
.sc-key.k-mode.is-on { background: #4f46e5; }
.sc-key.k-digit { font-size: 18px; }
.sc-key.is-shifted .main { color: #ea580c; }
[data-theme="dark"] .sc-key.k-fn { background: #1e1b4b; color: #c7d2fe; }
[data-theme="dark"] .sc-key.k-ac { background: #3f1d1d; color: #fecaca; }
[data-theme="dark"] .sc-key.k-del { background: #3b2710; color: #fdba74; }
[data-theme="dark"] .sc-key.k-shift { background: #431407; color: #fdba74; }

.sc-ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: sc-ripple .48s ease-out forwards;
  background: rgba(255,255,255,.5);
  pointer-events: none;
  z-index: 0;
}
.sc-key.k-fn .sc-ripple,
.sc-key.k-del .sc-ripple,
.sc-key.k-ac .sc-ripple { background: rgba(79, 70, 229, .28); }

.sc-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.sc-hist {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 16px;
  min-height: 280px;
}
.sc-hist h2 {
  font-size: 14px;
  font-weight: 750;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.sc-hist-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}
.sc-hist-empty { font-size: 13px; color: var(--text-secondary); padding: 18px 4px; }
.sc-hist-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 44px;
}
.sc-hist-item .q { display: block; font-size: 12px; color: var(--text-secondary); word-break: break-all; }
.sc-hist-item .a { display: block; font-size: 16px; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sc-hist-clear {
  margin-top: 12px;
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

@keyframes sc-ripple {
  to { transform: scale(2.8); opacity: 0; }
}
@keyframes sc-flash {
  0% { transform: scale(1.04); text-shadow: 0 0 18px rgba(134, 239, 172, .8); }
  100% { transform: scale(1); text-shadow: none; }
}
@keyframes sc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@media (max-width: 860px) {
  .sc-wrap { grid-template-columns: 1fr; }
  .sc-hist { min-height: 0; }
  .sc-hist-list { max-height: 220px; }
}
@media (max-width: 560px) {
  .sc-calc { padding: 12px; border-radius: 20px; }
  .sc-keys { gap: 6px; }
  .sc-key { min-height: 44px !important; border-radius: 12px; font-size: 13px; }
  .sc-key.k-digit { font-size: 16px; }
  .sc-key .sub { font-size: 8px; }
  .sc-display { min-height: 112px; padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .sc-key, .sc-display, .sc-flag, .sc-ripple, .sc-value {
    animation: none !important;
    transition: none !important;
  }
}
[data-boost="true"] .sc-key,
[data-boost="true"] .sc-display,
[data-boost="true"] .sc-flag,
[data-boost="true"] .sc-ripple,
[data-boost="true"] .sc-value {
  animation: none !important;
  transition: none !important;
}
[data-boost="true"] .sc-key:active,
[data-boost="true"] .sc-key.is-pressed {
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .sc-key:active, .sc-key.is-pressed { transform: none; }
}
