@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=swap');

:root {
  /* ── Palette (from web-front-end) ── */
  --gold:        #fabe00;
  --gold-dark:   #f18900;
  --gold-light:  #ffd84d;
  --gold-glow:   rgba(250,190,0,.28);
  --dark:        #101317;
  --dark2:       #1c2129;
  --white:       #ffffff;
  --beige:       #efece7;
  --beige2:      #e5e1da;
  --border:      #e0dbd3;
  --border-dark: #2a3140;
  --text:        #101317;
  --text-muted:  #6b6560;
  --text-dim:    #a09990;
  --green:       #16a34a;
  --red:         #c00000;
  --blue:        #63709c;
  --orange:      #f18900;

  /* ── Tokens ── */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-pill: 28px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow:    0 4px 16px rgba(0,0,0,.08);
  --shadow-gold: 0 4px 20px rgba(250,190,0,.30);
}

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

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--beige);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Login screen */
#login-screen { background: var(--beige); }
#login-screen .sidebar-logo { padding: 0 0 20px; }
#login-screen input { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; }

/* Login tabs */
.login-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.login-tab:hover { color: var(--text); }
.login-tab.active {
  color: var(--gold-dark);
  border-bottom-color: var(--gold);
}

/* Sidebar — dark, matching web-front-end nav drawer */
.sidebar {
  width: 220px;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  flex-shrink: 0;
  border-radius: 0 16px 16px 0;   /* curved right edge */
}

.sidebar-logo {
  padding: 0 22px 28px;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.4px;
}
.sidebar-logo span { color: #8a8f96; font-weight: 400; }

/* New: branded sidebar header */
.sidebar-brand {
  padding: 0 18px 24px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 14px;
}
.sidebar-brand-mark {
  display: block;
  width: 100%;
  max-width: 160px;
  height: auto;
  margin: 0 auto 14px;
  filter: drop-shadow(0 3px 14px rgba(250,190,0,.25));
}
.sidebar-brand-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.4px;
  line-height: 1.25;
  margin-bottom: 6px;
}
.sidebar-brand-tag {
  font-size: 11px;
  color: #fff;
  line-height: 1.55;
  margin-bottom: 14px;
  opacity: .92;
}
.sidebar-brand-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  color: #6f7480;
  padding-top: 10px;
  border-top: 1px dashed rgba(255,255,255,.07);
}
.sidebar-brand-by img {
  height: 14px;
  width: auto;
  opacity: .9;
  filter: brightness(1.1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 22px;
  color: #8a8f96;
  cursor: pointer;
  transition: all .2s;
  user-select: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  margin-right: 16px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #e0ddd7; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(250,190,0,.18), rgba(241,137,0,.10));
  color: var(--gold);
  border-right: 3px solid var(--gold);
}
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.main {
  flex: 1;
  overflow-y: scroll;             /* 永遠保留捲軸槽，不會內容變動時跳動 */
  display: flex;
  flex-direction: column;
  scrollbar-gutter: stable;
}
/* 自訂捲軸樣式（明顯但不刺眼） */
.main::-webkit-scrollbar { width: 12px; }
.main::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); }
.main::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
.main::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); background-clip: padding-box; border: 2px solid transparent; }

.topbar {
  padding: 18px 28px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: 18px; font-weight: 700; color: var(--text); }

.content { padding: 24px 28px; flex: 1; }

