:root {
  --bg: #ffffff;
  --panel: #fff;
  --panel-alt: #f7f8fa;
  --border: #e5e8ef;
  --accent: #c0392b;
  --accent-soft: rgba(192, 57, 43, 0.55);
  --title: #1a2332;
  --text: #2c3a4f;
  --muted: #6b778c;
  --btn-from: #5b8def;
  --btn-to: #2f6fed;
  --gold: #2f6fed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stars {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: -1;
  pointer-events: none;
}

.top-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  box-shadow: none;
  flex: 0 0 auto;
}

.link-back {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  height: 2rem;
  padding: 0 0.65rem 0 0.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border-radius: 999px;
  border: 1px solid rgba(47, 111, 237, 0.28);
  background: #fff;
  flex: 0 0 auto;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.link-back-arrow {
  font-size: 1.05rem;
  line-height: 1;
}
.link-back:active {
  background: rgba(47, 111, 237, 0.1);
}

.readout {
  position: relative;
  min-width: 0;
  text-align: center;
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 auto;
  padding: 0.28rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(47, 111, 237, 0.2);
  box-shadow: 0 1px 3px rgba(140, 100, 40, 0.06);
  max-width: 100%;
}
.readout strong {
  color: var(--title);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.readout .deg {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 0.1rem 0.2rem 0.1rem 0.35rem;
  margin: 0;
  border-left: 1px solid rgba(192, 57, 43, 0.22);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.2;
}
.readout .deg:hover,
.readout .deg:focus-visible {
  background: rgba(192, 57, 43, 0.08);
  outline: none;
}

.deg-pop {
  position: absolute;
  left: 50%;
  top: calc(100% + 0.45rem);
  transform: translateX(-50%);
  z-index: 40;
  min-width: 11.5rem;
  padding: 0.55rem 0.65rem 0.6rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(47, 111, 237, 0.32);
  box-shadow: 0 10px 28px rgba(60, 40, 10, 0.16);
  text-align: left;
}
.deg-pop.hidden { display: none; }
.deg-pop-label {
  display: block;
  font-size: 0.72rem;
  color: #8a7355;
  margin-bottom: 0.35rem;
}
.deg-pop-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.deg-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 4.8rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(47, 111, 237, 0.35);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--title);
  background: #ffffff;
}
.deg-input:focus {
  outline: none;
  border-color: rgba(192, 57, 43, 0.55);
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.12);
}
.deg-unit {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}
.deg-ok {
  flex: 0 0 auto;
  padding: 0.32rem 0.65rem;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.btn.chip {
  border-radius: 999px;
  padding: 0.34rem 0.72rem;
  font-size: 0.76rem;
  border: 1px solid rgba(47, 111, 237, 0.28);
  background: #fff;
  color: var(--text);
  font-weight: 600;
}
.save-btn {
  border-color: rgba(47, 111, 237, 0.5);
  color: var(--gold);
  font-weight: 700;
  background: linear-gradient(180deg, #f7f8fa, #fff);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem 0.55rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: #f7f8fa;
  flex: 0 0 auto;
}

.toolbar-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem 0.4rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.toolbar-actions::-webkit-scrollbar {
  display: none;
  height: 0;
  width: 0;
}

.toolbar-opts {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 0.4rem 0.55rem;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(47, 111, 237, 0.12);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.toolbar-opts::-webkit-scrollbar {
  display: none;
  height: 0;
  width: 0;
}

.btn {
  appearance: none;
  border: 1px solid rgba(47, 111, 237, 0.28);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  white-space: nowrap;
  flex: 0 0 auto;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(180deg, var(--btn-from), var(--btn-to));
  box-shadow: 0 2px 6px rgba(47, 111, 237, 0.22);
}
.btn.ghost {
  background: #fff;
  color: var(--gold);
  border-color: rgba(47, 111, 237, 0.4);
}
.btn.soft {
  background: #fff;
  color: var(--muted);
  border-color: rgba(0, 0, 0, 0.1);
  font-weight: 600;
}
.btn.icon-btn {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: rgba(47, 111, 237, 0.4);
  color: var(--gold);
  background: #fff;
}
.btn.icon-btn svg {
  display: block;
}
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

.tool-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  color: #6b6358;
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
}
.tool-opacity {
  flex: 1 1 auto;
  min-width: 7.5rem;
}
.tool-field input[type="range"] {
  flex: 1 1 auto;
  width: auto;
  min-width: 56px;
  max-width: 120px;
  height: 4px;
  accent-color: var(--gold);
}
.tool-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  color: #6b6358;
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
  padding: 0.15rem 0.2rem;
}
.tool-check input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  accent-color: var(--gold);
}
.tool-year {
  flex: 0 0 auto;
  gap: 0.3rem;
}
.tool-year input[type="number"] {
  width: 3.6rem;
  padding: 0.22rem 0.3rem;
  border: 1px solid rgba(47, 111, 237, 0.32);
  border-radius: 8px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  -moz-appearance: textfield;
}
.tool-year input[type="number"]::-webkit-outer-spin-button,
.tool-year input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tool-year.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 280px;
  background: #ffffff;
  overflow: hidden;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* 与罗盘·理气汇总同一套加载面板样式 */
