* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f6f8;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  color: #333;
}

body.is-authenticated .auth-overlay {
  display: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  z-index: 2000;
}

.auth-overlay.show {
  display: flex;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.2);
}

.auth-brand {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #dff7fb 0%, #ebfbff 100%);
  font-size: 24px;
  margin-bottom: 14px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 18px;
}

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

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #4b5563;
}

.auth-field input {
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
}

.auth-field input:focus {
  border-color: #00b4d8;
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.12);
}

.auth-submit {
  width: 100%;
  justify-content: center;
}

.auth-hint {
  margin-top: 14px;
  font-size: 12px;
  color: #6b7280;
}

.page-wrapper {
  width: 100%;
  max-width: 820px;
}

.top-sticky-area {
  position: sticky;
  top: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Video Preview Section ===== */
.video-preview {
  margin-bottom: 20px;
}

.video-thumbnail {
  width: 280px;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}

.video-placeholder-img {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #c8a87c 0%, #a0825a 50%, #8b6f50 100%);
  position: relative;
}

.video-placeholder-img::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: 2px solid white;
}

.video-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #e5e5e5;
  border-radius: 20px;
  background: white;
  color: #333;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: #ccc;
  background: #fafafa;
}

.action-btn.more-btn {
  padding: 8px 12px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Main Creation Card ===== */
.creation-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: visible;
  position: relative;
}

.card-gradient-top {
  height: 5px;
  background: linear-gradient(90deg, #80deea 0%, #b2ebf2 25%, #e0f7fa 50%, #b2ebf2 75%, #80deea 100%);
  border-radius: 16px 16px 0 0;
}

/* ===== Header ===== */
.card-header {
  display: flex;
  align-items: center;
  padding: 16px 20px 8px;
  gap: 8px;
}

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

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: #222;
}

.header-user-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef9fc;
  color: #008ead;
  font-size: 12px;
  font-weight: 600;
}

.header-try {
  color: #00b4d8;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  margin-left: 8px;
}

.header-try:hover {
  text-decoration: underline;
}

/* ===== Content Area ===== */
.card-content {
  padding: 12px 20px 8px;
  min-height: 80px;
}

.mode-content {
  display: none;
}

.mode-content[data-active="true"] {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* Frame Cards */
.frames-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.smart-frames-area {
  flex-wrap: wrap;
  align-items: flex-start;
  max-width: 400px;
}

.frame-card {
  width: 72px;
  height: 88px;
  border: 1.5px dashed #d0d0d0;
  border-radius: 8px;
  background: #f8f8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.04);
}

.frame-card:first-child {
  transform: rotate(-4deg);
}

.frame-card:last-child {
  transform: rotate(4deg);
}

.frame-card:only-child {
  transform: rotate(-4deg);
}

.frame-card:hover {
  border-color: #00b4d8;
  background: #f0fafc;
}

.frame-add-card {
  border-style: dashed;
  border-color: #9adfed;
  background: #f4fcfe;
}

.frame-add-card .frame-label {
  color: #00b4d8;
}

.frame-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.frame-label {
  font-size: 11px;
  color: #999;
}

.frame-separator {
  display: flex;
  align-items: center;
  color: #ccc;
}

.separator-symbol {
  font-size: 18px;
  color: #c0c0c0;
  font-weight: 300;
  line-height: 1;
}

.ref-card {
  width: 72px;
  height: 88px;
}

/* Text Input */
.text-input-area {
  flex: 1;
  min-height: 120px;
}

.prompt-input-wrapper {
  position: relative;
  width: 100%;
}

.prompt-input {
  width: 100%;
  min-height: 120px;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background: transparent;
  font-family: inherit;
  padding: 8px 0;
}

.prompt-input::placeholder {
  color: #bbb;
}

.mention-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  max-height: 200px;
  overflow-y: auto;
  min-width: 280px;
  z-index: 100;
}

.mention-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s;
  border-bottom: 1px solid #f0f0f0;
}

.mention-item:last-child {
  border-bottom: none;
}

.mention-item:hover,
.mention-item.active {
  background: #f5f9fc;
}

.mention-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.mention-item-preview {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: #f0f0f0;
  flex-shrink: 0;
  display: block;
}

.mention-item-info {
  flex: 1;
  min-width: 0;
}

