:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: #171a18;
  color: #eef0eb;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: auto;
  background: #171a18;
}

body {
  min-height: 100vh;
  background-color: #171a18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 28px 28px;
}

.workspace {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 4px;
}

.quick-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 8;
  margin-bottom: 2px;
}
.quick-action {
  appearance: none;
  border: 1px solid rgba(185, 198, 188, .25);
  border-radius: 999px;
  padding: 9px 16px 9px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #edf3ec;
  background: rgba(36, 44, 39, .9);
  box-shadow: 0 7px 18px rgba(0,0,0,.2), inset 0 1px rgba(255,255,255,.08);
  font: 600 13px/1 "Microsoft YaHei UI", sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.quick-action:hover { transform: translateY(-2px); background: #303c35; border-color: rgba(219,236,220,.55); }
.quick-action-icon { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #152019; background: #b9d6bd; font-size: 16px; }
.quick-action-svg { border-radius: 7px; }
.quick-action-svg svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.quick-action-buy .quick-action-icon { background: #e5bd71; }

.contact-modal[hidden] { display: none; }
.contact-modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; }
.contact-backdrop { position: absolute; inset: 0; background: rgba(7, 11, 9, .72); backdrop-filter: blur(7px); }
.contact-dialog { position: relative; width: min(450px, 100%); padding: 28px 24px 24px; border: 1px solid rgba(220, 239, 220, .18); border-radius: 24px; color: #eaf1ea; background: linear-gradient(145deg, #26342c, #18211c 70%); box-shadow: 0 28px 80px rgba(0,0,0,.55); animation: contact-in .24s ease-out; }
@keyframes contact-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.contact-close { position: absolute; top: 13px; right: 16px; border: 0; background: transparent; color: #c7d3c9; font-size: 28px; line-height: 1; cursor: pointer; }
.contact-kicker { color: #b9d6bd; letter-spacing: .18em; font-size: 10px; font-weight: 700; }
.contact-dialog h2 { margin: 7px 0 4px; font: 700 27px/1.15 "Microsoft YaHei UI", sans-serif; }
.contact-subtitle { margin: 0 0 18px; color: #9eafa2; font-size: 13px; }
.contact-cards { display: grid; gap: 10px; }
.contact-card { display: flex; align-items: center; gap: 15px; min-height: 82px; padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.065); }
.contact-brand-icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(255,255,255,.13); }
.contact-brand-icon svg { width: 35px; height: 35px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.contact-wechat { color: #8ee0a2; } .contact-douyin { color: #8ed5ee; } .contact-redbook { color: #ff9b9b; }
.contact-card strong { display: block; margin-bottom: 5px; color: #f3f7f3; font-size: 16px; }
.contact-card span:not(:first-child) { display: block; color: #a9b7ac; font-size: 11px; line-height: 1.35; }
@media (max-width: 520px) { .quick-actions { gap: 6px; } .quick-action { padding: 8px 9px 8px 7px; gap: 5px; font-size: 11px; } .quick-action-icon { width: 20px; height: 20px; } .contact-dialog { padding: 25px 16px 18px; } }

.calculator-shell {
  position: relative;
  width: min(520px, calc(100vw - 12px), calc((100vh - 12px) * 0.6058));
  aspect-ratio: 650 / 1073;
  flex: none;
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.5));
  user-select: none;
  -webkit-user-select: none;
  background: #151a17 url("./fx991ex-interface.png?v=20260822-ios-fallback") center / 100% 100% no-repeat;
}

.calculator-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  image-rendering: auto;
}

/* Safari only opens a file chooser from a user gesture when the input exists
   in the rendered document. Keep it invisible without using display:none. */
.file-picker {
  position: fixed;
  width: 1px;
  height: 1px;
  left: -10px;
  top: -10px;
  opacity: 0;
  pointer-events: none;
}

.lcd-canvas {
  position: absolute;
  left: 19.7%;
  top: 15.38%;
  width: 61.55%;
  height: 14.82%;
  image-rendering: pixelated;
  background: transparent;
  z-index: 2;
  border-radius: 4.2% / 15%;
  clip-path: inset(0 round 4.2% / 15%);
  overflow: hidden;
}

.ai-screen {
  position: absolute;
  left: 19.7%;
  top: 15.38%;
  width: 61.55%;
  height: 14.82%;
  z-index: 4;
  overflow: hidden;
  background: #d1ddd0;
  color: #17221a;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.34;
  letter-spacing: 0;
  container-type: inline-size;
  border-radius: 4.2% / 15%;
  clip-path: inset(0 round 4.2% / 15%);
}

.ai-screen[hidden] { display: none; }

.ai-lcd-page {
  height: 100%;
  padding: 1.6% 5.2% 1.2%;
  display: grid;
  grid-template-rows: 14% 29% 29% 28%;
  overflow: hidden;
  font-family: "Noto Serif CJK SC", "Songti SC", "SimSun", serif;
  font-weight: 600;
  text-align: left;
}

.ai-statusline {
  display: flex;
  justify-content: center;
  align-items: start;
  gap: 7%;
  padding-top: 1%;
  font-family: "Times New Roman", serif;
  font-size: 4.6cqw;
  line-height: 1;
}

.ai-lcd-row {
  display: flex;
  align-items: center;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  line-height: 1;
}

.ai-lcd-title {
  font-size: 7.1cqw;
}

.ai-lcd-primary {
  font-size: 6.6cqw;
}

.ai-lcd-hint {
  font-size: 5.3cqw;
  font-weight: 500;
}

.ai-activation-page {
  grid-template-rows: 14% 29% 28.5% 28.5%;
}

.activation-code {
  font-family: "Courier New", monospace;
  font-size: 6.1cqw;
  letter-spacing: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.answer-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  scrollbar-width: none;
  background: #c5d5c5;
}

.answer-scroll::-webkit-scrollbar { display: none; }
.answer-scroll img { display: block; width: 100%; height: auto; }

.key-layer { position: absolute; inset: 0; z-index: 5; }

.calc-key {
  position: absolute;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  outline: none;
  background: transparent;
  color: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  clip-path: inset(0 round 18%);
}

/* Match the four physical navigation-pad facets rather than leaving one
   large rectangular hit area across the whole pad. */
.calc-key.direction-left,
.calc-key.direction-right { clip-path: polygon(42% 0, 100% 18%, 100% 82%, 42% 100%, 0 50%); }
.calc-key.direction-right { clip-path: polygon(0 18%, 58% 0, 100% 50%, 58% 100%, 0 82%); }
.calc-key.direction-up,
.calc-key.direction-down { clip-path: polygon(18% 100%, 0 42%, 50% 0, 100% 42%, 82% 100%); }
.calc-key.direction-down { clip-path: polygon(0 58%, 18% 0, 82% 0, 100% 58%, 50% 100%); }
.calc-key.round-key {
  border-radius: 50%;
  clip-path: circle(46% at 50% 50%);
}

.calc-key:hover { background: rgba(255, 255, 255, 0.07); }
.calc-key:active, .calc-key.is-pressed { background: rgba(75, 140, 255, 0.2); }
.calc-key:focus-visible { outline: 2px solid rgba(255, 230, 90, 0.95); }
.photo-picker-trigger { z-index: 6; }
.hitbox-editable { outline: 1px dashed #00e5ff; background: rgba(0, 220, 255, 0.12); cursor: move; }
.hitbox-selected { outline: 2px solid #ffdf45; background: rgba(255, 220, 50, 0.28); }
.hitbox-editor-tip { position: fixed; z-index: 20; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 8px 12px; color: #111; background: #ffe36a; border-radius: 6px; font: 13px monospace; white-space: nowrap; }

/* First-use walkthrough: the next physical key gently flashes without
   changing the calculator artwork or enlarging the hitbox. */
.tutorial-pulse {
  animation: tutorial-key-pulse 0.9s ease-in-out infinite;
  border-radius: 18%;
}
@keyframes tutorial-key-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 224, 72, 0); background: rgba(255, 224, 72, 0); }
  50% { box-shadow: 0 0 0 5px rgba(255, 184, 0, 1), 0 0 18px rgba(255, 170, 0, 0.9); background: rgba(255, 190, 0, 0.52); }
}

.startup-state {
  min-height: 20px;
  margin: 0;
  color: #c5cbc1;
  font-size: 13px;
  letter-spacing: 0;
}

.startup-state.ready { visibility: hidden; }
.startup-state.error { color: #ffb4a7; }

@media (max-height: 680px) { .workspace { align-content: start; } }
