/* Import Instrument Sans font */
@import url("https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap");

/* Base styles - Dark Theme */
:root {
  --primary-color: rgb(153, 66, 245);
  --primary-hover: rgb(133, 46, 225);
  --text-color: #e5e7eb;
  --text-light: #9ca3af;
  --border-color: #2a2a2a;
  --bg-dark: #0a0a0a;
  --bg-darker: #000000;
  --bg-card: #0a0a0a;
  --bg-card-hover: #2a2a2a;
  --success-color: #34d399;
  --read-badge: #34d399;
  --bubble-bg: #2a2a2a;
  --bubble-border: #4c0096;
  --bubble-glow: 0 0 8px rgba(153, 66, 245, 0.4), 0 0 16px rgba(153, 66, 245, 0.2);
  --text-glow: 0 0 4px rgba(153, 66, 245, 0.8), 0 1px 5px rgba(76, 0, 150, 0.9);


  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
}

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

body {
  background: var(--bg-dark);
  color: var(--text-color);
  min-height: 100vh;
  padding-top: 60px; /* Space for fixed navbar */
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5vh;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
}

.navbar-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
}

.navbar-logo:hover {
  opacity: 0.8;
}

.navbar-logo-img {
  height: 25px;
  width: auto;
  display: block;
}

.hamburger-menu {
  position: relative;
}

.hamburger-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.hamburger-btn:hover {
  color: var(--primary-color);
}

.hamburger-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-width: 150px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: none;
}

.hamburger-dropdown.show {
  display: block;
}

.hamburger-dropdown a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text-color);
  text-decoration: none;
  transition: background 0.2s;
}

.hamburger-dropdown a:hover {
  background: var(--bg-card-hover);
}

.hamburger-dropdown a:first-child {
  border-radius: 8px 8px 0 0;
}

.hamburger-dropdown a:last-child {
  border-radius: 0 0 8px 8px;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  padding-top: 0rem;
}

h3 {
  color: var(--text-color);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

/* Header */
.header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-color);
}

.header a {
  text-decoration: none;
  color: var(--text-color);
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: center; /* centers items horizontally */
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.tab {
  padding: 0.2rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-color);
  background: var(--bg-hover);
  border-color: var(--primary-color);
}

.tab.active {
  color: var(--bg-primary);
  background: var(--primary-color);
  border-color: var(--primary-color);
}

/* Series Grid */
.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.series-card {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.series-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  border-color: var(--primary-color);
}

.series-card-inner {
  display: flex;
  gap: 0;
}

.series-cover {
  flex: 1;
  aspect-ratio: 2/3;
  background: var(--bg-darker);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-light);
  overflow: hidden;
}

