/* ==========================================================================
   RelayNovel - UI Components & Interactive Styles
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-inverse);
}
.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-accent {
  background-color: var(--color-accent);
  color: #FFFFFF;
}
.btn-accent:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.btn-outline {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--color-accent);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 7px;
  border-radius: 50%;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.btn-icon:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--bg-subtle);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.badge-genre {
  background-color: var(--bg-subtle);
  color: var(--color-primary);
  border: 1px solid var(--border-color);
}

.badge-status {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.badge-ongoing {
  background-color: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}
.badge-completed {
  background-color: #EFF6FF;
  color: #2563EB;
  border: 1px solid #BFDBFE;
}

[data-theme="dark"] .badge-ongoing {
  background-color: #064E3B;
  color: #6EE7B7;
  border-color: #047857;
}
[data-theme="dark"] .badge-completed {
  background-color: #1E3A8A;
  color: #93C5FD;
  border-color: #1D4ED8;
}

/* Author Avatar & Badge */
.author-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 3px 8px 3px 4px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}

.author-avatar-lg {
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
}

/* Novel Card */
.novel-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.novel-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

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

.card-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.card-bookmark-btn {
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: color var(--transition-fast);
}
.card-bookmark-btn.active, .card-bookmark-btn:hover {
  color: var(--color-accent);
}

.card-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 8px;
  line-height: 1.35;
  letter-spacing: -0.3px;
}

.card-synopsis {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-relay-preview {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-family: var(--font-story);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--color-accent);
  position: relative;
}

.card-relay-preview p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.card-relay-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.author-stack {
  display: flex;
  align-items: center;
}

.author-stack .author-avatar {
  margin-right: -6px;
  border: 2px solid var(--bg-surface);
}

.author-count-text {
  margin-left: 10px;
  font-weight: 500;
}

.card-stats {
  display: flex;
  gap: 10px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   Story Viewer View & Timeline
   ========================================================================== */
.viewer-container {
  display: none;
  padding: 24px 0 80px;
}

.viewer-container.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

.viewer-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.viewer-header-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.viewer-genre-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.viewer-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.viewer-synopsis {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

.viewer-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.viewer-meta-chips {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.viewer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Reader Toolbar */
.reader-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Story Timeline */
.story-timeline {
  position: relative;
  margin-bottom: 40px;
}

.timeline-item {
  position: relative;
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.timeline-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 48px;
}

.timeline-order {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.timeline-order.first-order {
  background: var(--color-accent);
  color: #FFFFFF;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.timeline-line {
  flex: 1;
  width: 2px;
  background: var(--border-color);
  margin: 6px 0;
}

.timeline-content-card {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.timeline-content-card:hover {
  border-color: var(--border-focus);
}

.paragraph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.author-info-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-name-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.first-author-tag {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.paragraph-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.paragraph-text {
  font-family: var(--font-story);
  font-size: 1.06rem;
  line-height: 1.9;
  color: var(--text-main);
  word-break: break-word;
  white-space: pre-line;
  letter-spacing: -0.2px;
}

.paragraph-note {
  margin-top: 14px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-ui);
}

.paragraph-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

.like-btn:hover, .like-btn.liked {
  color: #E11D48;
  border-color: #FECDD3;
  background: #FFF1F2;
}

[data-theme="dark"] .like-btn:hover, [data-theme="dark"] .like-btn.liked {
  background: #4C0519;
  border-color: #881337;
  color: #FDA4AF;
}

/* Relay Append Form */
.relay-dock-card {
  background: var(--bg-surface-elevated);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.relay-dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.relay-dock-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.context-preview-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  border-left: 3px solid var(--color-accent);
}

.context-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.context-text {
  font-family: var(--font-story);
  color: var(--text-secondary);
  line-height: 1.5;
  font-style: italic;
}

.author-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  background: var(--bg-subtle);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.author-input-row label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.author-input-row input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.textarea-wrap {
  position: relative;
  margin-bottom: 12px;
}

.story-textarea {
  width: 100%;
  min-height: 140px;
  padding: 14px;
  font-family: var(--font-story);
  font-size: 1rem;
  line-height: 1.7;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  resize: vertical;
  transition: border-color var(--transition-fast);
}

.story-textarea:focus {
  border-color: var(--color-accent);
}

.char-counter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.char-counter.invalid {
  color: #DC2626;
  font-weight: 700;
}

.note-input-wrap {
  margin-bottom: 16px;
}

.note-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
}

.relay-dock-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  font-size: 1.2rem;
  color: var(--text-muted);
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.9rem;
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--color-accent);
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--color-primary);
  color: var(--text-inverse);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.3s ease-in 2.7s forwards;
  pointer-events: auto;
}

.toast.toast-success {
  background: #059669;
}
.toast.toast-error {
  background: #DC2626;
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.9); }
}

