/* ============================================================
   CSS VARIABLES — macOS Bright Theme
   ============================================================ */
:root {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #fafafa;
  --bg-glass: rgba(255,255,255,0.72);
  --border-light: rgba(0,0,0,0.06);
  --border-medium: rgba(0,0,0,0.1);
  --border-focus: rgba(0,122,255,0.5);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent: #007aff;
  --accent-hover: #0063d1;
  --accent-light: rgba(0,122,255,0.08);
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --red-bg: rgba(255,59,48,0.08);
  --yellow: #ffcc00;
  --purple: #af52de;
  --pink: #ff2d55;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  --font: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; line-height: 1.6; }
img { display: block; max-width: 100%; }
button, select, input { font-family: inherit; }
::selection { background: var(--accent); color: #fff; }

.app-shell { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-light); border-radius: var(--radius-xl);
  margin-bottom: 24px; position: sticky; top: 12px; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.app-logo { display: flex; align-items: center; gap: 12px; }
.app-logo-icon { width: 40px; height: 40px; border-radius: var(--radius-md); object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.app-logo h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.app-logo h1 span { color: var(--text-tertiary); font-weight: 500; font-size: 12px; margin-left: 6px; }

.lang-switcher { display: flex; align-items: center; gap: 4px; background: rgba(0,0,0,0.04); border-radius: 980px; padding: 3px; }
.lang-btn { padding: 5px 10px; font-size: 12px; font-weight: 600; border: none; border-radius: 980px; background: transparent; color: var(--text-tertiary); cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.lang-btn:hover { color: var(--text-primary); }
.lang-btn.active { background: var(--bg-secondary); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ============================================================
   HERO
   ============================================================ */
.hero-section { text-align: center; padding: 40px 20px 48px; margin-bottom: 24px; background: linear-gradient(180deg, rgba(175,82,222,0.04) 0%, transparent 100%); border-radius: var(--radius-xl); position: relative; overflow: hidden; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: linear-gradient(135deg, rgba(175,82,222,0.1), rgba(255,45,85,0.1)); border: 1px solid rgba(175,82,222,0.15); border-radius: 980px; font-size: 12px; font-weight: 600; color: var(--purple); margin-bottom: 16px; }
.hero-title { font-size: 36px; font-weight: 900; letter-spacing: -1px; line-height: 1.2; margin-bottom: 12px; background: linear-gradient(135deg, #1d1d1f 0%, #6e6e73 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-subtitle { font-size: 16px; color: var(--text-secondary); max-width: 520px; margin: 0 auto 24px; line-height: 1.6; }
.hero-features { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.hero-feature { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.hero-feature .hf-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; }

/* ============================================================
   CARD / FORM
   ============================================================ */
.card { background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-body { padding: 24px; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.card-title .icon { width: 28px; height: 28px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }

.form-group { margin-bottom: 16px; }
.form-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.form-select, .form-input {
  width: 100%; padding: 10px 14px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border-medium); border-radius: var(--radius-sm);
  background: var(--bg-tertiary); color: var(--text-primary);
  outline: none; transition: all var(--transition);
}
.form-select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }
.form-select:focus, .form-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(0,122,255,0.15); }
.form-input::placeholder { color: var(--text-tertiary); }

/* Role Toggle */
.role-toggle { display: flex; background: var(--bg-tertiary); border: 1px solid var(--border-medium); border-radius: var(--radius-sm); overflow: hidden; }
.role-btn { flex: 1; padding: 10px; font-size: 14px; font-weight: 600; border: none; background: transparent; cursor: pointer; transition: all var(--transition); color: var(--text-tertiary); }
.role-btn.active-male { background: var(--accent); color: #fff; }
.role-btn.active-female { background: var(--pink); color: #fff; }

/* Upload Zone */
.upload-zone { position: relative; aspect-ratio: 4/3; border: 2px dashed var(--border-medium); border-radius: var(--radius-lg); background: var(--bg-tertiary); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); overflow: hidden; margin-bottom: 20px; }
.upload-zone:hover { border-color: var(--accent); background: var(--accent-light); }
.upload-zone.has-image { border-style: solid; border-color: var(--border-light); }
.upload-zone img { width: 100%; height: 100%; object-fit: cover; }
.upload-placeholder { text-align: center; color: var(--text-tertiary); }
.upload-placeholder svg { margin: 0 auto 12px; opacity: 0.4; }
.upload-placeholder .main-text { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.upload-placeholder .sub-text { font-size: 12px; margin-top: 4px; }

/* Generate Button */
.btn-generate { width: 100%; padding: 14px 24px; font-size: 15px; font-weight: 700; border-radius: var(--radius-md); background: linear-gradient(135deg, #af52de, #5856d6); color: #fff; border: none; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 16px rgba(175,82,222,0.25); margin-top: 20px; }
.btn-generate:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(175,82,222,0.35); transform: translateY(-1px); }
.btn-generate:disabled { background: rgba(0,0,0,0.08); color: var(--text-tertiary); box-shadow: none; cursor: not-allowed; }
.btn-generate.loading { background: linear-gradient(135deg, #af52de, #5856d6); pointer-events: none; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; font-size: 13px; font-weight: 600; border-radius: 980px; border: none; cursor: pointer; transition: all var(--transition); white-space: nowrap; user-select: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-green { background: var(--green); color: #fff; }
.btn-yellow { background: var(--yellow); color: #1d1d1f; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }

.error-msg { margin-top: 12px; padding: 12px 14px; background: var(--red-bg); border: 1px solid rgba(255,59,48,0.15); border-radius: var(--radius-sm); font-size: 13px; color: var(--red); display: flex; align-items: flex-start; gap: 8px; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }

/* ============================================================
   RESULT PANEL
   ============================================================ */
.result-preview { position: relative; background: var(--bg-tertiary); border-radius: var(--radius-lg); border: 1px solid var(--border-light); overflow: hidden; min-height: 400px; display: flex; align-items: center; justify-content: center; }
.result-preview img { width: 100%; height: auto; display: block; }
.result-preview .overlay-actions { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; opacity: 0; transition: opacity var(--transition); }
.result-preview:hover .overlay-actions { opacity: 1; }
.overlay-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-light); background: var(--bg-glass); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); color: var(--accent); }
.overlay-btn:hover { background: var(--accent); color: #fff; }
.overlay-btn svg { width: 16px; height: 16px; }
.result-preview .regen-overlay { position: absolute; inset: 0; background: rgba(255,255,255,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }

.result-info { margin-top: 16px; }
.result-info .drama-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.result-info .drama-subtitle { font-size: 14px; font-weight: 600; color: var(--purple); margin-bottom: 8px; }
.result-info .drama-cast { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.result-info .drama-plot { font-size: 13px; color: var(--text-secondary); line-height: 1.5; border-left: 3px solid var(--purple); padding-left: 12px; font-style: italic; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; color: var(--text-tertiary); text-align: center; padding: 40px; }
.empty-state .emoji { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state .title { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.empty-state .subtitle { font-size: 13px; margin-top: 4px; }

/* Platform Logo Overlay */
.platform-logo { position: absolute; bottom: 16px; width: 20%; max-width: 120px; filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5)); pointer-events: none; }
.platform-logo.left { left: 16px; }
.platform-logo.right { right: 16px; }

/* ============================================================
   SEO SECTIONS
   ============================================================ */
.seo-section { margin-top: 40px; padding: 48px 24px; background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.seo-section-title { text-align: center; font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.seo-section-subtitle { text-align: center; font-size: 14px; color: var(--text-secondary); margin-bottom: 36px; max-width: 480px; margin-left: auto; margin-right: auto; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature-card { padding: 24px; background: var(--bg-tertiary); border-radius: var(--radius-lg); border: 1px solid var(--border-light); transition: all var(--transition); text-align: center; }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-card .fc-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 24px; margin: 0 auto 14px; }
.feature-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.howto-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: step; }
.howto-step { position: relative; padding: 24px; background: var(--bg-tertiary); border-radius: var(--radius-lg); border: 1px solid var(--border-light); text-align: center; }
.howto-step::before { counter-increment: step; content: counter(step); display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: linear-gradient(135deg, #af52de, #5856d6); color: #fff; font-weight: 800; font-size: 16px; border-radius: 50%; margin: 0 auto 14px; }
.howto-step h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.howto-step p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.app-footer { text-align: center; padding: 32px 20px; margin-top: 40px; color: var(--text-tertiary); font-size: 12px; }

.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .howto-steps { grid-template-columns: repeat(2, 1fr); }
  .app-header { position: relative; top: 0; }
  .hero-title { font-size: 28px; }
}
@media (max-width: 640px) {
  .app-shell { padding: 12px; }
  .app-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-radius: var(--radius-lg); }
  .lang-switcher { order: 3; width: 100%; justify-content: center; }
  .card-body { padding: 16px; }
  .hero-section { padding: 28px 16px 32px; }
  .hero-title { font-size: 24px; }
  .features-grid { grid-template-columns: 1fr; }
  .howto-steps { grid-template-columns: 1fr; }
  .seo-section { padding: 32px 16px; }
  .btn-generate { font-size: 14px; padding: 12px 20px; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