.series-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-count-sidebar {
  width: 48px;
  background: rgba(0, 0, 0, 0.85);
  border-right: 3px solid var(--primary-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  flex-shrink: 0;
  color: #7602c4;
}

.count-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.5rem 0;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.count-item.active {
  opacity: 1;
}

.count-label {
  font-size: 1.3rem;
  font-weight: 600;
  text-transform: lowercase;
  color: #7602c4;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.count-item.active .count-label {
  color: #9800ff;
}

.count-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: #7602c4;
  line-height: 1;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.count-item.active .count-number {
  color: #a929ff;
}

.count-divider {
  height: 2px;
  background: var(--border-color);
  margin: 0 0.5rem;
}

.series-info {
  padding: 0.75rem;
}

.series-title {
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  margin-bottom: 0.25rem;
  color: var(--text-color);
}

.series-type {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Series Detail Page */
.series-detail {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.series-detail .series-cover {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.series-info h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.series-info h3 {
  color: var(--text-color);
  margin-bottom: 1rem;
}

.series-info p {
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Chapter List */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-color);
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid var(--border-color);
}

.chapter-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
}

.chapter-item.read {
  opacity: 0.5;
}

.read-badge {
  background: var(--read-badge);
  color: var(--bg-dark);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Chapter Reader */
.chapter-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-top: -2rem;
  margin-bottom: 2rem;
}

.chapter-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.chapter-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.chapter-header .series-link {
  color: var(--primary-color);
  text-decoration: none;
}

.chapter-header .series-link:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

/* Font size controls */
.font-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Language toggle */
.language-toggle {
  display: flex;
  gap: 0.5rem;
  padding-right: 1rem;
  border-right: 1px solid var(--border-color);
}

.btn-lang {
  background: var(--bg-card);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  min-width: 3rem;
}

.btn-lang:hover:not(.disabled) {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-lang.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn-lang.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  color: var(--text-light);
}

.btn-lang:active:not(.disabled) {
  transform: scale(0.95);
}

.btn-font {
  background: var(--bg-card);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-font:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-font:active {
  transform: scale(0.95);
}

.btn-font.marked {
  color: #fbbf24; /* Gold/yellow color for marked state */
}

#font-size-display {
  color: var(--text-light);
  font-size: 0.875rem;
  min-width: 3rem;
  text-align: center;
  font-weight: 500;
}

/* Chapter content styles */
.js-novel-text {
  line-height: 180%;
  font-size: 1.125rem;
  color: var(--text-color);
}

.js-novel-text p {
  margin-bottom: 1rem;
  /* Prevent long words from overflowing */
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.js-novel-text .text-block {
  text-indent: 1em;
  color: #d1d5db;
  text-shadow: var(--text-glow);
}

.js-novel-text .char-text,
.js-novel-text .sys-announcement,
.js-novel-text .forum-post {
  color: #e5e7eb;
  font-style: normal;
  background: var(--bubble-bg);
  border: 1px solid var(--bubble-border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin: 1.5rem 0; /* Extra margin for speaker names outside bubble */
  display: block;
  box-shadow: var(--bubble-glow);
  min-width: 120px; /* Ensure minimum width for speaker names */
  width: fit-content;
  max-width: 90%;
  position: relative;
}

/* Speaker annotation controls */
.speaker-control {
  position: absolute !important;
  white-space: nowrap !important;
  z-index: 10 !important;
}

/* Top-left position (default, alternates) */
.speaker-control.position-top-left {
  top: 0 !important;
  left: 0 !important;
  transform: translateY(-50%) !important;
}

/* Bottom-right position (alternates) */
.speaker-control.position-bottom-right {
  bottom: 0 !important;
  right: 0 !important;
  transform: translateY(50%) !important;
}

.speaker-name {
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: opacity 0.2s !important;
  background: transparent !important;
  padding: 0.25rem 0.5rem !important;
  margin: 0 !important;
  line-height: 1 !important;
  text-shadow:
    0 0 8px rgba(0, 0, 0, 0.8),
    0 0 4px rgba(0, 0, 0, 0.9),
    1px 1px 2px rgba(0, 0, 0, 1) !important;
}

.speaker-name:hover {
  opacity: 0.7 !important;
}

.btn-add-speaker {
  background: transparent;
  border: 1px dashed var(--border-color);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s;
  color: var(--text-light);
  opacity: 0.6;
  margin: 0;
}

.btn-add-speaker:hover {
  opacity: 1;
  border-color: var(--primary-color);
}

/* Speaker modal */
.speaker-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-dark);
  z-index: 2000;
  overflow-y: auto;
}

.speaker-modal {
  background: var(--bg-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.speaker-modal-header h3 {
  margin: 0;
  color: var(--text-color);
  font-size: 1.25rem;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: var(--bg-card-hover);
  color: var(--text-color);
}

.speaker-modal-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.add-character-form {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-darker);
}

.add-character-form h4 {
  margin: 0 0 0.75rem 0;
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-new-char-name {
  flex: 1;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  color: var(--text-color);
  font-size: 1rem;
  transition: all 0.2s;
}

.input-new-char-name:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-card);
}

.input-new-char-color {
  width: 50px;
  height: 42px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  transition: all 0.2s;
}

.input-new-char-color:hover {
  border-color: var(--primary-color);
}

.input-new-char-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.input-new-char-color::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.btn-add-character {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-add-character:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-add-character:active {
  transform: translateY(0);
}

.speaker-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.char-folder {
  margin-bottom: 0.75rem;
}

.char-folder-header {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
}

.char-folder-header:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
}

.folder-icon {
  color: var(--primary-color);
  font-size: 0.875rem;
  transition: transform 0.2s;
}

.folder-name {
  flex: 1;
}

.char-folder-content {
  margin-top: 0.5rem;
  margin-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Folder Navigation Items */
.folder-nav-item {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
}

.folder-nav-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.folder-nav-item .folder-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.folder-nav-item .folder-name {
  flex: 1;
  color: var(--text-color);
}

.folder-nav-item .folder-count {
  background: var(--bg-darker);
  color: var(--text-light);
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

.folder-nav-item .folder-arrow {
  color: var(--primary-color);
  font-size: 1.25rem;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
}

.folder-nav-item:hover .folder-arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* Back Button */
.btn-back-folder {
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  color: var(--text-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-back-folder:hover {
  background: var(--bg-card);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.speaker-option-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speaker-option {
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-color);
  font-size: 1rem;
  flex: 1;
}

.speaker-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.speaker-option.selected {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary-color);
}

.char-color-picker {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  transition: all 0.2s;
}

.char-color-picker:hover {
  border-color: var(--primary-color);
  transform: scale(1.1);
}

.char-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.char-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.char-name {
  font-weight: 500;
}

.no-characters {
  text-align: center;
  color: var(--text-light);
  padding: 2rem;
}

.no-characters a {
  color: var(--primary-color);
  text-decoration: underline;
}

.no-characters-yet {
  text-align: center;
  color: var(--text-light);
  padding: 1rem;
  font-size: 0.9rem;
  font-style: italic;
}

.btn-remove-speaker {
  width: 100%;
  padding: 0.75rem;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-remove-speaker:hover {
  background: #b91c1c;
}

.js-novel-text p:has(br:only-child) {
  margin-bottom: 0.5rem;
}

/* Chapter Navigation */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.chapter-nav .btn,
.chapter-nav .btn-secondary {
  flex: 1;
  max-width: 47.5%;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.btn {
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: var(--bg-dark);
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s, transform 0.1s;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  background: var(--border-color);
  color: var(--text-light);
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  border-color: var(--primary-color);
}

/* Loading state */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

/* Error state */
.error {
  background: #7f1d1d;
  color: #fecaca;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border: 1px solid #991b1b;
}

/* Paragraph edit menu */
.paragraph-edit-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 150px;
}

.paragraph-edit-menu button {
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  color: var(--text-color);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.paragraph-edit-menu button:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  transform: translateX(2px);
}

/* Text editor modal */
.text-editor-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-dark);
  z-index: 3000;
  overflow-y: auto;
}

.text-editor-modal {
  background: var(--bg-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.text-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.text-editor-header h3 {
  margin: 0;
  color: var(--text-color);
  font-size: 1.25rem;
  flex: 1;
  text-align: center;
}

.text-editor-header .btn-save-text {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: absolute;
  left: 1.5rem;
}

.text-editor-header .btn-save-text:hover {
  background: var(--primary-hover);
}

.text-editor-header .btn-close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.text-editor-header .btn-close-modal:hover {
  background: var(--bg-card-hover);
  color: var(--text-color);
}

.text-editor-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.text-editor-modal textarea {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-color);
  font-size: inherit;
  font-family: inherit;
  resize: none;
  min-height: 70vh;
  line-height: inherit;
}

.text-editor-modal textarea:focus {
  outline: none;
}

/* Type selector modal */
.type-selector-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem;
}

.type-option {
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.type-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.type-option.selected {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary-color);
}

.type-option-name {
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.25rem;
}

.type-option-desc {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* Settings Page */
.settings-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.settings-header h1 {
  font-size: 2rem;
  color: var(--text-color);
}

/* Settings Tabs */
.settings-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border-color);
}

.settings-tab {
  background: none;
  border: none;
  color: var(--text-light);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.settings-tab:hover {
  color: var(--text-color);
}

.settings-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.settings-content {
  position: relative;
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
}

.settings-section h2 {
  font-size: 1.5rem;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.settings-description {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-form label {
  font-weight: 500;
  color: var(--text-color);
}

.settings-form input {
  padding: 0.75rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.settings-form input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.settings-form input.input-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-form .btn {
  align-self: flex-start;
}

/* Font Size Controls */
.font-size-control {
  margin-bottom: 2rem;
}

.font-size-control label {
  display: block;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 1rem;
}

#font-size-value {
  color: var(--primary-color);
  font-weight: 600;
}

.font-size-slider-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.font-size-label {
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 500;
}

.font-size-label.large {
  font-size: 1.5rem;
}

#font-size-slider {
  flex: 1;
  height: 6px;
  background: var(--bg-darker);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

#font-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

#font-size-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#font-size-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
}

#font-size-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.font-preview {
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.font-preview h3 {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-content {
  line-height: 1.8;
  transition: font-size 0.2s;
}

.preview-content p {
  margin-bottom: 1rem;
}

.preview-content p:last-child {
  margin-bottom: 0;
}

.preview-content .char-text {
  margin-bottom: 1rem;
}

.preview-content .speaker-label {
  font-weight: 600;
  margin-right: 0.5rem;
}

/* Danger Zone */
.danger-zone {
  border-color: #dc2626;
}

.danger-zone h2 {
  color: #dc2626;
}

.btn-danger {
  background: #dc2626;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* Mobile Responsive for Settings */
@media (max-width: 768px) {
  .settings-container {
    padding: 1rem 0.5rem;
  }

  .settings-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-header h1 {
    font-size: 1.5rem;
  }

  .settings-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .settings-tab {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .settings-section {
    padding: 1.5rem 1rem;
  }

  .settings-section h2 {
    font-size: 1.25rem;
  }

  .settings-form .btn,
  .btn-danger,
  #save-preferences-btn {
    width: 100%;
  }

  .font-size-slider-container {
    gap: 0.5rem;
  }

  .font-preview {
    padding: 1rem;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  align-items: center;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  min-width: 300px;
  max-width: 500px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
  animation: slideIn 0.3s ease-out;
}

.toast.hiding {
  animation: slideOut 0.3s ease-out forwards;
}

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

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

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  color: var(--text-color);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toast-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-color);
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.success .toast-icon {
  color: #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.error .toast-icon {
  color: #ef4444;
}

.toast.warning {
  border-left: 4px solid #f59e0b;
}

.toast.warning .toast-icon {
  color: #f59e0b;
}

.toast.info {
  border-left: 4px solid var(--primary-color);
}

.toast.info .toast-icon {
  color: var(--primary-color);
}

/* Confirmation Toast */
.toast.confirm {
  border-left: 4px solid #f59e0b;
}

.toast.confirm .toast-icon {
  color: #f59e0b;
}

.toast-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.toast-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.toast-btn-primary {
  background: var(--primary-color);
  color: white;
}

.toast-btn-primary:hover {
  background: var(--primary-hover);
}

.toast-btn-secondary {
  background: var(--bg-darker);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.toast-btn-secondary:hover {
  background: var(--bg-card-hover);
}

/* Mobile styles */
@media (max-width: 768px) {
  .js-novel-text {
    font-size: 1.6875rem; /* 1.5x of 1.125rem */
  }

  .toast-container {
    top: 60px;
    left: 10px;
    right: 10px;
    transform: none;
  }

  .toast {
    min-width: auto;
    max-width: none;
    width: 100%;
  }

  /* Series Detail Mobile Layout */
  .series-detail {
    display: block;
    margin-bottom: 2rem;
  }

  .series-detail .series-cover {
    float: left;
    width: 120px;
    margin-right: 1rem;
    margin-bottom: 1rem;
  }

  .series-info {
    overflow: hidden;
  }

  .series-info h2 {
    font-size: 1.25rem;
  }

  .series-info h3 {
    font-size: 1rem;
  }

  .series-info p {
    font-size: 0.9rem;
    line-height: 1.5;
  }
}

/* Character List Styles */
.character-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.character-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.character-list-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.char-color-indicator {
  width: 4px;
  height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
}

.char-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.char-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
}

.char-folder-badge {
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--bg-darker);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
}

/* Character Edit Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.char-edit-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.char-edit-modal .modal-header h3 {
  margin: 0;
  color: var(--text-color);
  font-size: 1.25rem;
}

.char-edit-modal .modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.char-edit-modal .modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  gap: 1rem;
}

.modal-footer-right {
  display: flex;
  gap: 0.75rem;
}

.char-edit-modal input[type="text"],
.char-edit-modal input[type="color"],
.char-edit-modal select {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-color);
  font-size: 1rem;
}

.char-edit-modal input[type="color"] {
  height: 50px;
  cursor: pointer;
}

.char-edit-modal input[type="text"]:focus,
.char-edit-modal select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Login Page Styles */
.login-container {
  display: flex;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 3rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  height: 80px;
  width: auto;
  margin-bottom: 1rem;
}

.login-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.login-header p {
  color: var(--text-light);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 500;
  color: var(--text-color);
}

.form-group input {
  padding: 0.75rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.login-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #ef4444;
  font-size: 0.9rem;
  text-align: center;
}

/* Admin Page - Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-color);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal .modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-darker);
  color: var(--text-color);
}

.modal-form {
  padding: 1.5rem;
}

.modal-form .form-group {
  margin-bottom: 1.5rem;
}

.modal-form .form-group:last-of-type {
  margin-bottom: 0;
}

.modal-form label {
  display: block;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.modal-form input,
.modal-form select {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.modal-form input:focus,
.modal-form select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.modal-form .form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.modal-form .form-actions .btn {
  flex: 1;
}

/* Admin Tabs Mobile Dropdown */
.admin-tabs-mobile {
  display: none;
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 2rem;
  cursor: pointer;
}

.admin-tabs-mobile:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Mobile Responsive for Modal */
@media (max-width: 768px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-header .btn {
    width: 100%;
  }

  .modal {
    padding: 0.5rem;
  }

  .modal .modal-content {
    max-height: 95vh;
  }

  .modal-form .form-actions {
    flex-direction: column;
  }

  .modal-form .form-actions .btn {
    width: 100%;
  }

  /* Admin tabs - hide buttons, show dropdown on mobile */
  .admin-tabs {
    display: none !important;
  }

  .admin-tabs-mobile {
    display: block;
  }
}
