/* ============================================
   Character System
   ============================================ */

/* --- Characters List Page --- */
.chars-page {
  padding-top: var(--nav-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chars-container {
  width: 100%;
  max-width: 1200px;
  padding: 8px 48px 120px;
  flex: 1;
}

.chars-header {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  margin-bottom: 40px;
}

.chars-count {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  opacity: 0.7;
}

/* --- Character Card Grid --- */
.chars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 36px 28px;
}

/* Empty state */
.chars-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 24px;
  text-align: center;
}

.chars-empty-icon {
  font-size: 3rem;
  color: var(--bg-hover);
  margin-bottom: 20px;
}

.chars-empty-text {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.chars-empty-sub {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.6;
}

/* --- Individual Character Card --- */
.char-card-wrapper {
  display: flex;
  height: 100%;
  min-width: 0; /* allow grid item to shrink below content min-width (prevents iOS zoom-out) */
}

.char-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0; /* allow card to shrink & truncate long names */
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.45s cubic-bezier(0.25, 0.1, 0.25, 1),
              border-color 0.45s ease;
  text-decoration: none;
  color: inherit;
}

.char-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.52),
              0 0 0 1px rgba(255, 255, 255, 0.025);
  border-color: rgba(255, 255, 255, 0.06);
  transition: transform 0.55s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.55s ease,
              border-color 0.55s ease;
}

/* Card avatar area */
.char-card-avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.char-card-avatar .avatar-initial {
  font-family: var(--font-sans);
  font-size: 3.5rem;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.12);
  text-transform: uppercase;
  transition: color 0.5s ease;
}

.char-card:hover .avatar-initial {
  color: rgba(255, 255, 255, 0.18);
}

/* Avatar subtle pattern */
.char-card-avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 35%, rgba(var(--accent-rgb), 0.15) 0%, transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
  pointer-events: none;
}

/* Card body */
.char-card-body {
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.char-card-name {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.03em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-card-tagline {
  font-size: 0.86rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.46rem; /* reserves space for 2 lines even when empty */
}

.char-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.025);
}

.char-card-world {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 300;
  color: var(--gold-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.char-card-date {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* --- FAB (Floating Action Button) --- */
.fab {
  position: fixed;
  bottom: 40px;
  right: 40px;
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: var(--white-warm);
  font-size: 1.6rem;
  font-weight: 200;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.35s ease,
              background 0.35s ease;
  line-height: 1;
}

.fab:hover {
  transform: scale(1.03);
  background: var(--accent-light);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.5s ease,
              background 0.5s ease;
}

/* ============================================
   Create Character — Fullscreen Overlay
   ============================================ */

.create-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 8, 8, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.create-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.create-modal {
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}

/* --- Overlay Header --- */
.create-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.create-topbar-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.06em;
}

.create-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.create-close:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* --- Step Progress Dots --- */
.step-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 40px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.4s ease, transform 0.4s ease;
}

.step-dot.done {
  background: var(--accent-light);
}

.step-dot.current {
  background: var(--text-primary);
  transform: scale(1.35);
}

.step-line {
  width: 28px;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.4s ease;
}

.step-line.done {
  background: rgba(var(--accent-rgb), 0.4);
}

/* --- Step Panels --- */
.step-panel {
  display: none;
  flex-direction: column;
  gap: 24px;
  animation: step-fade-in 0.45s ease;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
  /* Subtle scrollbar for step panels */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.step-panel.active {
  display: flex;
}

.step-panel::-webkit-scrollbar {
  width: 4px;
}
.step-panel::-webkit-scrollbar-track {
  background: transparent;
}
.step-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
}

@keyframes step-fade-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Form Fields --- */
.step-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-label {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.step-input {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.step-input:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(255, 255, 255, 0.04);
}

.step-input::placeholder {
  color: rgba(255, 255, 255, 0.12);
}

.step-input.large {
  min-height: 130px;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.7;
}

.step-input.xlarge {
  min-height: 200px;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.8;
}

/* Character counter */
.char-counter {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 3px;
  letter-spacing: 0.03em;
}
.char-counter.near-limit {
  color: var(--gold-dim);
}
.char-counter.at-limit {
  color: var(--accent-light);
}

/* Limit warning / error on textarea */
.input-limit-warn {
  border-color: rgba(var(--gold-rgb),0.35) !important;
}
.input-limit-error {
  border-color: rgba(var(--accent-rgb),0.5) !important;
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb),0.1) !important;
}

