/* Calc Frost Web — © 2026 compact */
@font-face { font-family: 'Roboto'; font-weight: 300; font-display: block; src: url(../fonts/roboto-latin-300-normal.woff2) format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 400; font-display: block; src: url(../fonts/roboto-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 500; font-display: block; src: url(../fonts/roboto-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 300 500; font-display: block; unicode-range: U+221A; src: url(../fonts/roboto-math-500-normal.woff2) format('woff2'); }

:root {
  --accent: #00E5FF;
  --on-accent: #06101A;
  --theme-accent: #00E5FF; /* Android テーマの colorAccent(スイッチ・入力欄の下線) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: 'Roboto', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #060A16; color: #fff;
  font-family: var(--font); font-weight: 400;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; }
input { font: inherit; -webkit-user-select: text; user-select: text; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.screen {
  position: fixed; inset: 0;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  display: none;
}
.screen.active { display: flex; flex-direction: column; }
.screen.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen.scroll.active { display: block; }
.col { padding: 0 16px 16px; min-height: 100%; }

/* ------------------------------------------------ 電卓 */
#main { touch-action: manipulation; }
.topbar { position: relative; height: 56px; flex: none; }
.topbar .icon-btn { position: absolute; top: 6px; }
.topbar .left { left: 18px; }
.topbar .right { right: 18px; }

.display {
  flex: 1 1 0px; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 28px 4px;
  transition: flex-grow 180ms ease-in-out;
}
.mem {
  font-size: 14px; font-weight: 500; color: var(--accent);
  min-height: 22px; line-height: 22px;
  white-space: pre; overflow: hidden; text-overflow: ellipsis; flex: none;
}
.mainval {
  font-weight: 300; color: #fff; text-align: right; white-space: pre;
  line-height: 1.17; overflow: hidden; flex: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.53);
}
.subscroll {
  overflow-x: auto; overflow-y: hidden; flex: none; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.subscroll::-webkit-scrollbar { display: none; }
.sub {
  display: inline-block; min-width: 100%; text-align: right; white-space: pre;
  min-height: 34px; line-height: 34px; font-size: 22px;
  text-shadow: 0 1px 2px rgba(0,0,0,.53);
}
.u { font-size: var(--ur, .5em); }

.drawer {
  flex: 0 1 0px; min-height: 0; overflow: hidden; padding: 0 12px;
  display: flex; flex-direction: column;
  transition: flex-grow 180ms ease-in-out;
}
.drawer.closed { visibility: hidden; }
.pad { flex: 1 1 0px; min-height: 0; padding: 0 12px 12px; display: flex; flex-direction: column; }
.krow { display: flex; min-height: 0; }
.krow.small { flex: .6 1 0px; }
.krow.big { flex: 1 1 0px; }
.drawer .krow { flex: 1 1 0px; }

.handle { height: 22px; flex: none; position: relative; touch-action: none; cursor: pointer; }
.handle .line { position: absolute; left: 16px; right: 16px; top: 10.5px; height: 1px; background: rgba(255,255,255,.14); }
.handle .tab {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 18.92px;
  transform: translate(-50%,-50%); border-radius: 10px; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
}
.handle.pressed .tab { background: rgba(255,255,255,.4); }
.handle svg { width: 14px; height: 8px; overflow: visible; }

/* ------------------------------------------------ キー */
.key {
  flex: 1 1 0px; min-width: 0; margin: 4px; position: relative;
  container-type: size; cursor: pointer; touch-action: manipulation;
  transition: transform 110ms ease-out;
}
.key.pressed { transform: scale(.94); transition-duration: 60ms; }
.key .face {
  position: absolute; inset: 0;
  border-radius: calc(min(100cqw, 100cqh) * var(--kr, .32));
  background: var(--fill); border: 1px solid var(--stroke);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); text-shadow: 0 1px 2px rgba(0,0,0,.4);
  white-space: nowrap; line-height: 1;
}
.key.pressed .face::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; background: rgba(255,255,255,.22);
}
.key.t-digit .face { font-weight: 300; font-size: 30px; }
.key.t-func .face { font-weight: 500; font-size: 22px; }
.key.t-func.pct .face { font-size: 26px; }
.key.t-mem .face, .key.t-func2 .face, .key.t-unit .face { font-weight: 500; font-size: 16px; --kr: .38; }
.key.t-op .face, .key.t-eq .face { font-weight: 400; font-size: 34px; }
.key.ac .face { font-weight: 500; font-size: 24px; }
.key .face svg { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); overflow: visible; }

