*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--surface-muted);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  overscroll-behavior-y: none;
}

.hidden {
  display: none !important;
}

.app-root {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.app-header-title {
  font-size: 17px;
  font-weight: 700;
}

.app-header-back {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px 4px 0;
}

.app-main {
  min-height: calc(100dvh - var(--header-h));
  padding: 16px;
  padding-bottom: calc(16px + var(--tabbar-h) + var(--safe-bottom));
}

.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  z-index: 100;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
}

.tab-item.active {
  color: var(--primary);
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-elevated {
  box-shadow: var(--shadow-md);
}

.card + .card {
  margin-top: 12px;
}

.hero-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-sub {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.section-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.section-desc {
  margin: -8px 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  margin-top: 10px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  min-height: 40px;
  font-size: 14px;
}

.btn-sm {
  min-height: 36px;
  font-size: 14px;
  width: auto;
  padding: 0 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: var(--primary-soft); color: #047857; }
.badge-warn { background: var(--warn-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
.badge-info { background: var(--info-soft); color: #1d4ed8; }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
}

.alert-warn {
  background: var(--warn-soft);
  color: #92400e;
}

.alert-info {
  background: var(--info-soft);
  color: #1e40af;
}

.alert p {
  margin: 6px 0 0;
}

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.login-page {
  padding: 24px 16px;
  display: flex;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 240px;
  margin-bottom: 8px;
}

.qr-host {
  width: 220px;
  min-height: 220px;
}

.status-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.status-text.error {
  color: var(--danger);
}

.footer-note {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  word-break: break-all;
}

.result-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
}

.result-icon.success {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.result-icon.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
}

.avatar-lg {
  width: 64px;
  height: 64px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

textarea.input,
input.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  resize: vertical;
}

textarea.input:focus,
input.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.sticky-footer {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  z-index: 90;
}

.no-tabbar .app-main {
  padding-bottom: calc(80px + var(--safe-bottom));
}

.no-tabbar .sticky-footer {
  bottom: var(--safe-bottom);
}

/* 设备自适应：桌面默认宽屏审查台；≤768px 为移动 Tab 布局 */
html[data-device="desktop"] .app-root {
  max-width: none;
  margin: 0;
}

html[data-device="desktop"] .app-root:not(.review-mode) .app-main {
  max-width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  width: 100%;
}

html[data-device="desktop"] .app-header {
  max-width: none;
}

html[data-device="desktop"] .app-tabbar {
  max-width: min(960px, 100%);
}

html[data-device="desktop"] .task-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

html[data-device="mobile"] .app-root {
  max-width: 480px;
  margin: 0 auto;
}
