/* 通用零件：按钮、面板、徽章、轻提示、对话框、状态页、底部导航、发音按钮。 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 22px;
  border: 0; border-radius: var(--r-md);
  font-weight: 800; font-size: 17px; letter-spacing: .02em;
  background: var(--btn); color: #fff;
  box-shadow: 0 5px 0 var(--btn-deep);
  transition: transform .08s, box-shadow .08s, filter .15s, background .15s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--btn-deep); }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: 0 5px 0 color-mix(in srgb, var(--line) 80%, #000); }
.btn-block { display: flex; width: 100%; }
.btn-ok { background: #0E9C8B; box-shadow: 0 5px 0 #0A7468; }
.btn-ok:active:not(:disabled) { box-shadow: 0 1px 0 #0A7468; }
.btn-danger { background: #D93A48; box-shadow: 0 5px 0 #A82634; }
.btn-danger:active:not(:disabled) { box-shadow: 0 1px 0 #A82634; }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 2px var(--line) inset, 0 4px 0 var(--line); }
.btn-ghost:active:not(:disabled) { box-shadow: 0 0 0 2px var(--line) inset, 0 1px 0 var(--line); }
.btn-small { min-height: 44px; padding: 8px 16px; font-size: 15px; }

.icon-btn {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 20px; font-weight: 700;
}
.icon-btn:active { background: var(--soft); }

.panel { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }

.chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip-compound { background: var(--sun-soft); color: var(--sun-deep); }

.mascot { display: block; width: 96px; height: 96px; }

/* 轻提示 */
#toasts {
  position: fixed; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%);
  z-index: 60; width: min(440px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 600;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5);
  animation: rise .25s both;
}
.toast-ok { background: #0A7468; color: #fff; }
.toast-warn { background: #8A5A0A; color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity .3s, transform .3s; }

/* 对话框 */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; padding-bottom: calc(16px + var(--safe-b)); background: rgba(15, 17, 35, .55);
}
.dialog {
  width: 100%; max-width: 440px; padding: 22px 20px 18px; border-radius: var(--r-lg);
  background: var(--surface); animation: rise .22s both;
}
.dialog-title { font-size: 20px; font-weight: 800; }
.dialog-text { margin-top: 6px; color: var(--muted); }
.dialog-actions { display: grid; gap: 12px; margin-top: 18px; }
@media (min-width: 520px) { .overlay { align-items: center; } }

/* 加载 / 空 / 出错 */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 70dvh; padding: 32px 24px; text-align: center;
}
.state-title { font-size: 22px; font-weight: 800; }
.state-text { color: var(--muted); max-width: 30em; }
.state-emoji { font-size: 56px; line-height: 1; }
.state-mascot { width: 128px; height: 128px; animation: bob 2.6s ease-in-out infinite; }
.state-actions { display: grid; gap: 12px; width: 100%; max-width: 320px; margin-top: 14px; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 5px solid var(--line); border-top-color: var(--btn);
  animation: spin360 .8s linear infinite;
}

/* 底部导航 */
#tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 30;
  width: 100%; max-width: 480px; height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 2px solid var(--line);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 48px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700;
}
.tab-ico { font-size: 22px; line-height: 1.2; filter: grayscale(.7); opacity: .75; transition: transform .15s; }
.tab.is-active { color: var(--brand); }
.tab.is-active .tab-ico { filter: none; opacity: 1; transform: translateY(-2px) scale(1.12); }
.tab.is-active::before { content: ""; position: absolute; top: -2px; width: 36px; height: 4px; border-radius: 0 0 4px 4px; background: var(--btn); }
.tab-badge {
  position: absolute; top: 5px; left: calc(50% + 8px); min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #D93A48; color: #fff; font-size: 12px; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

/* 发音按钮：没有瑞典语语音时整体隐藏 */
.speak-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--brand-soft) 78%, #000);
  transition: transform .08s;
}
.speak-btn:active { transform: translateY(2px); }
.speak-ico { font-size: 20px; line-height: 1; }
.speak-sm { box-shadow: none; }
.speak-sm .speak-ico { font-size: 18px; }
.speak-lg { width: 56px; height: 56px; background: var(--btn); box-shadow: 0 4px 0 var(--btn-deep); }
.speak-lg .speak-ico { font-size: 26px; }
.speak-xl { width: 104px; height: 104px; border-radius: 32px; background: var(--btn); box-shadow: 0 7px 0 var(--btn-deep); }
.speak-xl .speak-ico { font-size: 48px; }
.speak-btn.is-speaking .speak-ico { animation: pop .45s; }
:root[data-voice="no"] .speak-btn { display: none; }

/* 普通页面骨架 */
.page { padding: calc(18px + var(--safe-t)) 16px 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page-center { min-height: 100dvh; align-content: center; }
.page-title { font-size: 28px; font-weight: 900; letter-spacing: .01em; }
.page-sub { color: var(--muted); margin-top: 2px; }
.sec-title { font-size: 15px; font-weight: 800; color: var(--muted); margin-top: 6px; letter-spacing: .06em; }

.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 14px; color: #fff; font-weight: 800; font-size: 18px; background: var(--c2);
}
.avatar-0 { background: #4C5FE0; } .avatar-1 { background: #0E9C8B; } .avatar-2 { background: #D07F00; }
.avatar-3 { background: #8457E8; } .avatar-4 { background: #D8508F; }
.avatar-big { width: 72px; height: 72px; border-radius: 24px; font-size: 34px; background: #4C5FE0; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tiles-4 { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tiles-2 { grid-template-columns: repeat(2, 1fr); }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px;
  border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--line); text-align: center; min-width: 0;
}
.tile-ico { font-size: 22px; line-height: 1.2; }
.tile-value { font-size: 20px; font-weight: 900; font-family: var(--font-round); white-space: nowrap; }
.tile-label { font-size: 12px; color: var(--muted); font-weight: 600; }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }
.dev-list { display: grid; gap: 4px; }
.dev-list a { display: block; padding: 10px 0; }