.step-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Character Type Options --- */
.char-type-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.char-type-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.35s ease,
              background 0.35s ease,
              box-shadow 0.35s ease;
  font-family: var(--font-sans);
}

.char-type-option:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
}

.char-type-option.selected {
  border-width: 2px;
  border-color: var(--sel-border);
  background: rgba(var(--accent-rgb), 0.1);
}

.char-type-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.char-type-option.selected .char-type-radio {
  border-color: var(--accent-light);
  background: var(--accent);
}

.char-type-option.selected .char-type-radio::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--white-warm);
}

.char-type-label {
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.char-type-option.selected .char-type-label {
  color: var(--text-primary);
}

/* --- World Setting Tags --- */
.world-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.world-tag {
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.015);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.35s ease;
  -webkit-user-select: none;
  user-select: none;
}

.world-tag:hover {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
}

.world-tag.selected {
  border-width: 2px;
  border-color: var(--sel-border);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--sel-border);
}

/* --- Real-life subtype tags (single-select) --- */
.real-subtype { margin-top: 16px; }
.subtype-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.subtype-tag {
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.015);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.35s ease;
  -webkit-user-select: none;
  user-select: none;
}

.subtype-tag:hover {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
}

.subtype-tag.selected {
  border-width: 2px;
  border-color: var(--sel-border);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--sel-border);
}

/* --- Real-life subtype: custom input for "other" --- */
.subtype-other-input[hidden] {
  display: none;
}

.subtype-other-input {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.subtype-other-input input {
  flex: 1;
  max-width: 320px;
  padding: 10px 16px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  outline: none;
  transition: border-color 0.35s ease;
}

.subtype-other-input input:focus {
  border-color: var(--accent-light);
}

.subtype-other-counter {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Personality Textareas --- */
.personality-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.personality-grid .step-field.full {
  grid-column: 1 / -1;
}

.personality-grid .step-row {
  grid-column: 1 / -1;
}

/* --- Impression Step --- */
.impression-guide {
  text-align: center;
  margin-bottom: 8px;
}

.impression-guide p {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  line-height: 1.6;
  font-style: italic;
}

.impression-guide .impression-sub {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 0.06em;
}

/* --- You & TA card (optional, independent from relationship network) --- */
.user-relation-card {
  margin-top: 28px;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}

.user-relation-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.user-relation-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--accent-light);
}

.user-relation-optional {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  opacity: 0.7;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 100px;
  padding: 2px 10px;
}

.user-relation-guide {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.85;
  margin-bottom: 18px;
  line-height: 1.6;
}

.user-relation-card .step-field {
  margin-bottom: 16px;
}

.relation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.relation-chip {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.015);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-user-select: none;
  user-select: none;
}

.relation-chip:hover {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
}

.relation-chip.selected {
  border-width: 2px;
  border-color: var(--sel-border);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--sel-border);
}

.relation-custom-input {
  max-width: 340px;
}

/* --- Step Actions --- */
.step-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 8px;
}

.step-btn {
  padding: 11px 28px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.35s ease;
}

.step-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.step-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.step-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white-warm);
}

.step-btn.primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.step-btn.ghost {
  border-color: transparent;
  padding-left: 0;
  color: var(--text-muted);
}

.step-btn.ghost:hover {
  color: var(--text-secondary);
  border-color: transparent;
}

/* ============================================
   Character Detail Page
   ============================================ */

.char-detail-page {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

.char-detail-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 56px;
}

/* --- Left Sidebar --- */
.char-detail-left {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.char-detail-avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.char-detail-avatar .avatar-initial {
  font-family: var(--font-sans);
  font-size: 5rem;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

.char-detail-avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 35%, rgba(var(--accent-rgb), 0.15) 0%, transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
  pointer-events: none;
}

.char-detail-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.char-detail-tagline {
  font-size: 0.9rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.6;
}

.char-detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.char-detail-badge {
  display: inline-flex;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.char-detail-badge.world {
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent-light);
}

/* --- Right Content --- */
.char-detail-right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.detail-panel {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.035);
  padding: 28px 30px;
  transition: border-color 0.4s ease;
}