/* ══════════════════════════════════════════════════════
   CARDS & GRIDS
══════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow); }
.card, .card:hover { transition: box-shadow .2s; }

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

/* ══════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--dark);
  box-shadow: 0 2px 8px var(--gold-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--gold-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: rgba(192,0,0,.08);
  color: var(--red);
  border: 1.5px solid rgba(192,0,0,.2);
}
.btn-danger:hover { background: rgba(192,0,0,.15); transform: translateY(-1px); }

.btn-success {
  background: rgba(22,163,74,.1);
  color: var(--green);
  border: 1.5px solid rgba(22,163,74,.25);
}
.btn-success:hover { background: rgba(22,163,74,.18); transform: translateY(-1px); }

.btn-sm { padding: 5px 14px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ══════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
}

input[type=text], textarea, select {
  width: 100%;
  background: var(--beige);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(250,190,0,.15);
  background: var(--white);
}
textarea { resize: vertical; min-height: 80px; }

/* ══════════════════════════════════════════════════════
   STATUS BADGES
══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}
.badge-pending      { background: #f0ede8; color: var(--text-muted); }
.badge-none         { background: #f0ede8; color: var(--text-muted); }
.badge-queued       { background: rgba(99,112,156,.08); color: var(--blue); opacity: .75; }
.badge-scraping     { background: rgba(99,112,156,.12); color: var(--blue); }
.badge-transcribing { background: rgba(241,137,0,.12); color: var(--orange); }
.badge-analyzing    { background: rgba(250,190,0,.15); color: #a07000; }
.badge-done         { background: rgba(22,163,74,.10); color: var(--green); }
.badge-error        { background: rgba(192,0,0,.10);   color: var(--red); }
.badge-draft        { background: #f0ede8; color: var(--text-muted); }
.badge-generating   { background: rgba(99,112,156,.12); color: var(--blue); }
.badge-sent_to_brand       { background: rgba(250,190,0,.15); color: #a07000; }
.badge-revision_requested  { background: rgba(192,0,0,.10);   color: var(--red); }
.badge-approved            { background: rgba(22,163,74,.10);  color: var(--green); }

/* ══════════════════════════════════════════════════════
   CREATOR CARDS
══════════════════════════════════════════════════════ */
.creator-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.creator-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}
.creator-card .username { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.creator-card .meta { color: var(--text-muted); font-size: 12px; display: flex; gap: 12px; margin-bottom: 10px; }
.creator-card .actions { display: flex; gap: 8px; margin-top: 12px; }

/* ══════════════════════════════════════════════════════
   SCRIPT VIEWER
══════════════════════════════════════════════════════ */
.script-section {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.script-section-header {
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(250,190,0,.08), transparent);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
}
.script-section-header .label { color: var(--gold-dark); }
.script-section-body {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ══════════════════════════════════════════════════════
   COMMENTS
══════════════════════════════════════════════════════ */
.comment-item {
  padding: 12px 14px;
  border-left: 3px solid var(--border);
  margin-bottom: 10px;
  background: var(--beige);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.comment-item.brand   { border-left-color: var(--blue); }
.comment-item.creator { border-left-color: var(--gold); }
.comment-item.resolved { opacity: .5; }
.comment-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.comment-meta .role { font-weight: 700; }
.comment-meta .role.brand   { color: var(--blue); }
.comment-meta .role.creator { color: var(--gold-dark); }

/* Sticky note (inline annotation) */
.sticky-note {
  background: #fffbe6;
  border: 1px solid #ffe066;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.sticky-note.resolved { opacity: .45; }
.sticky-note-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-bottom: 6px;
  font-size: 11px;
  min-width: 0;
}
.sticky-note-header > * { flex-shrink: 0; }
.sticky-seg {
  background: #fabe00;
  color: #101317;
  font-weight: 700;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 20px;
}
.sticky-quote {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  border-left: 2px solid #fabe00;
  padding-left: 7px;
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.sticky-note textarea {
  max-width: 100%;
  box-sizing: border-box;
}
#inline-annotations-list { min-width: 0; }
#inline-annotations-card { overflow: hidden; }

/* Suggestion-mode toolbar accent */
#diff-toolbar { transition: background .2s, border-color .2s; }
#diff-toolbar:has(#btn-cancel-suggestion[style*="display: none"]) { /* normal diff */ }
#diff-toolbar:has(#btn-cancel-suggestion:not([style*="display: none"])) {
  background: rgba(250,190,0,.08);
  border-color: var(--gold);
}

/* Pending highlight — shown while popup is open, before submitting */
mark.pending-highlight {
  background: rgba(250,190,0,.18);
  border-bottom: 2px dashed #f18900;
  border-radius: 2px;
  padding: 1px 0;
}

/* Inline annotation highlight (Google Docs style) */
mark.annotation-highlight {
  background: rgba(250,190,0,.38);
  border-bottom: 2px solid #f18900;
  border-radius: 2px;
  cursor: pointer;
  padding: 1px 0;
  transition: background .15s;
}
mark.annotation-highlight:hover {
  background: rgba(241,137,0,.55);
}

/* Pulse animation when sidebar item is clicked → mark in script */
@keyframes mark-pulse-anim {
  0%   { box-shadow: 0 0 0 0 rgba(241,137,0,.7);   transform: scale(1); }
  50%  { box-shadow: 0 0 0 12px rgba(241,137,0,0); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 0 rgba(241,137,0,0);    transform: scale(1); }
}
mark.mark-pulse {
  animation: mark-pulse-anim 0.9s ease-out 1;
  position: relative;
  z-index: 1;
}

/* Row pulse for missing-original case */
@keyframes row-pulse-missing-anim {
  0%, 100% { background: transparent; }
  30%      { background: rgba(192,0,0,.10); }
}
tr.row-pulse-missing {
  animation: row-pulse-missing-anim 1.6s ease-out 1;
}

/* "結案此討論" — clearly clickable, distinct from passive UI text */
.btn-resolve-thread {
  background: rgba(22,163,74,.12);
  color: var(--green);
  border: 1px solid rgba(22,163,74,.45);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-resolve-thread:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

/* Round-summary banner: tells brand/creator which segments changed since last submission */
#round-summary-banner {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(250,190,0,.10), rgba(99,112,156,.08));
  border: 1px solid rgba(250,190,0,.4);
  border-radius: 8px;
}
.round-summary-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.round-summary-headline {
  font-weight: 700;
  color: var(--gold-dark);
  margin-right: 4px;
}
.round-summary-chip {
  background: var(--gold);
  color: #101317;
  font-weight: 600;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s;
}
.round-summary-chip:hover { background: var(--gold-dark); color: #fff; }

/* Generic app toast (status confirmations, etc.) */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 3000;
  max-width: min(480px, 90vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.app-toast.info    { background: rgba(20,25,35,.94);   color: #fff; }
.app-toast.success { background: rgba(22,163,74,.96);  color: #fff; }
.app-toast.warn    { background: rgba(241,137,0,.96);  color: #fff; }

/* Floating toast for "original deleted" */
.focus-missing-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,25,35,.94);
  color: #fff;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 3000;
  width: min(360px, 90vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.focus-missing-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Hover affordance on sidebar cards */
.sticky-note:hover, .edit-suggestion-card:hover {
  outline: 2px solid rgba(250,190,0,.45);
  outline-offset: -1px;
}
.edit-suggestion-card:hover {
  outline-color: rgba(99,112,156,.55);
}

/* Edit suggestion card in the sidebar */
.edit-suggestion-card {
  background: rgba(99,112,156,.06);
  border: 1px solid rgba(99,112,156,.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.edit-suggestion-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-bottom: 4px;
  font-size: 11px;
}
.edit-suggestion-tag {
  background: #63709c;
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 20px;
}

/* Edit suggestion highlight (blue, distinct from comment annotation) */
mark.edit-highlight {
  background: rgba(99,112,156,.28);
  border-bottom: 2px solid #63709c;
  border-radius: 2px;
  cursor: pointer;
  padding: 1px 0;
  transition: background .15s;
}
mark.edit-highlight:hover {
  background: rgba(99,112,156,.50);
}
mark.edit-highlight::after {
  content: '✏';
  font-size: 9px;
  vertical-align: super;
  margin-left: 1px;
  opacity: .7;
}

/* Annotated table row (Jira-style) */
.script-table tbody tr.row-annotated {
  background: rgba(250,190,0,.07);
  border-left: 3px solid #fabe00;
}
.script-table tbody tr.row-annotated td:first-child {
  padding-left: 9px;
}

/* Annotation marker badge on label cell */
.annotation-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  background: #fabe00;
  color: #101317;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 0 4px;
  margin-left: 5px;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1;
}
.annotation-marker:hover { background: #f18900; }

/* Annotation section titles + state badges */
.ann-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 4px 0 8px;
  letter-spacing: 0.5px;
}
.thread-state-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.state-pending-creator { background: rgba(241,137,0,.18);  color: var(--orange); }
.state-pending-brand   { background: rgba(99,112,156,.18); color: var(--blue); }
.state-resolved        { background: rgba(22,163,74,.15);  color: var(--green); }

.carryover-badge {
  display: inline-block;
  font-size: 10px;
  background: rgba(0,0,0,.08);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
}
.carryover-badge:hover { background: rgba(0,0,0,.16); color: var(--text); }

/* Reply inside sticky note */
.annotation-reply {
  margin-top: 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,.7);
  border-radius: 6px;
  border-left: 2px solid #ccc;
  font-size: 12px;
}
.reply-author {
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,19,23,.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}
.modal {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  padding: 28px;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,.14);
  margin: auto;
}
.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  background: var(--beige);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px; height: 30px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--beige2); color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ══════════════════════════════════════════════════════
   MISC UTILITIES
══════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 24px;
  font-size: 13px;
}
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }

.log-box {
  background: var(--dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #9db8b2;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--beige);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .15s;
  color: var(--text-muted);
}
.version-pill.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-color: transparent;
  color: var(--dark);
  font-weight: 700;
  box-shadow: 0 2px 8px var(--gold-glow);
}
.version-pill:hover:not(.active) { border-color: var(--gold); color: var(--gold-dark); }

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

.flex          { display: flex; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.mb-4          { margin-bottom: 4px; }
.mb-8          { margin-bottom: 8px; }
.mb-12         { margin-bottom: 12px; }
.mb-16         { margin-bottom: 16px; }
.mb-20         { margin-bottom: 20px; }
.mt-8          { margin-top: 8px; }
.mt-12         { margin-top: 12px; }
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: 12px; }
.text-accent   { color: var(--gold-dark); }
.fw-600        { font-weight: 600; }

/* ══════════════════════════════════════════════════════
   SPINNER
══════════════════════════════════════════════════════ */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

/* ══════════════════════════════════════════════════════
   PROJECT & SCRIPT LAYOUTS
══════════════════════════════════════════════════════ */
.project-detail { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: stretch; }
.project-detail > .card { display: flex; flex-direction: column; }
.project-detail > .card > #project-scripts-list,
.project-detail > .card > #requirements-view { flex: 1; }
@media (max-width: 900px) { .project-detail { grid-template-columns: 1fr; } }

/* Collapsible 拍攝說明卡片 */
.brief-card .brief-collapsible {
  position: relative;
  overflow: hidden;
  transition: max-height .25s ease;
}
.brief-card.collapsed .brief-collapsible {
  max-height: 200px;
}
.brief-card.collapsed .brief-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), var(--white));
  pointer-events: none;
}
.brief-card:not(.collapsed) .brief-fade {
  display: none;
}
.brief-card:not(.collapsed) .brief-collapsible {
  max-height: none;
}

