/* ============================================
   Components
   Buttons, cards, inputs, sliders, etc.
   ============================================ */

/* ========== BUTTONS ========== */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px var(--space-lg);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow-glow-pink);
  transition: transform var(--transition-fast), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 28px rgba(255, 143, 171, 0.4);
}

.btn-primary:hover::before {
  opacity: 1;
}

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

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-optimize-primary {
  background: linear-gradient(135deg, #FFB347 0%, #FF7A59 50%, #FF5C8A 100%);
  color: #fff;
  box-shadow: 0 6px 24px rgba(255, 122, 89, 0.34);
}

.btn-optimize-primary:hover {
  box-shadow: 0 8px 30px rgba(255, 122, 89, 0.44);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 10px var(--space-lg);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--color-candy-lavender);
  background: #faf5ff;
  color: var(--color-candy-lavender);
}

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

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

.btn-text {
  background: none;
  border: none;
  color: var(--color-candy-lavender);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-text:hover {
  color: var(--color-candy-pink);
  background: rgba(255, 143, 171, 0.06);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--color-border-light);
  color: var(--color-candy-pink);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  border-radius: var(--radius-md);
}

.btn-full {
  width: 100%;
}

/* ========== CARDS ========== */

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
}

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

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-header .card-title {
  margin-bottom: 0;
}

.card-actions {
  display: flex;
  gap: var(--space-sm);
}

.poster-mode-status {
  margin: 0 0 var(--space-sm);
  font-size: 0.82rem;
  color: var(--color-candy-lavender);
}

.card-actions-compact {
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.slider-action-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding-bottom: var(--space-sm);
  margin-top: calc(var(--space-xs) * -1);
}

.canvas-header-tools {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.composition-toolbar {
  margin-top: var(--space-sm);
  padding: var(--space-sm) 0 var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.composition-toolbar .comp-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.poster-entry-card {
  border-style: dashed;
  border-color: rgba(137, 207, 243, 0.55);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(242, 249, 255, 0.95));
}

.poster-entry-desc {
  margin: 0 0 var(--space-md);
  color: var(--color-text-secondary);
  font-size: 0.84rem;
  line-height: 1.55;
}

.poster-entry-card .poster-mode-status {
  margin: var(--space-sm) 0 0;
}

.app-version {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  color: var(--color-text-tertiary);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.ui-mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.62);
}

.ui-mode-btn {
  min-height: 24px;
  padding: 0 9px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.ui-mode-btn.active {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-glow-pink);
}

.analysis-action-section {
  padding: var(--space-md);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-sm);
}

.analysis-action-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.analysis-action-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.analysis-action-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--color-text-secondary);
  font-size: 0.76rem;
  line-height: 1.45;
}

.analysis-action-copy strong {
  color: var(--color-text-primary);
  font-size: 0.82rem;
  font-weight: 800;
}

.analysis-action-copy span {
  color: var(--color-text-tertiary);
}

.module-note {
  margin: 0 0 var(--space-sm);
  padding: 8px 10px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
  color: var(--color-text-secondary);
  font-size: 0.74rem;
  line-height: 1.5;
}

.comp-note {
  margin-bottom: 2px;
}

.template-section {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

.template-section-title {
  margin: 0 0 var(--space-sm);
  color: var(--color-text-primary);
  font-size: 0.86rem;
  font-weight: 800;
}

.template-container,
.template-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.template-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--space-xs);
  align-items: center;
}

.template-name-input {
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
  color: var(--color-text-primary);
  padding: 6px 9px;
  font-size: 0.76rem;
}

.template-empty {
  padding: var(--space-sm);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-tertiary);
  font-size: 0.74rem;
  text-align: center;
}

.template-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs);
  align-items: center;
  padding: var(--space-sm);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
}

.template-item-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-item-title {
  overflow: hidden;
  color: var(--color-text-primary);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-desc {
  overflow: hidden;
  color: var(--color-text-tertiary);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.template-confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: var(--space-lg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-lg);
}

.template-confirm-title {
  margin: 0 0 var(--space-xs);
  font-size: 1rem;
  font-weight: 900;
}

.template-confirm-desc,
.template-confirm-name {
  margin: 0 0 var(--space-sm);
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  line-height: 1.5;
}

.template-confirm-name {
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: rgba(195, 166, 255, 0.12);
  color: var(--color-text-primary);
  font-weight: 800;
}

.template-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ========== TEXTAREA ========== */

.prompt-textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: var(--color-bg-input);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: var(--space-md);
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--color-candy-lavender);
  box-shadow: 0 0 0 3px rgba(195, 166, 255, 0.15);
}