.detail-panel:hover {
  border-color: rgba(255, 255, 255, 0.06);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.detail-panel-title {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-panel-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  opacity: 0.5;
}

.detail-panel-content {
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.8;
  min-height: 40px;
}

.detail-panel-content.empty {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

/* Detail impression block — special treatment */
.detail-impression {
  border-left: 2px solid var(--accent);
  padding-left: 20px;
  margin-top: 4px;
}

/* Back link */
.char-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.35s ease;
  margin-bottom: 36px;
}

.char-back:hover {
  color: var(--text-primary);
}

.char-back-arrow {
  font-size: 0.9rem;
}

/* --- Cancel button in topbar --- */
.create-cancel {
  padding: 8px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.create-cancel:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-secondary);
}

.create-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================
   Confirmation Dialog (unsaved changes)
   ============================================ */

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(8, 8, 8, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.confirm-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.confirm-dialog {
  width: 440px;
  max-width: 90vw;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-elevated);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.confirm-dialog-icon {
  font-size: 1.6rem;
  color: var(--accent-light);
}

.confirm-dialog-message {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.confirm-dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.confirm-dialog-btn {
  padding: 10px 22px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.confirm-dialog-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.confirm-dialog-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white-warm);
}

.confirm-dialog-btn.primary:hover {
  background: var(--accent-light);
}

.confirm-dialog-btn.danger {
  border-color: transparent;
  color: var(--text-muted);
}

.confirm-dialog-btn.danger:hover {
  color: var(--accent-light);
  border-color: rgba(var(--accent-rgb), 0.3);
}

/* ============================================
   Step 6 — Character Preview
   ============================================ */

.preview-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.preview-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.preview-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.preview-tagline {
  font-size: 0.78rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-muted);
}

.preview-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-badge {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 300;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.preview-badge.world {
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent-light);
}

.preview-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
}

.preview-text {
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.035);
  margin: 4px 0;
}

/* ============================================
   Character Memory — Detail Panel (expanded)
   ============================================ */

.memory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.memory-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memory-field.full {
  grid-column: 1 / -1;
}

.memory-field-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.6;
}

.memory-field-value {
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.7;
  min-height: 20px;
}

.memory-field-value.empty {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.4;
}

.memory-empty-banner {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.6;
}

/* ============================================
   Sound system (placeholder)
   ============================================ */

/* Sound toggle in page header area */
.sound-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.sound-toggle:hover {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
}

.sound-toggle.muted {
  opacity: 0.3;
}

/* ============================================
   Character Engine — Dashboard, Timeline,
   Relationships, Delete
   ============================================ */

/* --- Character cards（V3：刪除按鈕已拆除，position:relative 供星標定位） --- */
.char-card {
  position: relative;
}

/* Star toggle button */
.char-card-star {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.char-card:hover .char-card-star {
  opacity: 1;
}

.char-card-star.active {
  opacity: 1;
  color: var(--gold);
  border-color: rgba(var(--gold-rgb), 0.3);
}

.char-card-star:hover {
  color: var(--gold);
  opacity: 1;
}

/* --- Detail page delete button --- */
.detail-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.35s ease;
  margin-top: 12px;
}

.detail-delete-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(var(--accent-rgb), 0.06);
}

/* ============================================
   Character Dashboard — 3 Column Layout
   ============================================ */

.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 40px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

/* --- Left Column --- */
.dash-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.dash-avatar .avatar-initial {
  font-family: var(--font-sans);
  font-size: 4.5rem;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

.dash-avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 35%, rgba(var(--accent-rgb), 0.15) 0%, transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
  pointer-events: none;
}

.dash-name {
  font-family: var(--font-display);
  /* V4 App 思維：姓名放大 + 下劃線突出 */
  font-size: 2rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-decoration-line: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.65);
  text-decoration-thickness: 2px;
  text-underline-offset: 9px;
  padding-bottom: 2px;
}

.dash-tagline {
  font-size: 1rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
}


/* ============================================
   Stats Footer — quiet metadata
   ============================================ */

.stats-footer {
  border-top: 1px solid rgba(255,255,255,0.035);
  padding-top: 24px;
  margin-top: 8px;
}

.stats-footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stats-footer-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-footer-label {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.5;
}