.load-panel {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.92);
  pointer-events: none;
}
.stage.is-loading .load-panel {
  display: flex;
}
.stage.is-loading .luopan-widget {
  opacity: 0;
  pointer-events: none;
}
.load-panel-card {
  width: min(280px, 86vw);
  padding: 1.15rem 1.2rem 1rem;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(47, 111, 237, 0.2);
  box-shadow:
    0 12px 30px rgba(26, 35, 50, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.85) inset;
  text-align: center;
}
.load-panel-title {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: #6a5a3a;
  letter-spacing: 0.02em;
}
.load-panel-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(47, 111, 237, 0.12) 0%, rgba(47, 111, 237, 0.06) 100%);
  box-shadow: inset 0 1px 2px rgba(120, 90, 40, 0.12);
}
.load-panel-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--load-pct, 8%);
  border-radius: inherit;
  background: linear-gradient(90deg, #7aa4f5 0%, #2f6fed 45%, #5b8def 100%);
  box-shadow: 0 0 12px rgba(47, 111, 237, 0.32);
  transition: width 0.14s ease-out;
  overflow: hidden;
}
.load-panel-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 0%,
    transparent 40%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 60%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: load-shine 1.15s linear infinite;
}
.load-panel-meta {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: #8a7350;
}
@keyframes load-shine {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.floor-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#floorImg {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
#floorImg.hidden { display: none; }

.luopan-widget {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(106vw, 106vh);
  height: min(106vw, 106vh);
  margin-left: calc(min(106vw, 106vh) / -2);
  margin-top: calc(min(106vw, 106vh) / -2);
  z-index: 4;
  transform-origin: 50% 50%;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.luopan-widget.is-locked .rotate-ring {
  opacity: 0.35;
}

.luopan-frame {
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  cursor: grab;
}
.luopan-frame:active { cursor: grabbing; }
.luopan-widget.is-locked .luopan-frame { cursor: default; }

.luopan-rotator {
  position: absolute;
  left: 2%;
  top: 2%;
  width: 96%;
  height: 96%;
  transform-origin: 50% 50%;
  z-index: 1;
}

.luopan-media {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  overflow: visible;
}

.luopan-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  /* 不接收指针：避免浏览器长按/拖图弹出「保存图片」 */
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* 贴图自带外框虚线：左上锚点正方形，尺寸由 JS 写入（与黑盘同一套标定） */
.luopan-dash {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 1.5px dashed rgba(200, 50, 50, 0.95);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 2;
}

/* 流年飞星：叠在虚线内九宫，外宫贴边，背景透明不挡字 */
.annual-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
  z-index: 3;
  box-sizing: border-box;
}
.annual-overlay.hidden {
  display: none;
}
.annual-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 1%;
}
/* 南上：外宫贴到九宫最外边，避开盘面文字 */
.annual-cell[data-palace="巽"] { align-items: flex-start; justify-content: flex-start; }
.annual-cell[data-palace="离"] { align-items: flex-start; justify-content: center; }
.annual-cell[data-palace="坤"] { align-items: flex-start; justify-content: flex-end; }
.annual-cell[data-palace="震"] { align-items: center; justify-content: flex-start; padding-left: 0; }
.annual-cell[data-palace="兑"] { align-items: center; justify-content: flex-end; padding-right: 0; }
.annual-cell[data-palace="艮"] { align-items: flex-end; justify-content: flex-start; }
.annual-cell[data-palace="坎"] { align-items: flex-end; justify-content: center; }
.annual-cell[data-palace="乾"] { align-items: flex-end; justify-content: flex-end; }
.annual-cell[data-palace="中"] { align-items: center; justify-content: center; }

