/* CCFolia Log Archiver - Modern TRPG Glassmorphic Design System */

:root {
  --bg-base: #0c0e14;
  --bg-card: #151821;
  --bg-card-elevated: #1d212e;
  --bg-card-sub: #11131b;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-glow: rgba(147, 112, 219, 0.4);
  
  --text-main: #f0f4fc;
  --text-dim: #9aa5b8;
  --text-dark: #636e82;

  --accent-purple: #9d7bf5;
  --accent-purple-glow: rgba(157, 123, 245, 0.3);
  --accent-cyan: #00d2ff;
  --accent-cyan-glow: rgba(0, 210, 255, 0.25);
  --accent-amber: #f7931a;
  --accent-green: #00f090;
  --accent-crit: #ffd166;
  --accent-fumble: #ff4757;

  --tab-main-color: #9d7bf5;
  --tab-info-color: #00d2ff;
  --tab-other-color: #f7931a;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.6);

  --font-main: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Outfit", "Pretendard", sans-serif;
}

[data-theme="light"] {
  --bg-base: #f4f6fa;
  --bg-card: #ffffff;
  --bg-card-elevated: #f8fafc;
  --bg-card-sub: #f1f4f9;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --border-glow: rgba(110, 80, 210, 0.25);
  --text-main: #181c24;
  --text-dim: #5a6578;
  --text-dark: #8c98a8;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.15);
}

/* Global Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Ambient Background Lights */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.25;
}
.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #7b2cbf 0%, transparent 70%);
  top: -100px;
  left: 20%;
}
.bg-glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #0077b6 0%, transparent 70%);
  top: 300px;
  right: 15%;
}

/* Layout */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-container {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: rgba(21, 24, 33, 0.75);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 10px var(--accent-purple-glow));
}
.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 40%, var(--accent-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tag {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  user-select: none;
}
.btn:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #8a5cf6 0%, #6366f1 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #9d7bf5 0%, #7579ff 100%);
  box-shadow: 0 0 20px var(--accent-purple-glow);
}

.btn-accent {
  background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-accent:hover {
  background: linear-gradient(135deg, #2dd4bf 0%, #0284c7 100%);
  box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-card-elevated);
  border-color: var(--border-glow);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-glow {
  box-shadow: 0 0 16px rgba(157, 123, 245, 0.35);
}

/* Hero Section */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan), var(--accent-amber));
}
.hero-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  color: var(--text-main);
}
.hero-subtitle {
  color: var(--text-dim);
  font-size: 0.98rem;
  max-width: 820px;
  line-height: 1.65;
  margin-bottom: 24px;
}
.hero-subtitle strong {
  color: var(--accent-cyan);
}

/* Inputs & Form */
.input-box {
  margin-bottom: 20px;
}
.input-label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 8px;
  color: var(--text-main);
}
.url-input-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.url-input {
  flex: 1;
  min-width: 280px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}
.url-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px var(--accent-purple-glow);
}

/* Progress Panel */
.progress-panel {
  margin-top: 24px;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.progress-step-text {
  color: var(--accent-purple);
}
.progress-percent-text {
  color: var(--accent-cyan);
}
.progress-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 10px;
  transition: width 0.3s ease;
}
.progress-detail {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* Preview Section & Toolbar */
.preview-section {
  animation: fadeIn 0.4s ease;
}

.session-toolbar {
  position: sticky;
  top: 76px;
  z-index: 90;
  background: rgba(21, 24, 33, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-md);
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.session-info-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
}
.total-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-purple-glow);
  color: var(--accent-purple);
  border: 1px solid var(--accent-purple);
  padding: 2px 8px;
  border-radius: 12px;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Controls Panel */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.controls-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.search-group {
  flex: 1;
  min-width: 220px;
}
.search-input {
  width: 100%;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
}
.search-input:focus {
  border-color: var(--accent-purple);
}
.select-box {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}
.select-box:focus {
  border-color: var(--accent-purple);
}

.pills-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.pills-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dark);
}
.tab-pills-container {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tab-pill {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-elevated);
  color: var(--text-dim);
  transition: all 0.15s ease;
  user-select: none;
}
.tab-pill.active {
  color: var(--text-main);
  border-color: currentColor;
  background: rgba(255, 255, 255, 0.08);
}

/* Timeline & Cards */
.timeline-wrapper {
  position: relative;
}
.timeline-spine {
  position: absolute;
  left: 28px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent-purple), var(--accent-cyan), var(--border-subtle));
  opacity: 0.4;
}
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Group Card */
.message-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.message-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md);
}