.stats-footer-value {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.stats-footer-value.placeholder {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

.dash-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dash-badge {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.dash-badge.accent {
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent-light);
}

/* --- You & TA (user ↔ character) --- */
.user-relation-desc {
  margin-top: 10px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.user-relation-hint {
  margin-top: 10px;
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.65;
  letter-spacing: 0.03em;
}

.dash-stat-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.dash-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-stat-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dash-stat-value {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.dash-stat-value.placeholder {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

/* --- Center Column --- */
.dash-center {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Right Column --- */
.dash-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Dashboard Panels --- */
.dash-panel {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.035);
  padding: 24px;
  transition: border-color 0.4s ease;
}

.dash-panel:hover {
  border-color: rgba(255, 255, 255, 0.06);
}

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

.dash-panel-title {
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dash-panel-icon {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.5;
}

.dash-panel-body {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.8;
}

.dash-panel-body.empty {
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

/* ── Collapsible accordion panels ──────────────── */
.dash-panel-collapsible .dash-panel-header {
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
}
.dash-panel-collapsible .dash-panel-header:hover .dash-panel-title {
  color: var(--text-secondary);
}
.dash-panel-collapsible .dash-panel-body-wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.dash-panel-collapsible.expanded .dash-panel-body-wrap {
  max-height: 4000px;
}
.dash-panel-collapsible .dash-panel-body-wrap-inner {
  padding-top: 14px;
}
.dash-panel-collapsible .accordion-arrow {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.4;
  transition: transform 0.4s ease;
  display: inline-block;
}
.dash-panel-collapsible.expanded .accordion-arrow {
  transform: rotate(90deg);
}

/* ============================================
   Timeline
   ============================================ */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.04);
}

.timeline-item {
  position: relative;
  padding: 12px 0 12px 20px;
  animation: timeline-fade-in 0.5s ease both;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 18px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
}

.timeline-item.type-created::before  { border-color: var(--accent-light); }
.timeline-item.type-reading::before  { border-color: var(--gold-dim); }
.timeline-item.type-arcana::before   { border-color: var(--accent-light); }
.timeline-item.type-updated::before  { border-color: rgba(255,255,255,0.2); }
.timeline-item.type-relationship::before { border-color: var(--gold-dim); }

@keyframes timeline-fade-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.timeline-date {
  font-family: var(--font-sans);
  font-size: 0.63rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  opacity: 0.6;
  margin-bottom: 2px;
}

.timeline-title {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.timeline-desc {
  font-size: 0.74rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 2px;
}

.timeline-empty {
  text-align: center;
  padding: 16px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

/* ============================================
   Relationship System
   ============================================ */

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

.rel-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.025);
  transition: all 0.3s ease;
}

.rel-card:hover {
  border-color: rgba(255, 255, 255, 0.06);
  background: var(--bg-hover);
}

.rel-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

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

.rel-name {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.rel-type {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.rel-status {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 300;
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.rel-delete {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.rel-card:hover .rel-delete {
  opacity: 1;
}

.rel-delete:hover {
  color: var(--accent-light);
}

.rel-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.06);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

.rel-add-btn:hover {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
}

.rel-empty {
  text-align: center;
  padding: 14px 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.5;
}

/* ============================================
   Relationship Modal
   ============================================ */

.rel-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(8, 8, 8, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.rel-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.rel-modal {
  width: 440px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rel-modal-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.rel-modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rel-modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rel-modal-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rel-modal-input {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s ease;
}

.rel-modal-input:focus {
  border-color: rgba(var(--accent-rgb), 0.4);
}

.rel-modal-input::placeholder {
  color: rgba(255, 255, 255, 0.1);
}

.rel-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.rel-modal-btn {
  padding: 9px 22px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.rel-modal-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.rel-modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white-warm);
}

.rel-modal-btn.primary:hover {
  background: var(--accent-light);
}

/* ── Enhanced: Character Selector Dropdown ── */
.rel-char-select {
  position: relative;
  cursor: pointer;
}
.rel-char-select-placeholder {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.rel-char-select-placeholder.has-selection {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.14);
}
.rel-char-select-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  margin-top: 4px;
}
.rel-char-select-dropdown.open {
  display: block;
}
@media (max-width: 767px) {
  .rel-char-select-dropdown {
    max-height: 35vh;
  }
}
.rel-char-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.rel-char-option:hover {
  background: rgba(255, 255, 255, 0.04);
}
.rel-char-option.selected {
  background: rgba(var(--accent-rgb), 0.14);
  box-shadow: inset 3px 0 0 var(--sel-border),
              inset 0 0 0 1px rgba(var(--accent-rgb), 0.35);
}
.rel-char-option.muted {
  color: var(--text-muted);
  cursor: default;
  font-size: 0.78rem;
  padding: 12px;
}
.rel-char-opt-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  overflow: hidden;
}
.rel-char-opt-name {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-primary);
}
.rel-char-opt-tagline {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* ── Enhanced: Type Presets ── */
.rel-type-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rel-type-tag {
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.03em;
}
.rel-type-tag:hover {
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
}
.rel-type-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white-warm);
}

/* ── Enhanced: Direction Toggle ── */
.rel-direction-toggle {
  display: flex;
  gap: 6px;
}
.rel-dir-btn {
  flex: 1;
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.04em;
}
.rel-dir-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
}
.rel-dir-btn.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}

/* ── Enhanced: Rel Card ── */
.rel-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.rel-graph-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s ease;
}
.rel-graph-btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold-dim);
}
.rel-dir-icon {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-right: 2px;
}
.rel-notes-hint {
  font-size: 0.7rem;
  opacity: 0.5;
  cursor: help;
  margin-left: 6px;
}
.rel-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
  margin-left: auto;
}
.rel-card:hover .rel-edit {
  opacity: 0.7;
}
.rel-edit:hover {
  opacity: 1 !important;
  color: var(--text-primary);
}