/* Bottom row of "data enrichment" cards under the project-detail grid */
.project-enrichment-row {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}
.enrichment-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: stretch;       /* 三張卡片等高 */
}
.enrichment-grid > .card {
  display: flex;
  flex-direction: column;
}
/* 把每張卡的「儲存 / 解析重點 / 上傳一張圖」按鈕推到底部，視覺更整齊 */
.enrichment-grid > .card > button:last-child,
.enrichment-grid > .card #btn-save-brand-ref,
.enrichment-grid > .card #btn-parse-comms,
.enrichment-grid > .card #btn-upload-mood {
  margin-top: auto;
}
@media (max-width: 1100px) { .enrichment-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .enrichment-grid { grid-template-columns: 1fr; } }

.script-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.script-list-item:hover {
  border-color: var(--gold);
  transform: translateX(3px);
  box-shadow: var(--shadow);
}

/* ══════════════════════════════════════════════════════
   DIFF VIEW
══════════════════════════════════════════════════════ */
.diff-del {
  background: rgba(192,0,0,.10);
  color: #b51c1c;
  text-decoration: line-through;
  text-decoration-color: rgba(192,0,0,.45);
  border-radius: 3px;
  padding: 1px 3px;
  margin: 0 1px;
  display: inline-block;
  line-height: 1.5;
}
.diff-ins {
  background: rgba(22,163,74,.12);
  color: #15803d;
  border-radius: 3px;
  padding: 1px 3px;
  margin: 0 1px;
  display: inline-block;
  line-height: 1.5;
  font-weight: 500;
}
.diff-del + .diff-ins,
.diff-ins + .diff-del { margin-left: 3px; }
/* Word-level op buttons (↩ / ×) */
.diff-del, .diff-ins { position: relative; cursor: pointer; }
.diff-del:hover { background: rgba(192,0,0,.18); }
.diff-ins:hover { background: rgba(22,163,74,.2); }
.diff-word-btn {
  display: none;
  position: absolute;
  top: -9px;
  right: -6px;
  font-size: 10px;
  line-height: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  text-align: center;
  cursor: pointer;
  font-style: normal;
  z-index: 10;
  font-weight: 700;
  pointer-events: all;
}
.diff-ins .diff-word-btn  { background: #c00; color: #fff; }
.diff-del .diff-word-btn  { background: #16a34a; color: #fff; }
.diff-ins:hover .diff-word-btn,
.diff-del:hover .diff-word-btn { display: inline-block; }
/* Editable cell in diff mode (accepted segment): subtle green left border */
td.diff-accepted[contenteditable="true"] {
  border-left: 3px solid rgba(22,163,74,.5);
  outline: none;
  background: rgba(22,163,74,.03);
}
/* Block-level replace: full old line → full new line, no inline mixing */
.diff-block {
  display: block;
  margin: 2px 0;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.6;
  white-space: pre-wrap;
}
/* Bigger line-height + word-break for diff cells */
.script-table td.seg-visual,
.script-table td.seg-narration {
  word-break: break-word;
  overflow-wrap: anywhere;
}
.diff-section-unchanged .script-section-header { opacity: .4; }

.diff-decision-bar {
  display: flex;
  gap: 6px;
  padding: 8px 16px 10px;
  background: var(--beige);
  border-top: 1px solid var(--border);
  align-items: center;
}
.diff-decision-bar .decision-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 4px;
  font-weight: 600;
}

.btn-accept {
  background: rgba(22,163,74,.1);
  color: var(--green);
  border: 1.5px solid rgba(22,163,74,.25);
  font-size: 11px; font-weight: 600;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .15s;
}
.btn-accept.selected, .btn-accept:hover { background: rgba(22,163,74,.2); }

.btn-reject {
  background: rgba(192,0,0,.08);
  color: var(--red);
  border: 1.5px solid rgba(192,0,0,.2);
  font-size: 11px; font-weight: 600;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .15s;
}
.btn-reject.selected, .btn-reject:hover { background: rgba(192,0,0,.15); }

.btn-suggest {
  background: rgba(250,190,0,.1);
  color: var(--gold-dark);
  border: 1.5px solid rgba(250,190,0,.3);
  font-size: 11px; font-weight: 600;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .15s;
}
.btn-suggest.selected, .btn-suggest:hover { background: rgba(250,190,0,.2); }

/* ══════════════════════════════════════════════════════
   REQUIREMENTS
══════════════════════════════════════════════════════ */
.req-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--beige);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 13px;
}
/* Compact row-style layout used only in project-detail's requirements list,
   where space is tight and items don't have inline editing controls. */
