.sc-page {
 margin: 0;
 background: #f1f4f9;
}

#simulation-calculator {
 max-width: 1060px;
 min-height: 100dvh;
 margin-inline: auto;
}

.sc-calc {
 --sc-ink: #192942;
 --sc-muted: #52657d;
 --sc-border: #d8e1ee;
 --sc-blue: #2559c6;
 --sc-key-height: 44px;
 container-type: inline-size;
 padding: 18px 24px 22px;
 color: var(--sc-ink);
 font-family: Inter, -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
 font-size: 14px;
 line-height: 1.4;
}
.sc-calc * { box-sizing: border-box; }

.sc-top, .sc-modes {
 display: flex;
 align-items: center;
 justify-content: space-between;
 flex-wrap: wrap;
 gap: 8px 12px;
}

.sc-top { margin-bottom: 12px; }
.sc-top h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.sc-edit { display: flex; gap: 6px; margin-left: auto; }
.sc-edit button {
 min-height: 36px;
 min-width: 58px;
 padding: 0 12px;
 border: 1px solid var(--sc-border);
 border-radius: 8px;
 background: #fff;
 color: var(--sc-ink);
 font: inherit;
 cursor: pointer;
}
.sc-edit button:last-child { color: #963e38; }

.sc-screen {
 min-width: 0;
 padding: 10px 16px 6px;
 border: 1px solid #203554;
 border-radius: 13px;
 background: #14253e;
 box-shadow: inset 0 1px 0 #ffffff12;
}
.sc-display {
 display: block;
 width: 100%;
 height: 43px;
 min-width: 0;
 margin: 0;
 padding: 0;
 border: 0;
 border-radius: 3px;
 background: transparent;
 color: #fff;
 caret-color: #a9c6ff;
 font: 500 clamp(23px, 3.7vw, 34px)/1.2 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
 text-align: right;
}
.sc-display::placeholder { color: #aebed6; opacity: 1; }
.sc-error {
 min-height: 18px;
 color: #ffbfb4;
 font-size: 12px;
 overflow-wrap: anywhere;
}

.sc-modes { margin: 12px 0 16px; }
.sc-mode {
 display: flex;
 flex-wrap: wrap;
 gap: 2px;
 min-inline-size: 0;
 margin: 0;
 padding: 3px;
 border: 1px solid var(--sc-border);
 border-radius: 9px;
 background: #e6ecf5;
}
.sc-mode label { position: relative; display: block; margin: 0; cursor: pointer; }
.sc-mode input {
 position: absolute;
 inset: 0;
 width: 100%;
 height: 100%;
 margin: 0;
 opacity: 0;
 cursor: pointer;
}
.sc-mode span {
 display: block;
 padding: 5px 9px;
 border-radius: 6px;
 color: #455870;
 font-size: 13px;
 white-space: nowrap;
}
.sc-mode input:checked + span {
 background: #fff;
 color: #214c9d;
 font-weight: 600;
 box-shadow: 0 1px 3px #243f651a;
}
.sc-mode label:hover span { background: #f5f8fd; }

.sc-keyboards {
 display: grid;
 grid-template-columns: minmax(0, 3fr) minmax(0, 3fr) minmax(0, 4.2fr);
 gap: 16px;
 align-items: start;
}
.sc-keyboards section { min-width: 0; margin: 0; }
.sc-tools { display: grid; gap: 11px; }
.sc-group-label { margin-bottom: 7px; color: var(--sc-muted); font-size: 13px; font-weight: 600; }
.sc-keys, .sc-hex-keys { display: grid; gap: 6px; }
.sc-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sc-numpad .sc-keys { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sc-hex-keys { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 7px; }

.sc-calc .sc-key {
 min-width: 0;
 min-height: var(--sc-key-height);
 padding: 4px 2px;
 border: 1px solid var(--sc-border);
 border-radius: 8px;
 background: #e9eef6;
 color: var(--sc-ink);
 font-family: inherit;
 font-size: 14px;
 font-weight: 600;
 line-height: 1.2;
 text-align: center;
 cursor: pointer;
}
.sc-calc .sc-number { background: #fff; font-size: 18px; font-variant-numeric: tabular-nums; }
.sc-calc .sc-operation { border-color: #c9d8f2; background: #dce8fc; color: #214fa8; font-size: 18px; }
.sc-calc .sc-equal {
 grid-column: 1 / -1;
 border-color: var(--sc-blue);
 background: var(--sc-blue);
 color: #fff;
 font-size: 23px;
}
.sc-calc .sc-hex { min-height: 34px; background: #fff; }
.sc-calc .sc-hex:disabled { background: #edf1f7; color: #77889e; cursor: default; }
.sc-edit button:hover, .sc-key:hover:not(:disabled) { border-color: #9db5dc; background: #dce7f9; }
.sc-calc .sc-equal:hover { border-color: #1d48aa; background: #1d48aa; }
.sc-calc :is(.sc-key, .sc-edit button):active:not(:disabled) { transform: translateY(1px); }

.sc-calc button:focus-visible, .sc-mode input:focus-visible + span {
 outline: 2px solid var(--sc-blue);
 outline-offset: 1px;
}
.sc-calc .sc-display:focus-visible { outline: 2px solid #9dbdff; outline-offset: 3px; }

#dialog:has(#sim-calculator-fallback) { width: min(900px, calc(100vw - 32px)); padding: clamp(14px, 2.5vw, 24px); }
#sim-calculator-fallback .sc-calc { padding: 0; }

@container (max-width: 600px) {
 .sc-keyboards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
 .sc-numpad { grid-column: 1 / -1; }
}
@container (max-width: 360px) {
 .sc-keyboards { gap: 9px; }
 .sc-keys, .sc-hex-keys { gap: 4px; }
 .sc-calc .sc-key { font-size: 12px; }
 .sc-calc :is(.sc-number,.sc-operation) { font-size: 17px; }
 .sc-calc .sc-equal { font-size: 22px; }
}
@media (max-width: 550px) {
 .sc-calc { padding: 12px; }
 .sc-top h1 { font-size: 17px; }
 .sc-edit button { min-width: 45px; padding-inline: 7px; }
}