.mention-item-name {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-item-type {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.mention-empty {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* ===== Bottom Toolbar ===== */
.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 14px;
  border-top: 1px solid #f0f0f0;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.toolbar-item:hover {
  background: #f5f5f5;
}

.toolbar-item.dropdown-trigger {
  border-color: #ebebeb;
  background: #fafafa;
}

.toolbar-item.dropdown-trigger:hover {
  background: #f0f0f0;
  border-color: #ddd;
}

.toolbar-icon {
  flex-shrink: 0;
}

.toolbar-text {
  font-size: 13px;
  color: #555;
}

.gen-type-text {
  color: #00b4d8;
  font-weight: 600;
}

#genTypeBtn {
  background: #e8f8fb;
  border-color: #c8eef4;
}

#genTypeBtn:hover {
  background: #d8f2f7;
  border-color: #b0e5ee;
}

.dropdown-arrow {
  color: #999;
  margin-left: 2px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #e8e8e8;
  margin: 0 2px;
  flex-shrink: 0;
}

/* Credits */
.credits-item {
  cursor: default;
}

.credits-item:hover {
  background: transparent;
}

.credits-text {
  color: #555;
  font-size: 13px;
}

.credits-arrow {
  color: #555;
  font-size: 14px;
  font-weight: 600;
}

/* Send Button */
.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.send-btn:hover {
  transform: scale(1.05);
}

.send-btn.active svg circle {
  fill: #00b4d8;
  stroke: #00b4d8;
}

.send-btn.active svg path {
  stroke: white;
}

/* ===== Dropdown Menus ===== */
.dropdown-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 100;
  min-width: 160px;
}

.dropdown-menu.show {
  display: block;
}

.task-category-dropdown {
  min-width: 240px;
}

.task-category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}

.task-category-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: #555;
}

.task-category-option-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.task-category-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--task-category-color, #00b4d8);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

.task-category-option-meta {
  font-size: 11px;
  color: #999;
}

.task-category-option:hover,
.task-category-option.active {
  background: #f3fafc;
  color: #00a3c4;
}

.task-category-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 6px 4px;
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
}

.task-category-color-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #666;
}

.task-category-color-field input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.task-category-manage {
  display: flex;
  gap: 6px;
  padding: 8px 6px 4px;
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
}

.task-category-manage .btn {
  flex: 1;
}

.dropdown-header {
  padding: 10px 14px 8px;
  font-size: 13px;
  color: #999;
  white-space: nowrap;
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  font-size: 14px;
  color: #333;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-item.active {
  color: #00b4d8;
  font-weight: 500;
}

/* ===== Ratio Dropdown ===== */
.ratio-dropdown {
  min-width: 340px;
  padding: 12px 16px;
}

