/* iOS Calculator (iOS 18+/26 look) */
.ios {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  background: #000; color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  padding: 0 16px 18px;
}
.ios-top { width: 100%; max-width: var(--padw); height: 48px; flex: none; display: flex; align-items: center; gap: 10px; padding-left: 40px; }
.ios-hist { width: 36px; height: 36px; border-radius: 18px; border: 0; background: rgba(255,255,255,.1); color: #ff9f0a; display: grid; place-items: center; cursor: pointer; }
.ios-hist svg { width: 20px; height: 20px; }
.ios-rad { font-size: 15px; color: #fff; opacity: 0; }
.ios.rad-on .ios-rad { opacity: 1; }
.ios-display { width: 100%; max-width: var(--padw); flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; padding: 0 6px 10px; }
.ios-expr { text-align: right; color: #8d8d93; font-size: 26px; min-height: 32px; line-height: 32px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; unicode-bidi: plaintext; }
.ios-main { text-align: right; white-space: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.ios-main::-webkit-scrollbar { display: none; }
.ios-main span { font-weight: 300; line-height: 1.12; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: inline-block; }
.ios[data-layout="land"] .ios-expr { font-size: 20px; }

.ios-pad { flex: none; width: var(--padw); display: flex; flex-wrap: wrap; gap: var(--gap); justify-content: space-between; }
.ik {
  position: relative; border: 0; padding: 0; margin: 0; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-weight: 400;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: filter .25s, background-color .25s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), inset 0 -1px 0 rgba(0,0,0,.25);
}
.ik.pressed { filter: brightness(1.55); transition: none; }
.ik:focus { outline: none; }
.ik:focus-visible { box-shadow: 0 0 0 2px #fff; }
.ik.num { background: linear-gradient(rgba(255,255,255,.06), rgba(255,255,255,0)) #333335; }
.ik.fn { background: linear-gradient(rgba(255,255,255,.08), rgba(255,255,255,0)) #5c5c5f; }
.ik.op { background: linear-gradient(rgba(255,255,255,.14), rgba(255,255,255,0)) #ff9f0a; }
.ik.sci { background: linear-gradient(rgba(255,255,255,.05), rgba(255,255,255,0)) #1f1f21; }
.ik.sci.on { background: #6b6b6f; }
.ik svg { width: 42%; height: 42%; }
.ik.mode svg { width: 38%; height: 38%; }
.ik .ik-alt { display: none; }
.ios.second-on .ik[data-alt] .ik-main { display: none; }
.ios.second-on .ik[data-alt] .ik-alt { display: inline; }
.ik sup { font-size: .62em; vertical-align: .55em; line-height: 0; }
.ik sub { font-size: .62em; vertical-align: -.3em; line-height: 0; }
.ik .ix { margin-right: -.15em; }
.ik .fr { display: inline-flex; align-items: center; } .ik .fr sup, .ik .fr sub { vertical-align: baseline; font-size: .75em; }
.ik .pm { letter-spacing: -.04em; }

/* basic portrait: circles */
.ios[data-layout="basic"] .ik { width: var(--kw); height: var(--kh); border-radius: 50%; font-size: calc(var(--kh) * .44); }
.ios[data-layout="basic"] .ik.op { font-size: calc(var(--kh) * .5); }
.ios[data-layout="basic"] .ik.fn { font-size: calc(var(--kh) * .38); }

/* scientific portrait: 6-column sci block over the 4-column basic block */
.ios[data-layout="port"] .ik.sci { width: var(--sw); height: var(--sh); border-radius: calc(var(--sh) / 2); font-size: calc(var(--sh) * .42); }
.ios[data-layout="port"] .ik:not(.sci) { width: var(--bw); height: var(--bh); border-radius: calc(var(--bh) / 2); font-size: calc(var(--bh) * .46); }
.ios[data-layout="port"] .ik.op { font-size: calc(var(--bh) * .52); }

/* scientific landscape: 10 columns of pills */
.ios[data-layout="land"] { padding: 0 16px 12px; }
.ios[data-layout="land"] .ik { width: var(--lw); height: var(--lh); border-radius: calc(var(--lh) / 2); font-size: calc(var(--lh) * .42); }
.ios[data-layout="land"] .ik.op, .ios[data-layout="land"] .ik.num, .ios[data-layout="land"] .ik.fn { font-size: calc(var(--lh) * .5); }

/* history sheet */
.ios-sheet { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 5; }
.ios-sheet[hidden], .ios-menu[hidden] { display: none; }
.ios-sheet-card { width: min(100%, 520px); height: 75%; background: #1c1c1e; border-radius: 14px 14px 0 0; display: flex; flex-direction: column; }
.ios-sheet-card header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-weight: 600; }
.ios-sheet-card header button { background: none; border: 0; color: #ff9f0a; font: inherit; font-weight: 400; font-size: 17px; cursor: pointer; }
.ios-sheet-card ol { list-style: none; margin: 0; padding: 0 16px 20px; overflow-y: auto; flex: 1; }
.ios-sheet-card li { padding: 10px 0; border-bottom: 1px solid #2c2c2e; text-align: right; cursor: pointer; }
.ios-sheet-card li.empty { text-align: center; color: #8d8d93; border: 0; padding-top: 40px; cursor: default; }
.h-expr { color: #8d8d93; font-size: 15px; }
.h-res { font-size: 22px; }

/* mode menu */
.ios-menu { position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: flex-start; padding: 0 16px calc(18px + var(--kh, 60px)); }
.ios[data-layout="port"] .ios-menu { padding-bottom: calc(18px + var(--bh, 50px)); }
.ios-menu-card { margin-left: max(0px, calc((100% - var(--padw)) / 2)); width: 220px; background: rgba(44,44,46,.96); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 14px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.ios-menu-card button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: none; border: 0; border-bottom: 1px solid rgba(255,255,255,.08); color: #fff; font: inherit; font-size: 17px; text-align: left; cursor: pointer; }
.ios-menu-card button[disabled] { color: #6d6d72; cursor: default; }
.ios-menu-card .chk { width: 18px; height: 18px; display: inline-grid; color: #fff; }
.ios-menu-card .sep { height: 6px; background: rgba(0,0,0,.25); }
.ios[data-layout="land"] .ios-top { position: absolute; top: 0; left: 16px; width: auto; }