/* Section Card (Pre / Post session) */
.message-card.section-card {
  background: var(--bg-card-sub);
  border-left: 4px solid var(--accent-cyan);
}
/* Info Message Card */
.message-card.info-card {
  background: rgba(0, 210, 255, 0.05);
  border-left: 4px solid var(--accent-cyan);
}
.section-banner-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-cyan);
  margin-bottom: 10px;
}

/* Message Header */
.msg-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.char-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-subtle);
  background: var(--bg-card-sub);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
}
.char-avatar.square {
  border-radius: var(--radius-xs);
}
.char-name-block {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.char-name {
  font-weight: 700;
  font-size: 0.98rem;
}
.badge-tab {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-tab.tab-main {
  background: rgba(157, 123, 245, 0.18);
  color: var(--tab-main-color);
  border: 1px solid var(--tab-main-color);
}
.badge-tab.tab-info {
  background: rgba(0, 210, 255, 0.18);
  color: var(--tab-info-color);
  border: 1px solid var(--tab-info-color);
}
.badge-tab.tab-other {
  background: rgba(247, 147, 26, 0.18);
  color: var(--tab-other-color);
  border: 1px solid var(--tab-other-color);
}
.msg-time {
  font-size: 0.78rem;
  color: var(--text-dark);
  margin-left: auto;
}

/* Message Content */
.msg-text-content {
  padding-left: 54px;
  font-size: 0.95rem;
  color: var(--text-main);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.65;
}
.msg-text-content.scene-marker {
  font-weight: 700;
  color: var(--accent-crit);
  background: rgba(255, 209, 102, 0.08);
  padding: 10px 16px 10px 54px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent-crit);
  margin: 6px 0;
}
.msg-text-content.dice-roll {
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 14px 8px 54px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  border-left: 3px solid var(--text-dark);
  margin: 4px 0;
}
.msg-text-content.dice-critical {
  border-left-color: var(--accent-crit);
  color: var(--accent-crit);
  font-weight: 600;
}
.msg-text-content.dice-fumble {
  border-left-color: var(--accent-fumble);
  color: var(--accent-fumble);
  font-weight: 600;
}

/* Sub-Thread Accordion Card */
.sub-thread-box {
  margin-top: 12px;
  margin-left: 46px;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}
.sub-thread-toggle {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.15s ease;
}
.sub-thread-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}
.toggle-chevron {
  font-size: 0.72rem;
  transition: transform 0.2s ease;
}
.sub-thread-box.collapsed .toggle-chevron {
  transform: rotate(-90deg);
}
.sub-thread-box.collapsed .sub-thread-body {
  display: none;
}
.sub-thread-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Sub-Item */
.sub-msg-row {
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}
.sub-msg-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.sub-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.sub-avatar-img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.sub-char-name {
  font-size: 0.84rem;
  font-weight: 700;
}
.sub-body-text {
  font-size: 0.9rem;
  padding-left: 34px;
  color: var(--text-main);
  word-break: break-word;
  white-space: pre-wrap;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}
.btn-close:hover {
  color: var(--text-main);
}
.modal-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 16px;
}
.code-box-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.code-textarea {
  width: 100%;
  height: 140px;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--accent-cyan);
  font-family: monospace;
  font-size: 0.82rem;
  resize: vertical;
  outline: none;
}

/* Stats in modal */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-summary-card {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.stat-num {
  font-size: 1.4rem;
  font-weight: 800;
  display: block;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.stats-section {
  margin-bottom: 20px;
}
.stats-section h4 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--accent-purple);
}
.char-stat-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.char-stat-name {
  width: 140px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.char-stat-track {
  flex: 1;
  height: 8px;
  background: var(--bg-card-sub);
  border-radius: 4px;
  overflow: hidden;
}
.char-stat-fill {
  height: 100%;
  border-radius: 4px;
}
.char-stat-count {
  width: 50px;
  text-align: right;
  color: var(--text-dim);
}

/* Floating Top Button */
.fab-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-purple);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  opacity: 0.85;
  transition: all 0.2s ease;
  z-index: 90;
}
.fab-top:hover {
  opacity: 1;
  transform: translateY(-3px);
  box-shadow: 0 0 16px var(--accent-purple-glow);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-dark);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-subtle);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   WYSIWYG & In-Place Editing Styles
   ========================================================================== */

/* Mode Switch Group */
.mode-switch-group {
  display: flex;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.mode-btn:hover {
  color: var(--text-main);
}
.mode-btn.active {
  background: var(--accent-purple);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-purple-glow);
}