.ratio-grid {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.ratio-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.ratio-option:hover {
  background: #f5f5f5;
}

.ratio-option.is-disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.ratio-option.is-disabled:hover {
  background: transparent;
}

.ratio-option.active .ratio-preview {
  border-color: #00b4d8;
}

.ratio-option.active span {
  color: #00b4d8;
  font-weight: 500;
}

.ratio-option span {
  font-size: 12px;
  color: #666;
}

.ratio-preview {
  border: 1.5px solid #ccc;
  border-radius: 3px;
  background: transparent;
  transition: border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.r-adaptive {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  color: #666;
}

.r-21-9 {
  width: 42px;
  height: 18px;
}

.r-16-9 {
  width: 36px;
  height: 20px;
}

.r-4-3 {
  width: 30px;
  height: 23px;
}

.r-1-1 {
  width: 26px;
  height: 26px;
}

.r-3-4 {
  width: 23px;
  height: 30px;
}

.r-9-16 {
  width: 20px;
  height: 36px;
}

/* ===== Duration Dropdown ===== */
.duration-dropdown {
  top: calc(100% + 8px);
  bottom: auto;
  min-width: 220px;
  padding: 6px;
  max-height: min(420px, calc(100vh - 140px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.duration-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: #333;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.duration-option:hover {
  background: #f5f5f5;
}

.duration-option.active {
  color: #00b4d8;
}

.duration-option .check-mark {
  margin-left: auto;
  color: #00b4d8;
  font-size: 16px;
  font-weight: 600;
}

/* ===== Overlay for closing dropdowns ===== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
}

.overlay.show {
  display: block;
}

/* ===== Settings Button ===== */
.header-spacer {
  flex: 1;
}

.settings-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  color: #666;
}

.settings-btn:hover {
  background: #f0f0f0;
}

.settings-btn.has-config {
  color: #00b4d8;
}

.settings-btn.has-config svg path {
  stroke: #00b4d8;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  width: 460px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #222;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: #f0f0f0;
  color: #555;
}

.modal-body {
  padding: 8px 24px 16px;
  overflow-y: auto;
  flex: 1;
}

.form-group {
  margin-bottom: 18px;
}

.form-group:last-child {
  margin-bottom: 8px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: #333;
  background: #fafafa;
  transition: all 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: #00b4d8;
  background: white;
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.1);
}

.form-input::placeholder {
  color: #bbb;
}

.input-with-toggle {
  position: relative;
}

.input-with-toggle .form-input {
  padding-right: 42px;
}

.toggle-visibility {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
}

.toggle-visibility:hover {
  background: #eee;
}

.form-hint {
  font-size: 12px;
  color: #aaa;
  margin-top: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 22px;
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
  background: #fff;
}

.btn {
  padding: 8px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  font-weight: 500;
}

.btn-secondary {
  background: #f0f0f0;
  color: #555;
}

.btn-secondary:hover {
  background: #e5e5e5;
}

.btn-primary {
  background: #00b4d8;
  color: white;
}

.btn-primary:hover {
  background: #0099b8;
}

.btn-sm {
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12px;
}

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

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  padding: 14px 20px;
  font-size: 14px;
  color: #333;
  z-index: 2000;
  transition: transform 0.3s ease;
  max-width: 90vw;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-left: 4px solid #22c55e;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.loading {
  border-left: 4px solid #00b4d8;
}

.toast .task-id {
  font-family: 'Courier New', monospace;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  user-select: all;
  cursor: pointer;
}

/* ===== Loading Spinner for Send Btn ===== */
.send-btn.sending svg {
  display: none;
}

.send-btn.sending::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top-color: #00b4d8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Form Section Divider ===== */
.form-divider {
  height: 1px;
  background: #eee;
  margin: 18px 0 14px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #444;
  margin-bottom: 14px;
}

/* ===== Task List Section ===== */
.task-list-section {
  margin-top: 24px;
  overflow: hidden;
}

.task-list-top {
  background: #f5f6f8;
}

.task-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.task-list-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-list-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #e6eef2;
  border-radius: 10px;
  background: #f8fbfc;
}

.task-batch-info {
  font-size: 13px;
  color: #566;
  white-space: nowrap;
}

.status-filter {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #555;
  background: white;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.status-filter:focus {
  border-color: #00b4d8;
}

.btn-sm {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 5px;
  background: white;
  border: 1px solid #ddd;
  color: #555;
}

.btn-refresh:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.btn-refresh.loading svg {
  animation: spin 1s linear infinite;
}

.prompt-optimization-action-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #f5f5f5;
}

.prompt-optimization-action-area:hover {
  background: #eee;
}

/* Task Stats */
.task-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: #f8f9fa;
  transition: all 0.2s;
}

.stat-item:hover {
  background: #f0f1f3;
  transform: translateY(-2px);
}

.stat-label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #333;
}

.stat-succeeded .stat-value {
  color: #28a745;
}

.stat-processing .stat-value {
  color: #00b4d8;
}

.stat-queued .stat-value {
  color: #ffa500;
}

.stat-failed .stat-value {
  color: #dc3545;
}

/* Task Cards Container */
.task-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-empty {
  text-align: center;
  padding: 40px 20px;
  color: #aaa;
  font-size: 14px;
  background: white;
  border-radius: 12px;
  border: 1px dashed #e0e0e0;
}

/* Individual Task Card */
.task-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: box-shadow 0.2s;
  cursor: pointer;
}

.task-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.task-card.is-selected {
  box-shadow: 0 0 0 2px rgba(0, 180, 216, 0.18), 0 2px 12px rgba(0, 0, 0, 0.08);
}