#requirements-view .req-item {
  flex-direction: row;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 5px;
  font-size: 12.5px;
}
#requirements-view .req-item .req-badges {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  align-items: flex-start;
}
#requirements-view .req-item .req-text {
  flex: 1;
  min-width: 0;
  line-height: 1.5;
  word-break: break-word;
}
#requirements-view {
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}
.requirements-ai-note {
  font-size: 11.5px;
  line-height: 1.5;
  color: #5a6890;
  background: rgba(99,112,156,.08);
  border: 1px dashed rgba(99,112,156,.35);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  margin-bottom: 8px;
}
.requirements-ai-note b { color: var(--text); font-weight: 600; }
.requirements-extracting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  font-size: 13px;
  color: #5a6890;
  background: rgba(99,112,156,.08);
  border: 1px solid rgba(99,112,156,.25);
  border-radius: var(--radius-sm);
}
.requirements-extracting .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(99,112,156,.25);
  border-top-color: #63709c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ──────────────── Collapsible cards (script-detail right column) ──────────────── */
/* Hide the literal button text — actual label is rendered via ::before so it
   can change between "收合 ▾" / "展開 ▸" without touching the DOM. */
.collapsible-card .card-collapse-btn {
  padding: 4px 11px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: var(--radius-pill);
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.collapsible-card .card-collapse-btn::before {
  content: "收合 ▾";
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .3px;
}
.collapsible-card.collapsed .card-collapse-btn {
  background: rgba(250,190,0,.12);
  border-color: rgba(250,190,0,.45);
}
.collapsible-card.collapsed .card-collapse-btn::before {
  content: "展開 ▸";
  color: var(--gold-dark);
  font-weight: 700;
}
.collapsible-card .card-collapse-btn:hover {
  background: var(--gold);
  border-color: var(--gold);
}
.collapsible-card .card-collapse-btn:hover::before { color: #101317; }

.collapsible-card.collapsed .card-body { display: none; }
.collapsible-card.collapsed { padding-top: 12px; padding-bottom: 12px; }
.collapsible-card.collapsed > .flex-between,
.collapsible-card.collapsed > div:first-child { margin-bottom: 0 !important; }

/* Inline "🤖 請 AI 自動審核" call-to-action — sits next to the card title. */
.btn-ai-inline {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, rgba(99,112,156,.15), rgba(250,190,0,.15));
  color: #5a6890;
  border: 1px dashed #63709c;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.btn-ai-inline:hover {
  background: linear-gradient(135deg, rgba(99,112,156,.28), rgba(250,190,0,.3));
  color: var(--text);
  border-style: solid;
  border-color: var(--gold);
  transform: translateY(-1px);
}
.btn-ai-inline:active { transform: translateY(0); }
.btn-ai-inline:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

/* AI-confirmed requirement marker */
.req-item .req-ai-verdict {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(99,112,156,.12);
  color: #5a6890;
  border: 1px solid rgba(99,112,156,.3);
}
.req-item .req-ai-verdict.met { background: rgba(22,163,74,.12); color: var(--green); border-color: rgba(22,163,74,.3); }
.req-item .req-ai-verdict.unmet { background: rgba(192,0,0,.08); color: var(--red); border-color: rgba(192,0,0,.25); }
.req-status-tag {
  font-size: 10px;
  background: rgba(22,163,74,.12);
  color: var(--green);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}
.req-item .req-note-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}
.req-item .req-note-input:focus {
  outline: none;
  border-color: var(--gold);
}
.req-item .req-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}
.req-item.mandatory .req-badge { background: rgba(192,0,0,.1); color: var(--red); }
.req-item.optional  .req-badge { background: rgba(250,190,0,.15); color: #a07000; }
.req-type-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

/* AI 對應說明（從 script.requirement_coverage 讀） */
.req-ai-note {
  width: 100%;
  margin-top: 6px;
  padding: 6px 9px 7px;
  background: rgba(99,112,156,.08);
  border-left: 3px solid #63709c;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.55;
}
.req-ai-note > div { margin-top: 2px; color: var(--text); }

/* Check status (auto-check against script) */
.req-item .req-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.req-item.req-met   .req-check { background: var(--green); color: #fff; }
.req-item.req-unmet .req-check { background: rgba(192,0,0,.12); color: var(--red); }
.req-item.req-met   { opacity: .65; }
.req-item.req-unmet.mandatory { border-color: rgba(192,0,0,.4); background: rgba(192,0,0,.04); }

.req-summary {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.req-summary-ok   { background: rgba(22,163,74,.1);  color: var(--green); }
.req-summary-warn { background: rgba(192,0,0,.08);   color: var(--red); }

/* ══════════════════════════════════════════════════════
   PROFILE TYPE TABS
══════════════════════════════════════════════════════ */
.profile-tab {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--beige);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.profile-tab:hover { border-color: var(--gold); color: var(--gold-dark); }
.profile-tab.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #101317;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════
   SCRIPT TABLE (segment format)
══════════════════════════════════════════════════════ */
.script-table-wrap {
  overflow-x: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
}
.script-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.6;
}
.script-table thead th {
  background: var(--dark);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border-dark);
}
.script-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.script-table tbody tr:last-child { border-bottom: none; }
.script-table tbody tr:hover { background: var(--beige); }
.script-table td {
  padding: 10px 12px;
  vertical-align: top;
  outline: none;
}
.script-table td[contenteditable] {
  cursor: text;
  position: relative;
  transition: background .12s, box-shadow .12s;
}
.script-table td[contenteditable]::before {
  content: '✏';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  opacity: 0;
  color: var(--gold-dark);
  pointer-events: none;
  transition: opacity .12s;
}
.script-table td[contenteditable]:hover {
  background: rgba(250,190,0,.06);
  box-shadow: inset 0 0 0 1.5px rgba(250,190,0,.25);
  border-radius: 4px;
}
.script-table td[contenteditable]:hover::before { opacity: .5; }
.script-table td[contenteditable]:focus {
  background: rgba(250,190,0,.05);
  box-shadow: inset 0 0 0 2px rgba(250,190,0,.45);
  border-radius: 4px;
}
.script-table td[contenteditable]:focus::before { opacity: 0; }
.edit-hint-banner {
  font-size: 12px;
  color: var(--gold-dark);
  background: rgba(250,190,0,.08);
  border: 1px dashed rgba(250,190,0,.4);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}
.edit-hint-banner b { color: var(--text); font-weight: 600; }

.required-asterisk {
  color: var(--red);
  font-weight: 700;
  margin-left: 2px;
}
.brand-emails-warning {
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--red);
  background: rgba(192,0,0,.06);
  border: 1px solid rgba(192,0,0,.25);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}