/* ------------------------------------------------ アイコンボタン */
.icon-btn { width: 44px; height: 44px; flex: none; position: relative; cursor: pointer; }
.icon-btn svg { width: 44px; height: 44px; display: block; }
.icon-btn .press { opacity: 0; }
.icon-btn.pressed .press { opacity: 1; }

/* ------------------------------------------------ 共通部品 */
.header { display: flex; align-items: center; height: 64px; }
.header .title { font-size: 24px; font-weight: 300; padding-left: 14px; flex: 1; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card {
  background: rgba(10,15,30,.6); border: 1px solid rgba(255,255,255,.15); border-radius: 22px;
  padding: 16px; margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 500; letter-spacing: .06em; padding-bottom: 10px; color: var(--accent); }
.label { font-size: 16px; color: #fff; }
.hint { font-size: 12px; color: rgba(255,255,255,.6); line-height: 1.35; }
.row { display: flex; align-items: center; }
.grow { flex: 1 1 0px; min-width: 0; }

.gbtn {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.25); border-radius: 14px;
  color: #fff; font-size: 15px; white-space: nowrap; padding: 0 14px; cursor: pointer;
  text-overflow: ellipsis;
}
.gbtn > .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gbtn.accent { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.gbtn:disabled { opacity: 1; }
.rip {
  position: absolute; border-radius: 50%; pointer-events: none; background: rgba(255,255,255,.28);
  transform: scale(0); transition: transform 320ms ease-out, opacity 260ms ease-out;
}

/* スライダー(Android SeekBar 風) */
.seek { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; margin: 4px 0 0; padding: 0 16px; }
.seek::-webkit-slider-runnable-track {
  height: 2px; border-radius: 1px;
  background: linear-gradient(to right, var(--accent) 0 var(--p, 50%), rgba(255,255,255,.3) var(--p, 50%) 100%);
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  margin-top: -7px; border: 0;
}
.seek::-moz-range-track { height: 2px; background: rgba(255,255,255,.3); }
.seek::-moz-range-progress { height: 2px; background: var(--accent); }
.seek::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 0; }

/* スイッチ(Android Switch 風) */
.sw { position: relative; width: 52px; height: 32px; flex: none; cursor: pointer; }
.sw .track { position: absolute; left: 9px; right: 9px; top: 9px; height: 14px; border-radius: 7px; background: rgba(255,255,255,.3); transition: background .15s; }
.sw .thumb {
  position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: #bdbdbd; box-shadow: 0 1px 3px rgba(0,0,0,.5); transition: transform .15s, background .15s;
}
.sw.on .track { background: color-mix(in srgb, var(--theme-accent) 50%, transparent); }
.sw.on .thumb { background: var(--theme-accent); transform: translateX(20px); }

/* 入力欄(Android EditText 風) */
.edit {
  background: transparent; border: 0; border-bottom: 1px solid rgba(255,255,255,.7); color: #fff;
  outline: none; border-radius: 0; padding: 8px 4px; width: 100%;
}
.edit:focus { border-bottom: 2px solid var(--theme-accent); padding-bottom: 7px; }
.edit::placeholder { color: rgba(255,255,255,.4); }

/* セグメント(端数処理) */
.seg { display: flex; height: 42px; margin-top: 8px; }
.seg > button {
  flex: 1 1 0px; margin: 0 2px; border-radius: 12px; font-size: 13px; white-space: nowrap;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2); color: #fff; cursor: pointer;
}
.seg > button.sel { background: color-mix(in srgb, var(--accent) 92%, transparent); border-color: transparent; color: var(--on-accent); }

