/* ========== Time Beat Web · base.css ========== */
/* 设计令牌与 iOS AppTheme 对齐 */

:root {
  --bg: #000000;
  --primary: #0bffb3;
  --secondary: #1a1a2e;
  --perfect: #ffd700;
  --master: #0bffb3;
  --expert: #4fc3f7;
  --good: #aaaaaa;
  --miss: #ff3b3b;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --early: #ff9500;
  --late: #ffd60a;

  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --screen-w: 440px;
  --nav-h: 52px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button,
input {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  outline: none;
}

button {
  cursor: pointer;
}

ul,
li {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============ 应用容器：移动端竖屏优先，桌面 440 居中 ============ */
#app {
  position: relative;
  width: 100%;
  max-width: var(--screen-w);
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

/* ============ 屏幕与转场 ============ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ============ 通用导航栏（返回 + 居中标题） ============ */
.nav-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 20px 12px;
  flex-shrink: 0;
}

.nav-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.nav-btn:active {
  opacity: 0.5;
}

.nav-btn.placeholder {
  visibility: hidden;
}

.nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  font-weight: 700;
  bottom: 16px;
}

.nav-icon {
  width: 22px;
  height: 22px;
}

/* ============ 主按钮 ============ */
.btn-primary {
  width: 220px;
  height: 70px;
  border-radius: 35px;
  background: var(--primary);
  color: var(--bg);
  font-size: 28px;
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-primary.breathing {
  animation: breathe 1.2s ease-in-out infinite;
}

.btn-primary.small {
  width: 200px;
  height: 56px;
  border-radius: 28px;
  font-size: 20px;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* ============ 菊花 ============ */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(11, 255, 179, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.small {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============ 胶囊标签 ============ */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

/* ============ 列表行 ============ */
.list-row {
  background: var(--secondary);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

/* ============ 半屏弹层 ============ */
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 50;
}

.sheet-mask.active {
  opacity: 1;
  visibility: visible;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #12121c;
  border-radius: 20px 20px 0 0;
  padding: 0 16px calc(var(--safe-bottom) + 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.3, 1);
  z-index: 51;
  max-height: 80%;
  display: flex;
  flex-direction: column;
}

.sheet-mask.active .sheet {
  transform: translateY(0);
}

.sheet-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
}

.sheet-nav .title {
  font-size: 16px;
  font-weight: 700;
}

.sheet-nav .action {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.sheet-nav .cancel {
  font-size: 16px;
  color: var(--text-secondary);
}

.text-input {
  width: 100%;
  background: var(--secondary);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text-primary);
}

.text-input::placeholder {
  color: var(--text-secondary);
}

.text-input:focus {
  box-shadow: inset 0 0 0 1.5px rgba(11, 255, 179, 0.5);
}

/* ============ Toast ============ */
#toast-host {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 90px);
  transform: translateX(-50%);
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(26, 26, 46, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateY(8px);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============ iOS 风格开关 ============ */
.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: #3a3a4a;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toggle.on {
  background: var(--primary);
}

.toggle.on::after {
  transform: translateX(20px);
}

/* ============ 空态 ============ */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  width: 60px;
  height: 60px;
  color: var(--text-secondary);
  opacity: 0.6;
}

.empty-state .empty-text {
  font-size: 15px;
  color: var(--text-secondary);
}

.error-text {
  font-size: 11px;
  color: var(--miss);
  text-align: center;
  line-height: 1.5;
  word-break: break-word;
}

.btn-retry-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--miss);
  border: 1px solid rgba(255, 59, 59, 0.5);
  border-radius: 999px;
  padding: 6px 14px;
}

.btn-retry-mini:active {
  background: rgba(255, 59, 59, 0.12);
}

.center-spinner {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