.prompt-textarea::placeholder {
  color: var(--color-text-tertiary);
}

/* ========== FORM ========== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.form-group input[type='text'],
.form-group input[type='password'],
.form-group input[type='url'] {
  padding: 10px var(--space-md);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background: var(--color-bg-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-candy-lavender);
  box-shadow: 0 0 0 3px rgba(195, 166, 255, 0.15);
}

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

.input-with-toggle input {
  width: 100%;
  padding-right: 44px;
}

.input-with-toggle .btn-icon {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
}

/* ========== API MODE SWITCH ========== */

.api-mode-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.api-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.api-mode-option input {
  margin: 0;
  accent-color: var(--color-candy-pink);
}

.api-mode-option input:checked + span {
  color: var(--color-candy-pink);
  font-weight: 600;
}

.api-mode-option:has(input:checked) {
  border-color: var(--color-candy-pink);
  background: linear-gradient(135deg, rgba(255,143,171,0.08), rgba(195,166,255,0.08));
}

.settings-mode-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

#settings-panel #test-connection,
#settings-panel #save-settings {
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
}

/* ========== SCENE CONFIRM DIALOG ========== */

.scene-confirm-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  z-index: 980;
}

.scene-confirm-dialog {
  width: min(520px, 100%);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.scene-confirm-dialog h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-primary);
}

.scene-confirm-desc,
.scene-confirm-summary,
.scene-confirm-reason {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.scene-confirm-summary {
  color: var(--color-text-primary);
  font-weight: 600;
}

.scene-confirm-actions {
  margin-top: var(--space-sm);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ========== ANALYSIS FORM DIALOG ========== */

.analysis-form-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  z-index: 982;
}

.analysis-form-dialog {
  width: min(560px, 100%);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.analysis-form-dialog h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-primary);
}

.analysis-form-desc {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.analysis-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.analysis-form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.analysis-form-select,
.analysis-form-textarea {
  width: 100%;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.analysis-form-select {
  padding: 10px var(--space-md);
}

.analysis-form-textarea {
  min-height: 118px;
  padding: 10px var(--space-md);
  line-height: 1.6;
  resize: vertical;
}

.analysis-form-select:focus,
.analysis-form-textarea:focus {
  outline: none;
  border-color: var(--color-candy-lavender);
  box-shadow: 0 0 0 3px rgba(195, 166, 255, 0.15);
}

.analysis-form-actions {
  margin-top: var(--space-sm);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ========== SLIDERS ========== */

.slider-item {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border-light);
}

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

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.slider-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text-primary);
}

.slider-desc {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}

.slider-value {
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  min-width: 28px;
  text-align: right;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.slider-label-min,
.slider-label-max {
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
}

/* Custom range input */
.slider-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  background: var(--color-border);
  transition: background var(--transition-fast);
}

.slider-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  cursor: grab;
  border: 2.5px solid #fff;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.slider-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 24px rgba(255, 143, 171, 0.45);
}

.slider-range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

/* Firefox */
.slider-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  cursor: grab;
  border: 2.5px solid #fff;
  transition: transform var(--transition-fast);
}

.slider-range::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.slider-range::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: transparent;
}

/* ========== RADAR ========== */

.radar-wrapper {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  padding: var(--space-sm);
}

.radar-wrapper canvas {
  width: 100% !important;
  height: auto !important;
}

/* ========== RESULT CONTENT ========== */

.result-card-header {
  align-items: stretch;
  flex-direction: column;
  gap: var(--space-sm);
}

.result-header-actions {
  width: 100%;
  justify-content: flex-end;
  gap: var(--space-xs);
}

.result-content {
  padding: var(--space-lg);
  background: var(--color-bg-input);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  min-height: 120px;
  font-size: 0.93rem;
  line-height: 1.85;
  color: var(--color-text-primary);
  word-break: break-word;
}

.result-content p {
  margin-bottom: var(--space-sm);
}

.result-content p:last-child {
  margin-bottom: 0;
}

.result-content strong {
  color: var(--color-candy-pink);
  font-weight: 600;
}

.result-content code {
  background: var(--color-border-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.result-content em {
  color: var(--color-candy-lavender);
  font-style: italic;
}

/* ========== LOADING ========== */

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3xl) var(--space-xl);
  gap: var(--space-lg);
}

.loading-dots {
  display: flex;
  gap: 8px;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: loadingBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
  background: var(--color-candy-pink);
}

