/**
 * 家长中心样式 — 移动优先，与官网落地页（playmusekey.com）同一套设计语言
 *
 * 基调：奶油底 + 深紫描边卡片 + 粉色主按钮（硬阴影按压感），标题 Fredoka / 正文 Nunito。
 * 使用场景：Shopify 站内 iframe 嵌入（playmusekey.com），也可直接访问静态页。
 * 约束：禁止横向滚动、适配安全区、按钮触达 ≥ 44px；点歌跳转独立播放页（play.musekey.ai/s/{id}）听歌，页内不再内嵌播放器。
 */

:root {
  --ink: #241751;            /* 深紫：文字与描边主色（与落地页一致） */
  --ink-soft: #6f679e;       /* 次级文字：深紫的柔和变体 */
  --bg: #fff4e4;             /* 奶油底色（落地页 page background） */
  --surface: #ffffff;
  --line-soft: rgba(36, 23, 81, .16);
  --pink: #ff5c93;           /* 主按钮 */
  --pink-soft: #ffe3ee;
  --sun: #ffc53d;            /* 品牌黄 */
  --sun-soft: #fff3d0;
  --mint: #1fd1a2;
  --mint-soft: #e0f9f1;
  --danger: #d81b60;
  --shadow: 3px 3px 0 var(--ink);   /* 硬阴影：落地页按钮同款 */
  --radius: 18px;           /* 卡片大圆角（.device/.bind-block/.empty） */
  --font-display: 'Fredoka', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }

/* hidden 属性必须能压过本文件的 display 声明：
   作者样式表会覆盖 UA 的 [hidden]{display:none}，否则 .view/.otp-block 上的
   display:flex 会让 hidden 元素照样显示（登录页会同时冒出设备列表）。*/
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: #ffffff;              /* 框外纯白，与 Shopify 宿主页面融合 */
  color: var(--ink);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 60px 18px 24px;   /* 顶部让位听筒装饰 */
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== 手机框展示形态 =====
   桌面端：功能 UI 装在深紫外壳里，屏幕区固定高度内部滚动，更像真机预览；
   真机小屏（≤480px）去框全屏，播放器 sticky 贴视口底。 */

.phone {
  /* 宽 = min(460, 宿主列宽, 由视口高反推的等比宽)：矮视口整套等比缩小，壳完整可见、免页面滚动 */
  width: min(460px, 100%, calc((100vh - 56px) * 9 / 19));
  width: min(460px, 100%, calc((100dvh - 56px) * 9 / 19));
  aspect-ratio: 9 / 19;             /* 全面屏手机比例：高 = 宽 × 19/9（460 → 971） */
  margin: 28px auto;
  padding: 14px;
  position: relative;
  background: var(--ink);
  border-radius: 46px;
  box-shadow: 8px 10px 0 rgba(36, 23, 81, .18);
}

.phone-notch {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 22px;
  background: var(--ink);
  border-radius: 999px;
  z-index: 10;
}

.phone-screen {
  /* 高度由外壳 9:19 比例决定（screen = 框高 − 上下 padding） */
  height: 100%;
  border-radius: 34px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  scrollbar-width: none;            /* Firefox：隐藏滚动条更像手机 */
}

.phone-screen::-webkit-scrollbar { width: 0; }  /* Chrome/Safari：同上 */

.phone-screen .app { max-width: none; }

/* 真手机访问：去框全屏。由 parent.js 检测 UA+触摸后给根元素加 .on-phone 类；
   不用媒体宽度判断——iframe 场景下视口宽度是宿主列宽，不代表设备。 */
html.on-phone,
html.on-phone body { background: var(--bg); }   /* 真机全屏回归奶油底 */

.on-phone .phone {
  width: 100%;
  aspect-ratio: auto;               /* 解除比例锁定，高度随内容 */
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.on-phone .phone-notch { display: none; }

.on-phone .phone-screen {
  height: auto;
  min-height: 100vh;
  max-height: none;                 /* 真机不受展示上限约束 */
  border-radius: 0;
  overflow: visible;
}

.on-phone .app { padding-top: 20px; }

/* ===== 品牌 ===== */

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: .01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--sun);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.brand-mark svg { width: 18px; height: 18px; }

.brand .link-btn { margin-left: auto; }

/* ===== 文字 ===== */

.h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  margin: 4px 0 0;
}