/* ── 2026-09-13 關係網絡入口卡（列表 UI 已降級，沉浸式圖在 relationship-graph.html）── */
.rg-entry {
  padding: 16px 18px;
  margin: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease;
  outline: none;
}
.rg-entry:hover,
.rg-entry:focus-visible {
  border-color: rgba(var(--gold-rgb), 0.3);
  background: rgba(var(--gold-rgb), 0.03);
}
.rg-entry-avatars {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.rg-entry-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  margin-left: -8px;
  box-sizing: border-box;
}
.rg-entry-av:first-child { margin-left: 0; }
.rg-entry-more {
  margin-left: 6px;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--text-muted);
}
.rg-entry-empty {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.rg-entry-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rg-entry-count {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.rg-entry-go {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: 0.06em;
}

/* ============================================
   Relationship Graph Overlay
   ============================================ */

.graph-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(4, 4, 8, 0.94);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.graph-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.graph-container {
  width: 92vw;
  max-width: 760px;
  height: 82vh;
  max-height: 680px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
@media (max-width: 767px) {
  .graph-container {
    width: 96vw;
    height: 88vh;
    max-height: none;
    border-radius: var(--radius-lg);
  }
  .graph-header {
    padding: 14px 16px;
  }
  .graph-title {
    font-size: 0.85rem;
  }
}
.graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.graph-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.06em;
}
.graph-center-name {
  color: var(--gold-dim);
  font-weight: 300;
}
.graph-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}
.graph-close:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}
.graph-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(var(--accent-rgb), 0.04) 0%, transparent 70%);
  cursor: grab;
  touch-action: none;
}
.graph-canvas:active {
  cursor: grabbing;
}
.graph-canvas svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.graph-canvas svg line {
  pointer-events: stroke;
}
.graph-nodes {
  position: absolute;
  inset: 0;
}
.graph-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  gap: 8px;
}

/* ── Graph Node ── */
.graph-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transform: translate(-50%, -50%);
  animation: nodeAppear 0.55s ease backwards;
  cursor: pointer;
  z-index: 5;
  transition: left 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), top 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.graph-node.center-node {
  z-index: 10;
}
.graph-node.center-node .graph-node-avatar {
  border: 2px solid var(--accent);
  box-shadow: 0 0 32px rgba(var(--accent-rgb), 0.35), 0 0 72px rgba(var(--accent-rgb), 0.08);
}
.graph-node.satellite-node:nth-child(2) { animation-delay: 0.08s; }
.graph-node.satellite-node:nth-child(3) { animation-delay: 0.16s; }
.graph-node.satellite-node:nth-child(4) { animation-delay: 0.24s; }
.graph-node.satellite-node:nth-child(5) { animation-delay: 0.32s; }
.graph-node.satellite-node:nth-child(6) { animation-delay: 0.40s; }
.graph-node.satellite-node:nth-child(7) { animation-delay: 0.48s; }
.graph-node.satellite-node:nth-child(8) { animation-delay: 0.56s; }

/* External (non-character) nodes */
.graph-node.external-node {
  cursor: default;
}
.graph-node.external-node .graph-node-avatar {
  border-style: dashed;
  opacity: 0.7;
}
.graph-node.external-node:hover .graph-node-avatar {
  transform: none;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

/* --- You & TA querent node ('我' = user) --- */
.graph-node.querent-node .graph-node-avatar {
  border-color: rgba(var(--accent-rgb), 0.55);
  border-style: solid;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.18);
}