.loading-dots span:nth-child(2) {
  background: var(--color-candy-lavender);
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  background: var(--color-candy-mint);
  animation-delay: 0.4s;
}

.loading-text {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
}

/* ========== TOAST ========== */

#toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: 10px var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: toastIn var(--transition-normal) ease,
             toastOut var(--transition-normal) ease 2.7s forwards;
  pointer-events: auto;
  max-width: 360px;
}

.toast-info {
  background: rgba(137, 207, 243, 0.92);
  color: #1a4a6b;
}

.toast-success {
  background: rgba(125, 223, 195, 0.92);
  color: #1a5c4a;
}

.toast-error {
  background: rgba(255, 107, 138, 0.92);
  color: #5c1a2a;
}

/* ========== HISTORY ITEMS ========== */

.history-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-sm);
  position: relative;
}

.history-item:hover {
  background: #faf5ff;
  border-color: var(--color-candy-lavender);
}

.history-prompt {
  font-size: 0.85rem;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: var(--space-xs);
  padding-right: var(--space-xl);
}

.history-date {
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
}

.history-delete {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: 0.78rem;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: var(--color-error);
  background: rgba(255, 107, 138, 0.08);
}

/* ========== EMPTY STATE ========== */

.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-tertiary);
  font-size: 0.88rem;
}

/* ========== UTILITY ========== */

.hidden {
  display: none !important;
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Candy stripe decorative bar */
.candy-stripe-bar {
  height: 3px;
  border-radius: var(--radius-full);
  background: repeating-linear-gradient(
    90deg,
    var(--color-candy-pink) 0px,
    var(--color-candy-pink) 8px,
    var(--color-candy-lavender) 8px,
    var(--color-candy-lavender) 16px,
    var(--color-candy-mint) 16px,
    var(--color-candy-mint) 24px,
    var(--color-candy-peach) 24px,
    var(--color-candy-peach) 32px
  );
  opacity: 0.5;
  margin: var(--space-md) 0;
}

/* ========== PRESET CARDS ========== */

.presets-row {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.presets-row::-webkit-scrollbar {
  height: 4px;
}

.presets-row::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.preset-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  min-width: 0;
}

.preset-card:hover {
  border-color: var(--color-candy-lavender);
  background: #faf5ff;
}

.preset-card.active {
  border-color: var(--color-candy-pink);
  background: linear-gradient(135deg, rgba(255,143,171,0.08), rgba(195,166,255,0.08));
  box-shadow: 0 2px 12px rgba(255,143,171,0.12);
}

.preset-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.preset-card-desc {
  font-size: 0.68rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* ========== COMPOSITION SELECTOR ========== */

.comp-selector {
  display: flex;
  gap: var(--space-xs);
}

.comp-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.comp-option:hover {
  border-color: var(--color-candy-lavender);
}

.comp-option.active {
  border-color: var(--color-candy-pink);
  background: linear-gradient(135deg, rgba(255,143,171,0.08), rgba(195,166,255,0.08));
  box-shadow: 0 2px 10px rgba(255,143,171,0.12);
}

.comp-option .comp-icon {
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.comp-option.active .comp-icon {
  color: var(--color-candy-pink);
}

.comp-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
}

.comp-option.active .comp-label {
  color: var(--color-candy-pink);
}

/* ========== STYLE SLIDER (Anime ↔ Realistic, 10 steps) ========== */

.style-slider-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-slider-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  user-select: none;
}

.style-slider-label-left {
  color: var(--color-candy-pink);
}

.style-slider-label-right {
  color: var(--color-candy-sky);
}

.style-slider-track-wrap {
  position: relative;
  width: 120px;
  flex-shrink: 0;
}

.style-slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  background: var(--color-border);
}

.style-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  cursor: grab;
  border: 2px solid #fff;
  transition: transform var(--transition-fast);
}

.style-slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.style-slider-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.style-slider-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow-pink);
  border: 2px solid #fff;
  cursor: grab;
}

.style-slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  margin-top: 2px;
}

.style-slider-tick {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.style-slider-tick.active {
  background: var(--color-candy-pink);
  transform: scale(1.5);
}

.style-slider-value {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ========== GUIDE CARDS ========== */

.guide-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: opacity var(--transition-slow), max-height var(--transition-slow);
  overflow: hidden;
}

.guide-cards.hiding {
  opacity: 0;
  max-height: 0 !important;
  margin: 0;
  padding: 0;
}

.guide-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.guide-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border-light);
}