.swatch { flex: 1 1 0px; height: 44px; margin: 0 3px; display: flex; justify-content: center; cursor: pointer; }
.swatch span { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; }
.swatch.sel span { border-color: #fff; }

/* 履歴 */
.hitem {
  position: relative; overflow: hidden; padding: 14px; margin-bottom: 10px; cursor: pointer;
  background: rgba(10,15,30,.6); border: 1px solid rgba(255,255,255,.15); border-radius: 18px;
}
.hitem .e { font-size: 14px; color: rgba(255,255,255,.7); text-align: right; white-space: nowrap; overflow: hidden; direction: rtl; text-overflow: ellipsis; }
.hitem .r { font-size: 28px; font-weight: 300; color: #fff; text-align: right; white-space: nowrap; overflow: hidden; direction: rtl; text-overflow: ellipsis; line-height: 1.3; }
.hitem bdi { unicode-bidi: isolate; direction: ltr; }

/* 換算 */
.amount { font-size: 34px; text-align: right; }
.result { font-size: 34px; text-align: right; padding: 10px 4px; white-space: nowrap; overflow: hidden; direction: rtl; text-overflow: ellipsis; min-height: 60px; }
.result bdi { unicode-bidi: isolate; direction: ltr; }
.center { text-align: center; }

/* ダイアログ(AlertDialog 風)・トースト */
.dlg-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: calc(var(--sat) + 24px) 24px calc(var(--sab) + 24px);
}
.dlg {
  background: #424242; border-radius: 4px; width: 100%; max-width: 560px; box-shadow: 0 12px 40px rgba(0,0,0,.6);
  display: flex; flex-direction: column; max-height: 100%;
}
.dlg .dt { font-size: 20px; font-weight: 500; padding: 24px 24px 8px; }
.dlg .dm { font-size: 16px; color: rgba(255,255,255,.75); padding: 20px 24px 8px; line-height: 1.4; }
.dlg .dbody { padding: 8px 16px 0; min-height: 0; display: flex; flex-direction: column; }
.dlg .dbtns { display: flex; justify-content: flex-end; padding: 8px; gap: 8px; }
.dlg .dbtns button {
  color: var(--theme-accent); font-size: 14px; font-weight: 500; padding: 0 12px; min-width: 64px; height: 36px;
  border-radius: 2px; position: relative; overflow: hidden; text-transform: uppercase; cursor: pointer;
}
.dlg .list { overflow-y: auto; -webkit-overflow-scrolling: touch; height: 360px; max-height: 50vh; margin: 0 -16px; }
.dlg .list button {
  display: block; width: 100%; text-align: left; min-height: 48px; padding: 0 24px; font-size: 16px;
  position: relative; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer;
}
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 64px); transform: translateX(-50%);
  background: rgba(50,50,50,.95); color: #fff; font-size: 14px; padding: 12px 18px; border-radius: 22px;
  z-index: 60; max-width: 86vw; text-align: center; transition: opacity .2s; pointer-events: none;
}

/* 切り出し */
#crop { background: #000; touch-action: none; }
#crop canvas { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
#crop .overlay { position: relative; flex: 1; display: flex; flex-direction: column; pointer-events: none; }
#crop .overlay > * { pointer-events: auto; }
#crop .top { display: flex; align-items: center; padding: 12px 12px 0; }
#crop .chint {
  flex: 1; font-size: 13px; color: #fff; background: rgba(0,0,0,.4); border-radius: 14px; padding: 8px 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,.8); line-height: 1.4;
}
#crop .pbtn { height: 38px; margin-left: 8px; font-size: 13px; background: rgba(0,0,0,.4); border-color: rgba(255,255,255,.33); }
#crop .spacer { flex: 1; pointer-events: none; }
#crop .panel {
  margin: 0 12px 12px; padding: 12px 16px 14px; border-radius: 22px;
  background: rgba(10,15,30,.7); border: 1px solid rgba(255,255,255,.2);
}
#crop .hidden { visibility: hidden; }

#measure { position: absolute; left: -10000px; top: 0; visibility: hidden; white-space: pre; }