.annual-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 0;
  font-size: clamp(0.68rem, 3.8vmin, 1rem);
  font-weight: 800;
  line-height: 1;
  color: #c0392b;
  background: transparent;
  box-shadow: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow:
    0 0 2px rgba(255, 255, 255, 0.95),
    0 0 4px rgba(255, 255, 255, 0.9),
    1px 0 0 rgba(255, 255, 255, 0.85),
    -1px 0 0 rgba(255, 255, 255, 0.85),
    0 1px 0 rgba(255, 255, 255, 0.85),
    0 -1px 0 rgba(255, 255, 255, 0.85);
}
.annual-cell.is-center .annual-star {
  font-size: clamp(0.78rem, 4.4vmin, 1.12rem);
}
/* 东西宫竖排，避免横写贴边被裁 */
.annual-cell[data-palace="震"] .annual-star,
.annual-cell[data-palace="兑"] .annual-star {
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 0.08em;
  line-height: 1.05;
}

.rotate-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  background: transparent;
}

.ring-hint {
  display: none;
}

.focus-bar {
  display: none;
}

body.is-focus .top-bar,
body.is-focus .toolbar {
  display: none !important;
}

body.is-focus .focus-bar {
  display: flex;
  position: fixed;
  left: 50%;
  bottom: calc(0.85rem + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  z-index: 30;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(47, 111, 237, 0.28);
  box-shadow: 0 8px 28px rgba(60, 40, 10, 0.16);
  backdrop-filter: blur(8px);
}

body.is-focus .stage-wrap {
  flex: 1 1 auto;
}

body.is-focus .stage {
  min-height: 100%;
}

.help-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.help-mask.hidden { display: none; }
.help-card {
  width: min(360px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.help-card h2 {
  font-size: 1.05rem;
  color: var(--title);
  margin-bottom: 0.7rem;
}
.help-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}
.help-card b { color: var(--accent); font-weight: 700; }
.help-card .btn { width: 100%; }

.compass-card { width: min(480px, 100%); }
.compass-color-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.75rem;
  flex-wrap: wrap;
}
.compass-color-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #8a7355;
  margin-right: 0.15rem;
}
.compass-color-btn {
  appearance: none;
  border: 1px solid rgba(47, 111, 237, 0.32);
  background: #fff;
  color: var(--title);
  border-radius: 999px;
  padding: 0.32rem 0.85rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.compass-color-btn.is-active {
  border-color: var(--btn-to);
  background: linear-gradient(180deg, #f7f8fa, #fff);
  box-shadow: 0 0 0 2px rgba(47, 111, 237, 0.18);
  color: #8b5a2b;
}
.compass-color-btn[data-color="red"].is-active {
  color: #c0392b;
  border-color: rgba(192, 57, 43, 0.45);
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.15);
}
.compass-pick-list {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.45rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(47, 111, 237, 0.5) rgba(47, 111, 237, 0.08);
}
.compass-pick-list::-webkit-scrollbar {
  height: 5px;
}
.compass-pick-list::-webkit-scrollbar-track {
  background: rgba(47, 111, 237, 0.08);
  border-radius: 999px;
  margin: 0 0.2rem;
}
.compass-pick-list::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #5b8def, #2f6fed);
  border-radius: 999px;
}
.compass-pick-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #4a7fe0, #1d4ed8);
}
.compass-pick {
  appearance: none;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0.55rem 0.45rem 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  flex: 0 0 8.4rem;
  min-width: 8.4rem;
}
.compass-pick img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  pointer-events: none;
  /* 浅色底衬，避免透明/黑底缩略图发脏 */
  background:
    radial-gradient(circle at 50% 48%, #ffffff 0%, #f4f6fa 62%, #e8ecf4 100%);
  min-height: 5.5rem;
  box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.1);
}
.compass-pick.is-active {
  border-color: var(--btn-to);
  box-shadow: 0 0 0 2px rgba(47, 111, 237, 0.22);
}
.compass-pick span {
  color: var(--title);
  white-space: nowrap;
  text-align: center;
  line-height: 1.2;
}