/* Floating Rich Text Format Toolbar */
.floating-format-toolbar {
  position: absolute;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(26, 31, 46, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-purple);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px var(--accent-purple-glow);
  transform: translateX(-50%);
  animation: fadeIn 0.15s ease-out;
}
.fmt-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  width: 30px;
  height: 30px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
.fmt-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--border-glow);
}
.fmt-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
}
.fmt-color-picker-wrap {
  position: relative;
  display: inline-flex;
}
.color-preview {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #fff;
  margin-left: 2px;
}
.hidden-color-input {
  opacity: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
}

/* Message Card Edit Controls */
.message-card {
  position: relative;
}
.msg-edit-bar {
  display: none;
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(18, 22, 34, 0.9);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  padding: 3px 6px;
  gap: 4px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.is-edit-mode .message-card:hover .msg-edit-bar {
  display: flex;
}
.edit-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 3px 6px;
  font-size: 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 3px;
}
.edit-tool-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}
.edit-tool-btn.btn-del:hover {
  color: var(--accent-fumble);
  background: rgba(239, 68, 68, 0.15);
}

/* Inline Editable Content */
.is-edit-mode [contenteditable="true"] {
  outline: none;
  cursor: text;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  border-radius: 4px;
  padding: 2px 4px;
}
.is-edit-mode [contenteditable="true"]:hover {
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.is-edit-mode [contenteditable="true"]:focus {
  background: rgba(138, 92, 246, 0.08);
  box-shadow: inset 0 0 0 1.5px var(--accent-purple);
}

/* Drag Handle */
.drag-handle {
  cursor: grab;
  color: var(--text-dark);
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
}
.drag-handle:active {
  cursor: grabbing;
}

/* Center Alignment & Narrative Custom Styles */
.msg-card-centered {
  text-align: center !important;
  justify-content: center !important;
}
.msg-card-centered .msg-header-row {
  justify-content: center !important;
}
.msg-card-centered .msg-text-content {
  text-align: center !important;
}
.msg-card-bold .msg-text-content {
  font-weight: bold !important;
}
.msg-card-no-avatar .char-avatar {
  display: none !important;
}
.msg-card-no-sender .char-name {
  display: none !important;
}

/* Batch Character Table Modal */
.modal-lg {
  max-width: 860px;
  width: 95%;
}
.batch-char-table-container {
  overflow-x: auto;
  max-height: 480px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-card-sub);
}
.batch-char-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}
.batch-char-table th, .batch-char-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.batch-char-table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-dim);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 5;
}
.char-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.char-cell img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.preset-badge-btn {
  background: rgba(138, 92, 246, 0.15);
  border: 1px solid var(--accent-purple);
  color: #c4b5fd;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-badge-btn:hover {
  background: var(--accent-purple);
  color: #fff;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

/* Image Dropzone in Modal */
.image-dropzone {
  border: 2px dashed var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-card-sub);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.image-dropzone:hover, .image-dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(0, 210, 255, 0.05);
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.15);
}
.dropzone-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 8px;
}
.dropzone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 6px;
}
.dropzone-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dropzone-preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  object-fit: contain;
}
.preview-info {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  margin-top: 8px;
  font-weight: 500;
}

/* Inserted Image Replay Card in Timeline */
.message-card.image-card {
  background: rgba(138, 92, 246, 0.04);
  border: 1px solid rgba(138, 92, 246, 0.25);
  padding: 16px 20px;
}
.message-card.image-card:hover {
  border-color: var(--accent-purple);
  box-shadow: 0 0 20px rgba(138, 92, 246, 0.15);
}
.inserted-img-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 8px 0;
  width: 100%;
}
.inserted-replay-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: block;
  transition: transform 0.2s ease;
}
.inserted-replay-img:hover {
  transform: scale(1.01);
}
.inserted-img-caption {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 4px;
}
.inserted-img-caption[contenteditable="true"]:focus {
  background: rgba(255, 255, 255, 0.06);
  outline: 1px solid var(--accent-cyan);
}

/* Timeline Drag-over Drop Highlighting */
.message-card.drop-target-active {
  border: 2px dashed var(--accent-cyan) !important;
  background: rgba(0, 210, 255, 0.08) !important;
  box-shadow: 0 0 24px rgba(0, 210, 255, 0.25) !important;
}

/* Responsive */
@media (max-width: 768px) {
  .hero-card { padding: 20px; }
  .session-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
  .stats-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .msg-text-content { padding-left: 0; margin-top: 8px; }
  .sub-thread-box { margin-left: 0; }
}