/* Style spectrum table */
.guide-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 3px 0;
}

.guide-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
}

.guide-desc {
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* Operation steps */
.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.guide-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-secondary);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ========== POSTER WORKSPACE INSPECTOR ========== */

.poster-inspector {
  display: flex;
  flex-direction: column;
  align-self: start;
  position: sticky;
  top: 88px;
  height: calc(100dvh - 104px);
  max-height: calc(100dvh - 104px);
  min-height: 0;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.poster-inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.poster-inspector-header h2 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
}

.poster-inspector-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

#btn-exit-poster-workspace {
  padding-inline: 10px;
  white-space: nowrap;
}

#btn-close-poster-inspector {
  display: none;
}

.poster-inspector-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: var(--space-xs);
  padding: var(--space-sm);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  min-height: 0;
}

.poster-group {
  flex: 0 0 auto;
  margin: 0;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  overflow: hidden;
}

.poster-group.dropdown-open {
  position: relative;
  z-index: 30;
  overflow: visible;
}

.poster-inspector-body > .poster-group:last-child {
  margin-bottom: 0;
}

.poster-inspector-body {
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
}

.poster-group > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 10px var(--space-md);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  background: linear-gradient(135deg, rgba(255, 143, 171, 0.05), rgba(195, 166, 255, 0.05));
  border-bottom: 1px solid transparent;
}

.poster-group > summary::-webkit-details-marker {
  display: none;
}

.poster-group[open] > summary {
  color: var(--color-text-primary);
  border-bottom-color: var(--color-border-light);
}

.poster-slot {
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.poster-slot > .card {
  margin: 0;
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.poster-slot > .card .card-title {
  font-size: 0.92rem;
}

.poster-group-layers {
  display: none;
}

body.poster-workspace-active .poster-slot {
  gap: var(--space-xs);
  padding: var(--space-xs);
}

body.poster-workspace-active .poster-group {
  width: 100%;
}

body.poster-workspace-active .poster-slot > .card {
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: none;
}

body.poster-workspace-active .poster-slot > .analysis-action-section {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border-radius: var(--radius-md);
  box-shadow: none;
}

body.poster-workspace-active .poster-slot > .card > :last-child {
  margin-bottom: 0;
}

body.poster-workspace-active .poster-slot > .card .card-header {
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

body.poster-workspace-active .poster-slot > .card .card-title {
  font-size: 0.86rem;
  line-height: 1.3;
}

body.poster-workspace-active #poster-slot-composition .comp-selector {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 6px;
}

body.poster-workspace-active #poster-slot-composition .comp-section-title {
  margin: 2px 0 0;
}

body.poster-workspace-active #poster-slot-composition .comp-final-size {
  margin-bottom: 0;
}

body.poster-workspace-active .module-note {
  padding: 7px 8px;
  font-size: 0.7rem;
  line-height: 1.45;
}

body.poster-workspace-active .poster-slot .btn-full {
  min-height: 38px;
}

body.poster-workspace-active .poster-slot #prompt-input {
  min-height: 96px;
  max-height: 180px;
}

.poster-mobile-inspector-btn {
  display: none;
}

.poster-floating-tools {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
}

body:not(.poster-workspace-active) .poster-floating-tools,
body:not(.poster-workspace-active) .poster-floating-panel {
  display: none !important;
}

.poster-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.poster-tool-btn:hover,
.poster-tool-btn.active {
  color: var(--color-text-primary);
  border-color: rgba(255, 143, 171, 0.45);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.poster-tool-btn.active {
  background: linear-gradient(135deg, rgba(255, 143, 171, 0.16), rgba(195, 166, 255, 0.16));
}

.poster-tool-btn svg {
  flex: 0 0 auto;
}

.poster-tool-btn span {
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.poster-floating-panel {
  position: fixed;
  top: calc(var(--poster-header-offset, 88px) + var(--space-lg));
  left: 72px;
  z-index: 860;
  display: flex;
  flex-direction: column;
  width: min(1120px, calc(100vw - clamp(360px, 24vw, 440px) - 104px));
  height: calc(100dvh - var(--poster-header-offset, 88px) - 48px);
  min-width: 720px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.poster-floating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  flex: 0 0 auto;
}

.poster-floating-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.poster-floating-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-md);
  overflow: auto;
}

.poster-floating-content {
  min-height: 100%;
}

.poster-floating-slot {
  min-width: 0;
  min-height: 0;
}

