:root {
  --bg-main: #0d0f17;
  --bg-card: #161926;
  --bg-elevated: #1f2437;
  --border-color: rgba(255, 255, 255, 0.09);
  --text-main: #f1f3f9;
  --text-muted: #949bb0;
  --accent: #7c5cff;
  --accent-hover: #9176ff;
  --accent-cyan: #00d4ff;
  --danger: #ff4d6a;
  --success: #2dd4bf;
  --warn: #fbbf24;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}

/* F31: 禁止长按图片和视频弹出「存储到照片」 */
.no-callout,
img,
video {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none;
}

input,
textarea,
select {
  -webkit-user-select: text !important;
  user-select: text !important;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

.hidden {
  display: none !important;
}

/* 全屏引导、设密、锁屏页 */
.full-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: radial-gradient(circle at top, #1d2136 0%, var(--bg-main) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.app-logo {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  margin-bottom: 8px;
}

.lock-icon {
  font-size: 42px;
  margin-bottom: 6px;
}

.auth-card h1 {
  margin: 4px 0 6px;
  font-size: 20px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 18px;
}

.install-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.step-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-elevated);
  padding: 11px 12px;
  border-radius: var(--radius-md);
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-item p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.hint-note {
  font-size: 12px;
  color: var(--warn);
  margin: 10px 0 0;
}

/* 主应用外壳 */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.topbar {
  padding-top: calc(var(--safe-top) + 10px);
  padding-bottom: 10px;
  padding-left: 16px;
  padding-right: 16px;
  background: rgba(22, 25, 38, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-cyan));
}

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

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 28px;
  -webkit-overflow-scrolling: touch;
}

.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 卡片与表单布局 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.card h4 {
  margin: 8px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.section-label {
  font-weight: 600;
  font-size: 13px;
  display: block;
  margin-bottom: 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  text-align: left;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 12px;
  color: var(--text-muted);
}

.checkbox-field {
  justify-content: center;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main) !important;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row-gap-sm {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.select-sm {
  width: auto;
  max-width: 210px;
  padding: 5px 8px;
  font-size: 12px;
}

.input-xs {
  width: auto;
  max-width: 145px;
  padding: 5px 8px;
  font-size: 12px;
}

/* 按钮与徽章 */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: opacity 0.15s, background 0.15s;
  color: var(--text-main);
  background: var(--bg-elevated);
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b3df5);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-color);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}

.btn-danger {
  background: rgba(255, 77, 106, 0.16);
  border-color: rgba(255, 77, 106, 0.4);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.danger-text {
  color: var(--danger) !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-mock {
  background: rgba(0, 212, 255, 0.15);
  color: var(--accent-cyan);
}

.badge-live {
  background: rgba(45, 212, 191, 0.15);
  color: var(--success);
}

.badge-lock {
  background: rgba(124, 92, 255, 0.2);
  color: #bbaaff;
}

/* 分段选择器与胶囊按钮 */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.pill.active {
  background: rgba(124, 92, 255, 0.22);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* 角色卡锁定栏 (F14) */
.locked-char-box {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(124, 92, 255, 0.4);
}

.char-avatar {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.locked-char-info {
  flex: 1;
  min-width: 0;
}

.locked-desc-text {
  margin: 4px 0 6px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-word;
}

/* 扩写栏与参考图 */
.expand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.expand-model-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.ref-thumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ref-thumb-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.ref-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
}

.frame-pickers-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.frame-box {
  height: 100px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
}

.frame-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.price-tag {
  color: var(--accent-cyan);
  font-size: 15px;
}

/* 任务列表与日期分组 (F22, F24, F25) */
.grouped-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.date-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.date-group-header {
  padding: 11px 13px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.date-group-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar-track {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-cyan));
  transition: width 0.25s;
}

/* 作品墙网格与默认打码 (F26, F27) */
.works-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
}

.work-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  cursor: pointer;
}

.work-tile.selected {
  border-color: var(--accent-cyan);
}

.work-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.work-thumb-blurred {
  filter: blur(18px) scale(1.12);
}

.work-tile-badges {
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.tile-tag {
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.batch-bar {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 底部导航栏 */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(22, 25, 38, 0.96);
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
  padding-bottom: calc(var(--safe-bottom) + 6px);
  flex-shrink: 0;
}

.nav-item {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  cursor: pointer;
}

.nav-item.active {
  color: var(--accent-cyan);
}

.nav-icon {
  font-size: 18px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 26%;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 0 5px;
  border-radius: 999px;
}

/* 全屏查看器与双指缩放/视频播放 (F29, F30) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(6, 7, 12, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.viewer-top-bar {
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(13, 15, 23, 0.75);
  z-index: 10;
}

.viewer-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.viewer-media-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
}

.viewer-media-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}

/* F30: 横版视频旋转横屏支持 */
.viewer-landscape-rotated .viewer-media-video {
  transform: rotate(90deg);
  max-width: 78vh;
  max-height: 92vw;
}

.video-controls-bar {
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
  background: rgba(22, 25, 38, 0.88);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease;
}

.video-controls-bar.controls-hidden {
  opacity: 0;
  pointer-events: none;
}

.vid-seek-slider {
  flex: 1;
  padding: 0;
}

.viewer-bottom-sheet {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 10px 14px calc(var(--safe-bottom) + 12px);
  z-index: 10;
}

.viewer-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.recipe-meta-box {
  font-size: 12px;
  color: var(--text-muted);
  max-height: 96px;
  overflow-y: auto;
  background: var(--bg-elevated);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

/* 弹窗卡片与连接自检列表 */
.dialog-card {
  width: 92%;
  max-width: 460px;
  max-height: 86vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow-y: auto;
}

.compare-video-player {
  width: 100%;
  max-height: 220px;
  background: #000;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.candidate-row {
  background: var(--bg-elevated);
  padding: 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.check-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.check-badge {
  font-weight: 600;
  color: var(--text-muted);
}

.check-pass {
  color: var(--success);
}

.check-fail {
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-item {
  background: var(--bg-main);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.usage-box,
.hint-box {
  background: var(--bg-elevated);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-top: 8px;
}

.banner {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin: 8px 0;
}

.banner-warn {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--warn);
}

.banner-info {
  border-color: rgba(0, 212, 255, 0.35);
}

.muted-label,
.muted-text {
  color: var(--text-muted);
  font-size: 12px;
}

.error-text {
  color: var(--danger);
  font-size: 12px;
  margin-bottom: 10px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 12px 0;
}

.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: rgba(31, 36, 55, 0.96);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
