:root {
  --bg: #0F172A;
  --panel: #1E293B;
  --input: #334155;
  --input-hover: #475569;
  --border: #475569;
  --accent: #60A5FA;
  --accent-hover: #93C5FD;
  --text: #F1F5F9;
  --text-dim: #94A3B8;
  --danger: #EF4444;
  --success: #22C55E;
  --warning: #F59E0B;
}

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

body {
  font-family: -apple-system, 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; flex-direction: column; height: 100vh; }

.app-header {
  padding: 16px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 20px; font-weight: 600; }

.app-body { display: flex; flex: 1; overflow: hidden; }

.form-panel {
  width: 480px;
  padding: 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background: #0a0a0f;
  overflow: auto;
  padding: 20px;
}

.form-section { margin-bottom: 28px; }
.form-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-row { margin-bottom: 14px; }
.form-row > label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-inline { display: flex; gap: 8px; align-items: center; }
.form-inline select { flex: 1; }

.field-hint { font-size: 12px; color: var(--text-dim); opacity: .75; margin-top: 5px; line-height: 1.4; }

.custom-dropdown {
  flex: 1;
  position: relative;
  user-select: none;
}
.dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.dropdown-trigger:hover, .dropdown-trigger:focus-visible { border-color: var(--accent); outline: none; }
.dropdown-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-arrow { font-size: 10px; opacity: 0.6; flex-shrink: 0; margin-left: 8px; }
.custom-dropdown.open .dropdown-arrow { transform: rotate(180deg); }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.custom-dropdown.open .dropdown-menu { display: block; }
.dropdown-search {
  width: calc(100% - 16px);
  margin: 8px 8px 4px;
  padding: 6px 10px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.dropdown-search:focus { border-color: var(--accent); }
.dropdown-list { max-height: 210px; overflow-y: auto; }
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--input-hover); outline: none; }
.dropdown-item.selected { color: var(--accent); }
.dropdown-item .di-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item .di-meta { flex-shrink: 0; font-size: 11px; color: var(--text-dim); margin-left: 8px; }
.dropdown-item .di-delete {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: all 0.15s;
}
.dropdown-item .di-delete:hover { background: var(--danger); color: #fff; }
.dropdown-empty { padding: 12px; font-size: 13px; color: var(--text-dim); text-align: center; }
.dropdown-menu::-webkit-scrollbar { width: 5px; }
.dropdown-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus, input[type="date"]:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.radio-group { display: flex; gap: 16px; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  cursor: pointer;
  margin: 0;
}
.radio-group input[type="radio"] { accent-color: var(--accent); }

.rating-selector { display: flex; gap: 8px; }
.rating-option {
  padding: 6px 20px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.rating-option:hover, .rating-option:focus-visible { border-color: var(--accent); outline: none; }
.rating-option.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.rating-option.rating-good { color: #FBBF24; }
.rating-option.rating-worth { color: #34D399; }
.rating-option.rating-mid { color: #CBD5E1; }
.rating-option.rating-meh { color: #FB923C; }
.rating-option.rating-bad { color: #F87171; }
.rating-option.selected { color: #fff; }

.btn-primary {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-sm {
  padding: 6px 12px;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--input-hover); }
.btn-sm:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { color: var(--danger); }
.btn-icon { padding: 2px 7px; font-size: 12px; }

.actions { display: flex; gap: 12px; margin-top: 8px; }
.bottom-actions { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.bottom-actions .btn-primary { flex: 1; }

.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  color: var(--accent-hover);
}

.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 18px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 6px;
  font-size: 13px;
  color: var(--warning);
}

.avatar-selector { display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-group-label {
  width: 100%;
  font-size: 11px;
  color: var(--text-dim);
  opacity: .8;
  margin-top: 4px;
}
.avatar-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: border-color 0.2s, background 0.2s;
  background: transparent;
}
.avatar-option:hover, .avatar-option:focus-visible { border-color: var(--border); outline: none; }
.avatar-option.selected { border-color: var(--accent); background: rgba(96, 165, 250, 0.1); }
.avatar-option img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; display: block; pointer-events: none; }
.avatar-option .avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.avatar-option .avatar-name { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.avatar-option .avatar-character { font-size: 10px; color: var(--text-dim); opacity: .85; margin-top: 2px; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-option .avatar-delete {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: .75;
  transition: opacity 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.avatar-option .avatar-delete:hover { opacity: 1; }
.avatar-option.avatar-rated { opacity: .45; cursor: not-allowed; }
.avatar-option.avatar-rated img { filter: grayscale(1); }
.avatar-count { color: var(--accent); font-size: 12px; }

.avatar-add {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.avatar-add input[type="text"] {
  width: 120px;
  padding: 4px 8px;
  font-size: 12px;
}
.avatar-preview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
}

.avatar-rating-area {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(96, 165, 250, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.avatar-rating-title { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.avatar-rating-list { display: flex; flex-direction: column; gap: 8px; }
.avatar-rating-item { display: flex; align-items: center; gap: 10px; }
.avatar-rating-item .ari-avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.avatar-rating-item .ari-fallback {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #667eea, #764ba2); flex-shrink: 0;
}
.avatar-rating-item .ari-name { flex: 1; font-size: 13px; color: var(--text); }
.avatar-rating-item .ari-btns { display: flex; gap: 6px; }
.ari-btn {
  padding: 4px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--input); cursor: pointer; transition: all .15s;
}
.ari-btn:hover { border-color: var(--accent); }
.ari-btn.rating-good { color: #FBBF24; }
.ari-btn.rating-worth { color: #34D399; }
.ari-btn.rating-mid { color: #CBD5E1; }
.ari-btn.rating-meh { color: #FB923C; }
.ari-btn.rating-bad { color: #F87171; }
.ari-btn.selected { background: var(--accent); color: #fff; border-color: var(--accent); }



.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.preview-mode-label { font-size: 13px; color: var(--text-dim); margin-right: 4px; }
.preview-mode-btn {
  padding: 6px 14px;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.preview-mode-btn:hover { border-color: var(--accent); }
.preview-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.preview-stage { display: flex; flex-direction: column; align-items: center; }
.preview-placeholder { text-align: center; color: var(--text-dim); padding: 80px 20px; }
.preview-placeholder p { font-size: 16px; margin-bottom: 8px; }
.preview-placeholder .hint { font-size: 13px; opacity: 0.7; }

.preview-frame-wrap { position: relative; display: inline-block; }
#previewFrame {
  width: 600px;
  min-height: 800px;
  height: auto;
  border: none;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: block;
}
.split-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
}
.split-line {
  position: absolute;
  left: 4px;
  right: 4px;
  border-top: 2px dashed rgba(255, 120, 80, 0.9);
  z-index: 5;
}
.split-line::after {
  content: '切分点';
  position: absolute;
  top: -18px;
  right: 8px;
  font-size: 11px;
  color: #fff;
  background: rgba(255, 120, 80, 0.85);
  padding: 1px 6px;
  border-radius: 3px;
}

.mode-hint {
  font-size: 12px;
  color: var(--text-dim);
  opacity: .8;
  line-height: 1.5;
  margin-bottom: 8px;
}
.zip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
  cursor: pointer;
  user-select: none;
}
.zip-toggle input { accent-color: var(--accent); cursor: pointer; }

.export-progress {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.progress-track {
  height: 6px;
  background: var(--input);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-fill.indeterminate {
  width: 35%;
  animation: progress-slide 1.1s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}
#exportProgressText { display: block; font-size: 12px; color: var(--text-dim); margin-top: 8px; }

.export-result {
  margin-top: 14px;
  padding: 12px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 6px;
  font-size: 13px;
  color: var(--success);
  line-height: 1.6;
  word-break: break-all;
}

.review-list { display: flex; flex-direction: column; gap: 8px; }
.review-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.review-item .ri-cat { font-weight: 600; color: var(--accent); white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.review-item .ri-pin {
  font-size: 10px;
  color: var(--warning);
  border: 1px solid var(--warning);
  border-radius: 3px;
  padding: 0 3px;
  white-space: nowrap;
}
.review-item .ri-text { flex: 1; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-item .ri-actions { display: flex; gap: 4px; flex-shrink: 0; }
.review-item.editing { border-color: var(--accent); background: rgba(96, 165, 250, 0.08); }

/* Toast */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-msg { flex: 1; line-height: 1.4; }
.toast-undo {
  flex-shrink: 0;
  padding: 3px 10px;
  background: transparent;
  color: var(--accent-hover);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.toast-undo:hover { background: rgba(96, 165, 250, 0.15); }
.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.toast-close:hover { color: var(--text); background: var(--input-hover); }

@media (max-width: 900px) {
  .app-body { flex-direction: column; overflow-y: auto; }
  .form-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .preview-panel { overflow: visible; }
  #previewFrame { width: 100%; max-width: 600px; }
}