.poster-floating-dimensions {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(300px, 0.85fr);
  gap: var(--space-md);
  align-items: stretch;
}

.poster-floating-dimensions > .poster-floating-slot {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.poster-floating-dimensions .card {
  margin: 0;
  height: 100%;
}

.poster-floating-dimensions #radar-section {
  min-height: 420px;
}

.poster-floating-dimensions .radar-wrapper {
  min-height: 360px;
}

.poster-floating-dimensions #radar-chart {
  max-height: 360px;
}

@media (max-width: 768px) {
  .card {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .card-actions,
  .result-header-actions,
  .card-actions-compact,
  .canvas-header-tools {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .prompt-textarea {
    min-height: 128px;
    margin-bottom: var(--space-sm);
  }

  .analysis-action-section {
    padding: var(--space-sm);
    border-radius: var(--radius-lg);
  }

  .analysis-action-list {
    gap: 10px;
    margin-top: var(--space-sm);
  }

  .analysis-action-copy {
    font-size: 0.72rem;
  }

  .analysis-action-copy strong {
    font-size: 0.8rem;
  }

  .btn-primary,
  .btn-secondary {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
    padding-inline: 12px;
  }

  .template-form {
    grid-template-columns: 1fr;
  }

  .template-item {
    grid-template-columns: 1fr;
  }

  .template-item-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  body.poster-workspace-active .poster-mobile-inspector-btn {
    display: inline-flex;
  }

  body.poster-workspace-active .poster-floating-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.poster-workspace-active .poster-tool-btn {
    min-height: 42px;
    justify-content: center;
    padding: 8px;
  }

  body.poster-workspace-active .poster-floating-panel {
    inset: var(--poster-header-offset, 56px) 0 0 0;
    left: 0;
    z-index: 940;
    width: auto;
    height: calc(100dvh - var(--poster-header-offset, 56px));
    min-width: 0;
    border-radius: 0;
    border: none;
  }

  body.poster-workspace-active .poster-floating-body {
    padding: var(--space-sm);
  }

  body.poster-workspace-active .poster-floating-dimensions {
    grid-template-columns: 1fr;
  }

  body.poster-workspace-active .poster-inspector {
    position: fixed;
    inset: var(--poster-header-offset, 56px) 0 0 0;
    z-index: 920;
    height: calc(100dvh - var(--poster-header-offset, 56px));
    max-height: none;
    min-height: 0;
    border-radius: 0;
    border: none;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
  }

  body.poster-workspace-active .poster-inspector.open {
    transform: translateX(0);
  }

  body.poster-workspace-active #btn-close-poster-inspector {
    display: flex;
  }

  body.poster-workspace-active .poster-inspector-header {
    position: sticky;
    top: 0;
    background: var(--color-bg-card);
    z-index: 2;
  }

  body.poster-workspace-active .poster-inspector-body {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  }

  body.poster-workspace-active .poster-group-layers {
    display: block;
  }
}

@media (max-width: 640px) {
  .composition-toolbar {
    margin-top: var(--space-xs);
    padding-bottom: var(--space-sm);
  }

  .poster-floating-tools {
    grid-template-columns: 1fr;
  }

  .poster-tool-btn {
    min-height: 40px;
  }

  .result-content {
    padding: var(--space-md);
    font-size: 0.86rem;
    line-height: 1.7;
  }
}

/* ========== PRO UI MODE ========== */

[data-ui-mode="pro"] .btn-primary {
  background: #343434;
  color: #F6EBD7;
  border: 1px solid #343434;
  border-radius: var(--radius-md);
  box-shadow: none;
}

[data-ui-mode="pro"][data-theme="dark"] .btn-primary {
  background: #F1E7D2;
  color: #242424;
  border-color: #F1E7D2;
}

[data-ui-mode="pro"] .btn-primary::before {
  display: none;
}

[data-ui-mode="pro"] .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

[data-ui-mode="pro"] .btn-optimize-primary {
  background: #B8792F;
  border-color: #B8792F;
  color: #FFF9EC;
  box-shadow: none;
}

[data-ui-mode="pro"] .btn-optimize-primary:hover {
  background: #946126;
  border-color: #946126;
  box-shadow: var(--shadow-md);
}

[data-ui-mode="pro"][data-theme="dark"] .btn-optimize-primary {
  background: #E0B15F;
  border-color: #E0B15F;
  color: #242424;
}

[data-ui-mode="pro"][data-theme="dark"] .btn-optimize-primary:hover {
  background: #F1C879;
  border-color: #F1C879;
}

[data-ui-mode="pro"] .btn-secondary,
[data-ui-mode="pro"] .btn-icon,
[data-ui-mode="pro"] .btn-text {
  border-radius: var(--radius-md);
}

[data-ui-mode="pro"] .btn-secondary {
  background: var(--color-bg-card);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-ui-mode="pro"] .btn-secondary:hover,
[data-ui-mode="pro"] .btn-icon:hover,
[data-ui-mode="pro"] .btn-text:hover {
  background: var(--color-bg-input);
  border-color: var(--color-text-secondary);
  color: var(--color-text-primary);
}

[data-ui-mode="pro"] .card,
[data-ui-mode="pro"] .guide-card,
[data-ui-mode="pro"] .analysis-action-section,
[data-ui-mode="pro"] .side-panel,
[data-ui-mode="pro"] .history-panel,
[data-ui-mode="pro"] .poster-inspector,
[data-ui-mode="pro"] .poster-floating-panel,
[data-ui-mode="pro"] .template-confirm-dialog {
  border-radius: var(--radius-xl);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

[data-ui-mode="pro"] .card:hover,
[data-ui-mode="pro"] .guide-card:hover {
  box-shadow: var(--shadow-sm);
}

[data-ui-mode="pro"] .poster-entry-card {
  border-style: solid;
  background: var(--color-bg-card);
}

[data-ui-mode="pro"] .candy-stripe-bar {
  height: 1px;
  margin: var(--space-md) 0;
  background: var(--color-border);
  opacity: 1;
}

[data-ui-mode="pro"] .ui-mode-switch {
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
}

[data-ui-mode="pro"] .ui-mode-btn {
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
}

[data-ui-mode="pro"] .ui-mode-btn.active {
  background: var(--color-text-primary);
  color: var(--color-bg-card);
  box-shadow: none;
}

[data-ui-mode="pro"][data-theme="dark"] .ui-mode-btn.active {
  background: var(--color-text-primary);
  color: #242424;
}

[data-ui-mode="pro"] .app-version {
  border-color: var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-input);
  color: var(--color-text-secondary);
}

[data-ui-mode="pro"] .style-slider-label-left,
[data-ui-mode="pro"] .style-slider-label-right {
  color: var(--color-text-secondary);
}

[data-ui-mode="pro"] .style-slider-input {
  height: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-border);
}