.save-card { width: min(520px, 100%); }
.save-card h2 {
  margin-bottom: 0.65rem;
}
.save-title-hint {
  margin-left: 0.28rem;
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent, #c0392b);
  vertical-align: baseline;
}
.save-preview-wrap {
  position: relative;
  margin-bottom: 0.85rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #ffffff;
}
.save-preview {
  display: block;
  width: 100%;
  max-height: min(55vh, 420px);
  object-fit: contain;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
}
.save-hold-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 88px;
  height: 88px;
  margin: 0;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #f5c518;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
  opacity: 1;
  transition: opacity 0.35s ease;
}
.save-hold-hint.is-faded {
  opacity: 0;
}
.save-hold-rings {
  position: absolute;
  inset: 0;
  display: block;
}
.save-hold-rings i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 2px solid rgba(245, 197, 24, 0.9);
  box-sizing: border-box;
  animation: save-hold-ring 1.8s ease-out infinite;
}
.save-hold-rings i:nth-child(2) { animation-delay: 0.45s; }
.save-hold-rings i:nth-child(3) { animation-delay: 0.9s; }
@keyframes save-hold-ring {
  0% { transform: scale(0.55); opacity: 0.9; }
  70% { transform: scale(2.05); opacity: 0; }
  100% { transform: scale(2.05); opacity: 0; }
}
.save-hold-hand {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 46px;
  animation: save-hold-press 1.8s ease-in-out infinite;
}
.save-hold-dot {
  opacity: 0.95;
}
@keyframes save-hold-press {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(3px) scale(0.92); }
  55% { transform: translateY(3px) scale(0.92); }
}
.save-actions {
  display: flex;
  gap: 0.55rem;
}
.save-actions .btn {
  flex: 1 1 0;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}
#saveDownload.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12000;
  max-width: min(90vw, 360px);
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  background: rgba(40, 36, 30, 0.9);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}
.toast.hidden { display: none; }

@media (max-width: 720px) {
  .top-bar {
    gap: 0.4rem;
    padding: 0.42rem 0.55rem;
  }
  .link-back {
    font-size: 0.72rem;
    padding: 0 0.5rem 0 0.3rem;
  }
  .readout {
    padding: 0.22rem 0.5rem;
  }
  .readout strong { font-size: 0.86rem; letter-spacing: 0.03em; }
  .readout .deg { font-size: 0.82rem; }
  .toolbar {
    gap: 0.35rem;
    padding: 0.4rem 0.55rem 0.45rem;
  }
  .toolbar-actions {
    gap: 0.28rem;
  }
  .btn:not(.chip) {
    padding: 0.34rem 0.58rem;
    font-size: 0.74rem;
  }
}