.h2 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.muted { color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; margin: 0; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

/* 标题行右侧动作区：绑定入口 + 刷新并排 */
.head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* 绑定设备折叠块：白卡 + 深紫描边，与设备/歌曲卡片同视觉 */
.bind-block {
  margin: 10px 0 4px;
  padding: 16px 14px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.bind-hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.msg {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line-soft);
  border-radius: 14px;
  padding: 10px 14px;
}

.msg.error { color: var(--danger); border-color: var(--pink); background: var(--pink-soft); }
.msg.ok { color: #0b7f63; border-color: var(--mint); background: var(--mint-soft); }

/* ===== 表单 ===== */

.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 16px;                    /* ≥16px 避免 iOS 聚焦自动缩放 */
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 14px;
  outline: none;
}

.field input::placeholder { color: var(--ink-soft); opacity: .6; }

.field input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px var(--pink-soft);
}

.otp-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#otpInput { letter-spacing: .3em; text-align: center; font-weight: 800; }

.btn {
  min-height: 50px;
  padding: 0 20px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--sun);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}

.btn:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

.btn.primary {
  color: #fff;
  background: var(--pink);
}

.btn.primary[disabled] {
  opacity: .55;
  cursor: default;
  transform: none;
  box-shadow: var(--shadow);
}

.link-btn {
  min-height: 32px;
  padding: 0 4px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--pink);
  font-family: inherit;
}

.link-btn.center { align-self: center; }

/* ===== 设备列表 ===== */

.who {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  word-break: break-all;
}

.device-list, .song-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.device {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  transition: transform .06s ease, box-shadow .06s ease;
}

.device:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }

.device[aria-pressed="true"] {
  background: var(--sun-soft);
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.device-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line-soft);
  border: 2px solid var(--ink);
}

.device-dot.on { background: var(--mint); }

.device-body { min-width: 0; flex: 1 1 auto; }

.device-name {
  font-weight: 800;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-meta {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 歌曲列表 ===== */

.song {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  transition: transform .06s ease, box-shadow .06s ease;
}

.song:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }

.song-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sun);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.song-body { min-width: 0; flex: 1 1 auto; }

.song-title {
  font-size: 15px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-meta { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }

.empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.7;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 2px dashed var(--line-soft);
  border-radius: var(--radius);
}

/* ===== 歌曲行操作（删除） ===== */

.song-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 2px;
}

.icon-act {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.icon-act svg { width: 19px; height: 19px; display: block; }

.icon-act:hover { background: var(--sun-soft); }
.icon-act:active { background: var(--pink-soft); }
.icon-act[disabled] { opacity: .45; cursor: default; }

/* 点赞：未赞空心描边、已赞实心粉色（模板 path 自带 stroke，on 态改 fill） */
.icon-act-like.on { color: var(--pink); }
.icon-act-like.on svg path { fill: currentColor; stroke: none; }

.icon-act-del { color: var(--ink-soft); }
.icon-act-del:hover { background: var(--pink-soft); color: var(--danger); }

.song:focus-visible, .icon-act:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}

/* ===== 确认弹窗（破坏性操作，居中卡片覆盖整屏） ===== */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36, 23, 81, .45);
}

.modal {
  width: min(340px, 100%);
  padding: 20px 18px 16px;
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--ink);
}

.modal-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.modal-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.modal-warn {
  margin: 10px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 700;
  color: var(--danger);
  background: var(--pink-soft);
  border: 2px solid var(--pink);
  border-radius: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn { min-height: 44px; padding: 0 18px; font-size: 15px; }

.btn.ghost { background: var(--surface); }

.btn.danger { color: #fff; background: var(--danger); }

/* ===== 轻提示（非阻塞 Toast，自动淡出） ===== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(36, 23, 81, .3);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ===== 商店（入口 banner + 商品卡） ===== */

.shop-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: var(--sun-soft);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.shop-banner-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}

.shop-banner-sub {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.shop-banner .btn {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  font-size: 14px;
}

.shop-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 18px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.shop-shot {
  border: 2px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  background: #fff4e4;   /* 与商品图底色一致：留白区不突兀 */
}

.shop-shot img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.shop-card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}

.shop-card-desc { font-size: 13px; }

.shop-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.shop-price {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1;
}

.shop-compare {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.shop-badge {
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #0b7f63;
  background: var(--mint-soft);
  border: 2px solid var(--mint);
  border-radius: 999px;
}

.buy-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.buy-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--line-soft);
  border-radius: 14px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}

.buy-option:hover { border-color: var(--ink); }

.buy-option[aria-pressed="true"] {
  background: var(--sun-soft);
  border-color: var(--ink);
  box-shadow: var(--shadow);
}

.buy-option-price { font-family: var(--font-display); font-weight: 600; }

.buy-option:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 2px;
}

/* 购买用 <a> 走 .btn 样式：补 flex 居中与去下划线 */
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}

a.btn.block { width: 100%; }

.shop-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  text-align: center;
}

@media (min-width: 620px) {
  .phone { margin: 36px auto; }
}