[data-ui-mode="pro"] .style-slider-input::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-text-primary);
  border-color: var(--color-bg-card);
  box-shadow: none;
}

[data-ui-mode="pro"] .style-slider-input::-moz-range-thumb {
  background: var(--color-text-primary);
  border-color: var(--color-bg-card);
  box-shadow: none;
}

[data-ui-mode="pro"] .style-slider-tick.active {
  background: var(--color-text-primary);
}

[data-ui-mode="pro"] .style-slider-value {
  background: none;
  -webkit-text-fill-color: var(--color-text-primary);
  color: var(--color-text-primary);
}

[data-ui-mode="pro"] .slider-value {
  background: none;
  -webkit-text-fill-color: var(--color-text-primary);
  color: var(--color-text-primary);
}

[data-ui-mode="pro"] .slider-range {
  height: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-border);
}

[data-ui-mode="pro"] .slider-range::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-text-primary);
  border-color: var(--color-bg-card);
  box-shadow: none;
}

[data-ui-mode="pro"] .slider-range::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  box-shadow: none;
}

[data-ui-mode="pro"] .slider-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--color-text-primary);
  border-color: var(--color-bg-card);
  box-shadow: none;
}

[data-ui-mode="pro"] .slider-range::-moz-range-thumb:hover {
  transform: scale(1.12);
}

[data-ui-mode="pro"] .comp-pill.active,
[data-ui-mode="pro"] .preset-card.active {
  background: var(--color-bg-input);
  border-color: var(--color-text-primary);
  color: var(--color-text-primary);
  box-shadow: none;
}

[data-ui-mode="pro"] .poster-tool-btn {
  background: var(--color-bg-card);
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-ui-mode="pro"] .poster-tool-btn:hover,
[data-ui-mode="pro"] .poster-tool-btn.active {
  background: var(--color-bg-input);
  border-color: var(--color-text-secondary);
  box-shadow: none;
}

[data-ui-mode="pro"] .poster-tool-btn.active {
  color: var(--color-text-primary);
}

[data-ui-mode="pro"] .poster-group > summary {
  background: var(--color-bg-input);
}