#project-brand-emails-wrap.is-missing #project-brand-emails-input {
  border-color: var(--red);
  background: rgba(192,0,0,.03);
}
.seg-label {
  font-weight: 700;
  font-size: 18px;
  color: var(--gold-dark);
  text-align: center;
  vertical-align: middle !important;
  width: 54px;
  position: relative;
}
.seg-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(192,0,0,.1);
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.script-table tbody tr:hover .seg-delete-btn { opacity: 1; }
.seg-delete-btn:hover { background: var(--red); color: #fff; }
.seg-seconds {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  vertical-align: middle !important;
  white-space: nowrap;
}
.seg-visual {
  color: var(--text-muted);
  font-size: 12px;
}
.seg-narration {
  color: var(--text);
  font-size: 13.5px;
}
.seg-notes {
  font-size: 12px;
  color: var(--text-dim);
}

/* ══════════════════════════════════════════════════════
   GENERATING OVERLAY — fun message icon spin
══════════════════════════════════════════════════════ */
@keyframes gen-icon-spin {
  0%   { transform: rotate(-8deg) scale(1); }
  25%  { transform: rotate(12deg) scale(1.15); }
  50%  { transform: rotate(-6deg) scale(1); }
  75%  { transform: rotate(10deg) scale(1.1); }
  100% { transform: rotate(-8deg) scale(1); }
}

/* ══════════════════════════════════════════════════════
   PRE-GEN STATE — attention animations
══════════════════════════════════════════════════════ */
@keyframes btn-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250,190,0,.5), var(--shadow-gold); }
  50%       { box-shadow: 0 0 0 6px rgba(250,190,0,.0), var(--shadow-gold); }
}
.btn-pulse {
  animation: btn-pulse-glow 1.6s ease-in-out infinite;
}