.task-card-body {
  padding: 16px 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* Video Thumbnail in task card */
.task-video-wrap {
  flex-shrink: 0;
  width: 160px;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  position: relative;
}

.task-video-wrap video {
  width: 100%;
  display: block;
  border-radius: 8px;
}

.task-video-placeholder {
  width: 160px;
  height: 90px;
  background: linear-gradient(135deg, #e0e0e0 0%, #d0d0d0 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 12px;
}

/* Task Info */
.task-info {
  flex: 1;
  min-width: 0;
}

.task-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.task-select-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #00b4d8;
  cursor: pointer;
}

.task-id-label {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #333;
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 4px;
  user-select: all;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.task-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.task-status.succeeded {
  background: #ecfdf5;
  color: #16a34a;
}

.task-status.processing {
  background: #eff6ff;
  color: #2563eb;
}

.task-status.queued {
  background: #fffbeb;
  color: #d97706;
}

.task-status.failed {
  background: #fef2f2;
  color: #dc2626;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: #888;
}

.task-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.task-meta-item strong {
  color: #555;
  font-weight: 500;
}

.task-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef9fc;
  color: #00a3c4;
  font-size: 12px;
  font-weight: 500;
}

.task-prompt {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #333;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-materials,
.task-restore-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #7a8791;
}

.task-failure-reason {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 600;
}

.task-restore-hint {
  color: #00a3c4;
}

/* Task Card Footer with download link */
.task-card-footer {
  padding: 0 18px 14px;
}

.task-video-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #00b4d8;
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.15s;
}

.task-video-link:hover {
  color: #0099b8;
  text-decoration: underline;
}

/* Pagination */
.task-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.page-size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #666;
}

.page-size-input {
  width: 68px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  outline: none;
}

.page-size-input:focus {
  border-color: #00b4d8;
}

.page-info {
  font-size: 13px;
  color: #666;
}

/* ===== File Manager ===== */
.modal-wide {
  width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-wide .modal-body {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 20px;
}

/* Upload Zone */
.file-upload-zone {
  border: 2px dashed #d0d0d0;
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
  margin-bottom: 16px;
}

.file-upload-zone:hover,
.file-upload-zone.dragover {
  border-color: #00b4d8;
  background: #f0fafc;
}

.file-upload-zone.dragover {
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15);
}

.upload-zone-text {
  font-size: 14px;
  color: #666;
  margin-top: 10px;
}

.upload-zone-link {
  color: #00b4d8;
  font-weight: 500;
  cursor: pointer;
}

.upload-zone-hint {
  font-size: 12px;
  color: #aaa;
  margin-top: 6px;
}

.file-category-toolbar {
  display: flex;
  gap: 12px;
  margin: 0 0 12px;
}

.file-category-field {
  flex: 1;
  min-width: 0;
}

.file-category-filter-field {
  max-width: 220px;
}

.file-category-action-field {
  width: 120px;
  flex-shrink: 0;
}

.file-category-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #777;
  font-weight: 500;
}

.file-category-input,
.file-category-select {
  height: 38px;
}

.file-category-create-btn {
  width: 100%;
  height: 38px;
}

.category-manager-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.file-move-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #e8eef1;
  border-radius: 10px;
  background: #fafcfd;
}

.file-move-label {
  font-size: 12px;
  color: #667;
  white-space: nowrap;
}

.file-move-select {
  flex: 1;
  height: 36px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f7f9;
  color: #567;
  font-size: 12px;
  border: 1px solid #e3ecef;
}

.category-chip.is-active {
  background: #eef9fc;
  border-color: #b7e9f3;
  color: #0094b3;
}

.category-chip-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-chip-count {
  color: #8aa;
}

.category-chip-btn {
  border: none;
  background: transparent;
  color: #7a8a93;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}

.category-chip-btn:hover {
  color: #00a3c4;
}

.category-chip-btn:disabled {
  color: #c4cbd1;
  cursor: not-allowed;
}

.category-chip-btn.delete:hover {
  color: #dc3545;
}

/* Upload Progress */
.upload-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.upload-progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f8f8f8;
  border-radius: 10px;
  font-size: 13px;
}

.upload-progress-item .upload-filename {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #333;
}

.upload-progress-item .upload-status {
  font-size: 12px;
  white-space: nowrap;
}

.upload-progress-item .upload-status.uploading {
  color: #00b4d8;
}

.upload-progress-item .upload-status.done {
  color: #16a34a;
}