.graph-me-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-light, #c9a86a);
  color: #111;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(0, 0, 0, 0.35);
  z-index: 3;
}

@keyframes nodeAppear {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.graph-node-avatar {
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  transition: border-color 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
  flex-shrink: 0;
}
.graph-node:hover .graph-node-avatar {
  border-color: var(--gold-dim);
  box-shadow: 0 0 18px rgba(var(--gold-rgb), 0.25);
  transform: scale(1.06);
}
.graph-node.center-node:hover .graph-node-avatar {
  border-color: var(--accent-light);
  box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.5), 0 0 80px rgba(var(--accent-rgb), 0.12);
  transform: scale(1.04);
}
.graph-node-name {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-align: center;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  position: absolute;
  top: 100%;
  margin-top: 4px;
  line-height: 1.2;
  pointer-events: none;
}
@media (max-width: 767px) {
  .graph-node-name {
    font-size: 0.62rem;
    max-width: 64px;
    margin-top: 3px;
  }
}

/* ── Graph Lines ── */
.graph-line {
  stroke-width: 1.5;
  opacity: 0.35;
  transition: opacity 0.3s, stroke-width 0.3s;
  cursor: pointer;
  pointer-events: stroke;
}
.graph-line:hover {
  opacity: 0.75;
  stroke-width: 2.5;
}
.graph-line.line-default  { stroke: rgba(210, 210, 220, 0.3); }
.graph-line.line-love     { stroke: rgba(220, 90, 100, 0.45); }
.graph-line.line-hostile  { stroke: rgba(190, 70, 70, 0.55); stroke-dasharray: 6 3; }
.graph-line.line-secret   { stroke: rgba(150, 110, 190, 0.5); stroke-dasharray: 3 5; }
.graph-line.line-mentor   { stroke: rgba(110, 170, 210, 0.45); }
.graph-line.line-family   { stroke: rgba(170, 190, 150, 0.45); }
.graph-line.one-way { stroke-dasharray: none; }

/* ── Edge Label (SVG) ── */
.edge-label-text {
  fill: rgba(var(--gold-rgb), 0.85);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.05em;
  pointer-events: all;
  cursor: pointer;
  transition: fill 0.25s;
  user-select: none;
}
.edge-label-text:hover {
  fill: rgba(var(--gold-rgb), 1);
}

/* ── Graph Tooltip ── */
.graph-tooltip {
  position: fixed;
  z-index: 500;
  background: rgba(18, 16, 18, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  max-width: 280px;
}
.graph-tooltip.visible {
  opacity: 1;
}
.graph-tooltip-row {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-primary);
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.graph-tooltip-type {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  color: var(--gold-dim);
  letter-spacing: 0.06em;
}
.graph-tooltip-notes {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ============================================
   Action Bar — Edit, Duplicate, Export
   ============================================ */

.detail-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.detail-action-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.015);
}

.detail-action-btn.primary-action {
  border-color: var(--accent);
  color: var(--accent-light);
}

.detail-action-btn.primary-action:hover {
  background: rgba(var(--accent-rgb), 0.1);
}

.detail-action-btn.danger-action {
  border-color: transparent;
  color: var(--text-muted);
}

.detail-action-btn.danger-action:hover {
  color: var(--accent-light);
  border-color: rgba(var(--accent-rgb), 0.2);
}

/* Mobile: collapse action bar extras */
@media (max-width: 480px) {
  .detail-action-bar {
    gap: 6px;
  }
  .detail-action-btn {
    padding: 6px 10px;
    font-size: 0.65rem;
    letter-spacing: 0.03em;
  }
  #btnDuplicate,
  #btnExport {
    display: none;
  }
}

/* Date display on character cards */
.char-card-dates {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  opacity: 0.6;
  min-width: 0;
  flex-shrink: 1;
}

/* ============================================
   Export Modal
   ============================================ */

.export-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(8, 8, 8, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.export-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.export-modal {
  width: 380px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.export-modal-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.3s ease;
}

.export-option:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.015);
}

.export-option-icon {
  font-size: 1.3rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.export-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-option-name {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.export-option-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.export-modal-close {
  align-self: flex-end;
  padding: 7px 18px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
}

.export-modal-close:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-secondary);
}