@keyframes bounce-right {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(6px); }
}

/* ══════════════════════════════════════════════════════
   AI GENERATING — flowing conic-gradient border
   Uses padding-box/border-box multi-background trick so
   the card's white fill stays intact without pseudo-elements.
══════════════════════════════════════════════════════ */
@property --ai-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes ai-border-spin {
  to { --ai-angle: 360deg; }
}

@keyframes ai-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px 2px rgba(250,190,0,.55), 0 0 22px 4px rgba(0,212,255,.18); }
  50%       { box-shadow: 0 0 10px 3px rgba(0,212,255,.6), 0 0 26px 6px rgba(241,137,0,.2); }
}

.ai-generating {
  background:
    linear-gradient(#fff, #fff) padding-box,
    conic-gradient(
      from var(--ai-angle),
      #fabe00 0%,
      #f18900 15%,
      #00d4ff 35%,
      #0088cc 52%,
      #00d4ff 68%,
      #f18900 82%,
      #fabe00 100%
    ) border-box !important;
  border: 2px solid transparent !important;
  animation: ai-border-spin 2s linear infinite, ai-glow-pulse 2s ease-in-out infinite;
  transition: none !important;
}

/* The overlay card has a larger border-radius */
#generating-overlay-card.ai-generating { border-radius: 16px !important; }

/* ══════════════════════════════════════════════════════
   SCROLL STYLING
══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--beige2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