.upload-progress-item .upload-status.error {
  color: #dc2626;
}

.upload-progress-bar {
  width: 80px;
  height: 4px;
  background: #e5e5e5;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.upload-progress-bar-inner {
  height: 100%;
  background: #00b4d8;
  border-radius: 2px;
  transition: width 0.3s;
}

/* File List Header */
.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 10px;
}

.file-list-count {
  font-size: 13px;
  color: #888;
  font-weight: 500;
}

/* File Grid */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.file-grid .task-empty {
  grid-column: 1 / -1;
  padding: 24px;
}

/* File Card */
.file-card {
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
  background: white;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}

.file-card:hover {
  border-color: #ccc;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.file-card.selected {
  border-color: #00b4d8;
  box-shadow: 0 0 0 2px rgba(0, 180, 216, 0.2);
}

.file-card-thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  min-height: 220px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.file-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.file-card-thumb video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.file-type-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(0,0,0,0.5);
  color: white;
}

.file-card-info {
  padding: 8px 10px;
}

.file-card-name {
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.file-card-meta {
  font-size: 11px;
  color: #aaa;
  display: flex;
  gap: 6px;
  align-items: center;
}

.file-card-category {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef9fc;
  color: #00a3c4;
  font-size: 11px;
  font-weight: 500;
}

.file-card-status {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.file-card-status.active {
  background: #22c55e;
}

.file-card-status.processing {
  background: #f59e0b;
}

.file-card-id {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: #bbb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Copy ID button on hover */
.file-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
}

.file-card:hover .file-card-actions {
  display: flex;
  gap: 4px;
}

.file-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.9);
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: all 0.15s;
}

.file-action-btn:hover {
  background: white;
  color: #00b4d8;
}

.delete-file-btn:hover {
  color: #ef4444;
}

/* File Manager Footer (selection mode) */
.file-manager-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

.file-select-hint {
  font-size: 13px;
  color: #999;
}

.file-select-hint.has-selection {
  color: #00b4d8;
  font-weight: 500;
}

.file-manager-footer-btns {
  display: flex;
  gap: 8px;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
}

.admin-user-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-user-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.admin-user-meta {
  font-size: 12px;
  color: #6b7280;
}

.admin-user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-rules-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.prompt-rules-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-rules-editor {
  min-height: 220px;
  margin-top: 10px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.dashboard-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-stat-card {
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f8fdff 0%, #eefbff 100%);
  border: 1px solid #d9f3f9;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dashboard-stat-card span {
  font-size: 12px;
  color: #6b7280;
}

.dashboard-stat-card strong {
  font-size: 22px;
  color: #111827;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.dashboard-table th,
.dashboard-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  font-size: 13px;
}

.dashboard-table th {
  color: #4b5563;
  background: #f8fafc;
}

/* Frame card with selected file */
.frame-card.has-file {
  border-color: #00b4d8;
  background: #f8fcfe;
  position: relative;
  overflow: hidden;
}

.frame-card.has-file .frame-inner {
  padding: 6px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  overflow: hidden;
}

.frame-card.has-file .frame-plus-icon {
  display: none;
}

.frame-file-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.frame-file-thumb {
  width: 100%;
  max-width: 100%;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  border-radius: 6px;
  object-fit: contain;
  background: #eef4f7;
  display: block;
  flex: 0 0 auto;
}

.frame-file-name {
  font-size: 11px;
  color: #555;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.frame-card.has-file .frame-label {
  line-height: 1;
  flex: 0 0 auto;
}

.frame-clear-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: white;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.frame-card.has-file:hover .frame-clear-btn {
  opacity: 1;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .page-wrapper {
    max-width: 100%;
  }

  .card-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar-left {
    flex-wrap: wrap;
    gap: 4px;
  }

  .ratio-dropdown {
    min-width: 280px;
  }

  .ratio-grid {
    gap: 6px;
  }

  .mode-content[data-active="true"] {
    flex-direction: column;
  }

  .task-card-body {
    flex-direction: column;
  }

  .task-video-wrap,
  .task-video-placeholder {
    width: 100%;
  }

  .task-video-placeholder {
    height: 120px;
  }

  .dashboard-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-user-item {
    flex-direction: column;
    align-items: flex-start;
  }
}
