/* ==========================================================================
   PENPAL // NEO-BRUTALIST STYLING CORE
   ========================================================================== */

/* 1. CSS VARIABLES & COLOR PALETTES */
:root {
  /* Common Core Colors */
  --absolute-black: #000000;
  --absolute-white: #ffffff;
  
  --neon-cyan: #00f5ff;
  --neon-magenta: #ff003c;
  --neon-yellow: #e5ff00;
  --neon-green: #39ff14;
  --neon-orange: #ff5e00;
  --neon-purple: #9d00ff;

  --font-heading: 'Syne', 'Outfit', 'Space Grotesk', sans-serif;
  --font-body: 'Space Grotesk', sans-serif;
  --font-screenplay: 'Courier Prime', 'Courier New', monospace;
  --font-novel: 'Lora', Georgia, serif;
}

/* THEME 1: ELECTRIC CREAM (Default Light) */
:root[data-theme="electric-cream"] {
  --bg-primary: #ffffff;
  --bg-secondary: #ffffff;
  --text-primary: #000000;
  --text-secondary: #222222;
  --border-color: #000000;
  
  --card-bg-primary: #ffffff;
  --card-bg-accent: #e5ff00;
  --sidebar-bg: #ffffff;
  
  --shadow-offset-btn: 4px 4px 0px #000000;
  --shadow-offset-card: 8px 8px 0px #000000;
  --shadow-offset-card-hover: 12px 12px 0px #000000;
}

/* THEME 2: MIDNIGHT NEON (Dark Theme) */
:root[data-theme="midnight-neon"] {
  --bg-primary: #121212;
  --bg-secondary: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #dddddd;
  --border-color: #ffffff;
  
  --card-bg-primary: #1e1e1e;
  --card-bg-accent: #ff003c;
  --sidebar-bg: #1a1a1a;
  
  --shadow-offset-btn: 4px 4px 0px var(--neon-cyan);
  --shadow-offset-card: 6px 6px 0px var(--neon-magenta);
  --shadow-offset-card-hover: 10px 10px 0px var(--neon-cyan);
}

/* 2. BASE RESET & HTML */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
}

/* Targeted transitions specifically for elements changing colors on theme switches */
body, header, aside, main, footer, 
.neo-card, .neo-btn, .neo-input, 
.screenplay-paper, .novel-paper, .editor-toolbar, 
.stats-panel, .sidebar-module-item, .lore-card, .brutalist-lbl, .empty-library {
  transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), 
              color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  background-image: radial-gradient(var(--border-color) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
}

.hidden {
  display: none !important;
}

/* Accessibility: visible keyboard focus for all interactive elements.
   Mouse users keep the clean brutalist look; keyboard users get a clear ring. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[contenteditable="true"]:focus-visible,
.template-choice-btn:focus-visible,
.export-option-btn:focus-visible,
.binder-tab-btn:focus-visible,
.sidebar-module-item:focus-visible {
  outline: 4px solid var(--neon-purple);
  outline-offset: 2px;
}

[data-theme="midnight-neon"] :focus-visible {
  outline-color: var(--neon-cyan);
}

/* Screen-reader-only utility for visually-hidden labels */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Respect users who prefer reduced motion: disable the perpetual decorative
   animations and heavy transitions that can cause discomfort. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .shape-star,
  .empty-illustration,
  .neon-dot.pulse {
    animation: none !important;
  }
}

/* 3. NEO-BRUTALIST ATOMS & COMPONENT STYLING */

/* Solid Black Border outline */
.neo-card {
  background-color: var(--card-bg-primary);
  border: 3.5px solid var(--border-color);
  box-shadow: var(--shadow-offset-card);
  border-radius: 0px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.neo-card:hover {
  box-shadow: var(--shadow-offset-card-hover);
  transform: translate(-3px, -3px);
}

/* Interactive Buttons */
.neo-btn {
  background-color: var(--neon-yellow);
  color: #000000;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  text-transform: uppercase;
  padding: 10px 18px;
  border: 3.5px solid #000000 !important;
  box-shadow: 4px 4px 0px #000000;
  cursor: pointer;
  outline: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.2s;
  user-select: none;
}

.neo-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px #000000;
  background-color: var(--neon-cyan);
}

.neo-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0px #000000;
}

/* Form Inputs */
.neo-input {
  width: 100%;
  padding: 12px 15px;
  background-color: var(--card-bg-primary);
  color: var(--text-primary);
  border: 3px solid var(--border-color);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 0px;
  outline: none;
  box-shadow: 3px 3px 0px var(--border-color);
}

.neo-input:focus {
  border-color: var(--neon-magenta);
  box-shadow: 5px 5px 0px var(--neon-magenta);
}

textarea.neo-input {
  resize: vertical;
  min-height: 100px;
}

.text-area-large {
  min-height: 180px !important;
}

/* Custom Outlined Labels */
.brutalist-lbl {
  display: block;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background-color: var(--absolute-black);
  color: var(--absolute-white);
  padding: 4px 8px;
  width: fit-content;
  border: 2px solid var(--border-color);
}

/* Bright Contrast stickers / Tags */
.brutalist-tag {
  display: inline-block;
  padding: 4px 10px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  border: 2px solid #000000;
  box-shadow: 2px 2px 0px #000000;
  color: #000000;
  background-color: var(--neon-yellow);
}

.tag-cyan { background-color: var(--neon-cyan) !important; }
.tag-magenta { background-color: var(--neon-magenta) !important; }
.tag-yellow { background-color: var(--neon-yellow) !important; }
.tag-green { background-color: var(--neon-green) !important; }
.tag-orange { background-color: var(--neon-orange) !important; }

/* 4. BACKGROUND DECORATION SHAPES */
.decor-shape {
  position: fixed;
  font-size: 6rem;
  color: rgba(0, 0, 0, 0.05);
  font-weight: 900;
  user-select: none;
  z-index: -1;
  pointer-events: none;
}

[data-theme="midnight-neon"] .decor-shape {
  color: rgba(255, 255, 255, 0.04);
}

.shape-star {
  top: 35%;
  left: 4%;
  animation: spin 30s linear infinite;
}

.shape-circle {
  bottom: 10%;
  left: 8%;
  width: 100px;
  height: 100px;
  border: 8px solid rgba(0, 0, 0, 0.05);
  border-radius: 50%;
}

[data-theme="midnight-neon"] .shape-circle {
  border-color: rgba(255, 255, 255, 0.04);
}

.shape-triangle {
  top: 20%;
  right: 6%;
  transform: rotate(25deg);
}

.shape-square {
  bottom: 15%;
  right: 8%;
  width: 90px;
  height: 90px;
  border: 8px solid rgba(0, 0, 0, 0.05);
  transform: rotate(-15deg);
}

[data-theme="midnight-neon"] .shape-square {
  border-color: rgba(255, 255, 255, 0.04);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==================== DASHBOARD VIEW STYLING ==================== */
.dashboard-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 5px solid #000000;
  padding-bottom: 25px;
  margin-bottom: 40px;
}

.brand-badge-container {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 5.5rem;
  line-height: 0.9;
  letter-spacing: -3px;
  font-weight: 900;
  color: var(--text-primary);
  text-shadow: 5px 5px 0px #ff003c; /* Red Shadow for Light Theme */
}

:root[data-theme="midnight-neon"] .brand-title {
  text-shadow: 5px 5px 0px var(--neon-yellow); /* Yellow Shadow for Dark Theme */
}

.brand-sub {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 4px;
  background-color: var(--border-color);
  color: var(--bg-primary);
  padding: 4px 10px;
  margin-top: 10px;
  width: fit-content;
  transform: rotate(-1deg);
}

.btn-theme {
  background-color: var(--neon-cyan);
  border-radius: 0px;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  flex: 1;
  margin-bottom: 40px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-card {
  padding: 30px;
}

.new-project-card {
  background-color: var(--card-bg-primary);
  transform: rotate(-0.5deg);
}

.library-card {
  background-color: var(--card-bg-primary);
  transform: rotate(0.5deg);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 900;
  margin-bottom: 12px;
  text-transform: uppercase;
  border-bottom: 4px solid var(--border-color);
  padding-bottom: 10px;
  display: inline-block;
}

.section-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-weight: 500;
  line-height: 1.5;
}

/* Template Selectors */
.template-selector-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.template-choice-btn {
  display: flex;
  align-items: center;
  text-align: left;
  padding: 20px;
  cursor: pointer;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  width: 100%;
  border: 3.5px solid var(--border-color);
  box-shadow: 4px 4px 0px var(--border-color);
  transition: transform 0.15s, box-shadow 0.15s, background-color 0.2s;
  position: relative;
}

.template-choice-btn:hover {
  transform: translate(-4px, -4px) scale(1.01);
  box-shadow: 8px 8px 0px var(--border-color);
  background-color: var(--bg-secondary);
}

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

.template-choice-btn .brutalist-tag {
  flex-shrink: 0;
  margin-left: 20px;
  align-self: center;
}

.template-icon {
  font-size: 2.5rem;
  margin-right: 20px;
  background: var(--bg-secondary);
  border: 3.5px solid var(--border-color);
  width: 65px;
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0px var(--border-color);
}

.template-info h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.template-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 85%;
  line-height: 1.4;
}

/* Library List */
.library-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 8px;
}

.empty-library {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  border: 3px dashed var(--border-color);
  background-color: rgba(0, 0, 0, 0.02);
}

.empty-illustration {
  font-size: 4rem;
  margin: 20px 0;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

.sub-alert {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 70%;
  margin-top: 10px;
}

.btn-load-examples {
  margin-top: 22px;
  background-color: var(--neon-cyan);
}

/* Individual Library Cards */
.library-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: var(--bg-secondary);
  border: 3.5px solid var(--border-color);
  box-shadow: 4px 4px 0px var(--border-color);
}

.library-item:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--border-color);
}

.lib-item-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lib-item-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 800;
}

.lib-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  align-items: center;
}

.lib-item-actions {
  display: flex;
  gap: 10px;
}

.btn-lib-open {
  background-color: var(--neon-green);
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lib-delete {
  background-color: var(--neon-magenta);
  padding: 6px 12px;
  font-size: 0.8rem;
  color: #ffffff;
}

.brutalist-footer {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  border-top: 4px solid var(--border-color);
  padding-top: 20px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.footer-divider {
  margin: 0 10px;
  color: var(--text-secondary);
}

.footer-contact {
  color: var(--text-secondary);
}

/* Contact email — red so the "buy it" call-to-action stands out */
.footer-email {
  color: var(--neon-magenta);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 2px solid var(--neon-magenta);
  padding-bottom: 1px;
}

.footer-email:hover {
  background-color: var(--neon-magenta);
  color: #ffffff;
}

/* ==================== WORKSPACE STYLING ==================== */
.workspace-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.workspace-header {
  height: 75px;
  border-bottom: 4px solid #000000;
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 25px;
  z-index: 10;
}

.workspace-branding {
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
}

.back-arrow {
  font-size: 1.4rem;
  font-weight: 900;
  color: #000000;
  background-color: var(--neon-yellow);
  width: 40px;
  height: 40px;
  border: 3px solid #000000;
  box-shadow: 2px 2px 0px #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.back-arrow:hover {
  background-color: var(--neon-magenta);
}

.editable-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-primary);
  padding: 2px 8px;
  border: 3px solid transparent;
  outline: none;
  text-transform: uppercase;
}

.editable-title:focus {
  border-color: #000000;
  background-color: var(--bg-primary);
}

.workspace-controls {
  display: flex;
  gap: 12px;
}

.nav-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-focus { background-color: var(--neon-orange); color: #000; }
.btn-binder { background-color: var(--neon-cyan); }
.btn-export { background-color: var(--neon-green); }
.btn-close { background-color: #ffffff; }

/* Workspace Split Layout */
.workspace-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  padding: 15px;
  gap: 15px;
}

/* Sidebar panel */
.workspace-sidebar {
  width: 300px;
  display: flex;
  flex-direction: column;
  background-color: var(--sidebar-bg);
  flex-shrink: 0;
  transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar-header {
  padding: 15px;
  border-bottom: 3.5px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--border-color);
  color: var(--bg-secondary);
}

.sidebar-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.btn-add-small {
  padding: 4px 10px;
  font-size: 0.75rem;
  background-color: var(--neon-yellow);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-module-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 2.5px solid var(--border-color);
  font-weight: 700;
  font-size: 0.88rem;
  background-color: var(--bg-primary);
  cursor: pointer;
  box-shadow: 2px 2px 0px var(--border-color);
}

.sidebar-module-item:hover {
  background-color: var(--bg-secondary);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px var(--border-color);
}

.sidebar-module-item.active {
  background-color: var(--neon-cyan);
  color: #000;
  border-color: #000;
  box-shadow: 3px 3px 0px #000;
}

.sidebar-module-item.active:hover {
  background-color: var(--neon-cyan);
}

.module-meta-actions {
  display: flex;
  gap: 6px;
  opacity: 0.8;
}

.module-meta-actions:hover {
  opacity: 1;
}

.btn-module-del {
  border: 1.5px solid #000;
  background: var(--neon-magenta);
  color: #fff;
  width: 20px;
  height: 20px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Analytics Stats Block in Sidebar */
.stats-panel {
  margin: 12px;
  padding: 12px;
  background-color: var(--bg-primary);
  box-shadow: 4px 4px 0px var(--border-color);
}

.stats-panel h4 {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 5px;
  margin-bottom: 8px;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 800;
}

.stat-lbl {
  color: var(--text-secondary);
  margin-right: 6px;
}

.stat-val {
  color: var(--text-primary);
}

.full-stat-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 5px;
  border-top: 2px solid var(--border-color);
  padding-top: 8px;
}

.goal-bar-bg {
  height: 14px;
  width: 100%;
  background-color: var(--bg-secondary);
  box-shadow: 2px 2px 0px var(--border-color);
}

.goal-bar-fill {
  height: 100%;
  background-color: var(--neon-green);
  width: 0%;
}

.stat-val-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Middle Writing Canvas */
.workspace-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  overflow: hidden;
}

.editor-toolbar {
  min-height: 65px;
  height: auto;
  background-color: var(--bg-primary);
  border: none;
  border-bottom: 3.5px solid var(--border-color);
  box-shadow: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  padding: 12px 18px;
}

.toolbar-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  gap: 10px;
}

.toolbar-hint {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background-color: var(--border-color);
  color: var(--bg-secondary);
  padding: 4px 8px;
  border: 2px solid var(--border-color);
  transform: rotate(-0.5deg);
  width: fit-content;
  box-shadow: 2px 2px 0px var(--border-color);
}

.toolbar-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-btn {
  padding: 6px 10px;
  font-size: 0.7rem;
  box-shadow: 2px 2px 0px #000;
  background-color: var(--bg-secondary);
}

.tool-btn.active {
  background-color: var(--neon-yellow);
}

.editor-stage {
  flex: 1;
  overflow-y: auto;
  background-color: var(--bg-primary);
  display: flex;
  justify-content: center;
  padding: 25px;
}

.writing-canvas {
  width: 100%;
  max-width: 880px;
}

/* ==================== SCREENPLAY EDITOR SPECIFICS ==================== */
.screenplay-layout {
  max-width: 800px;
}

.screenplay-paper {
  background-color: var(--bg-secondary);
  color: var(--text-primary) !important;
  border-radius: 0px;
  box-shadow: 6px 6px 0px var(--border-color);
  min-height: 800px;
  padding: 1.2in 1in 1in 1.2in;
}

.screenplay-editable {
  font-family: var(--font-screenplay);
  font-size: 11pt;
  line-height: 1.5;
  outline: none;
  min-height: 600px;
  white-space: pre-wrap;
}

/* Custom Screenplay Element Margins & Formats */
.screenplay-editable p {
  margin: 0 0 12pt 0;
  min-height: 1em;
}

/* Scene Heading */
.screenplay-editable [data-type="scene-heading"] {
  text-transform: uppercase;
  font-weight: bold;
  margin-top: 18pt;
  margin-bottom: 12pt;
  text-align: left;
}

/* Action */
.screenplay-editable [data-type="action"] {
  text-align: left;
}

/* Character Name */
.screenplay-editable [data-type="character"] {
  text-transform: uppercase;
  margin-left: 33.3%;
  margin-top: 12pt;
  margin-bottom: 2pt;
  width: 60%;
  text-align: left;
}

/* Parenthetical instruction */
.screenplay-editable [data-type="parenthetical"] {
  margin-left: 23.3%;
  margin-right: 25%;
  margin-bottom: 2pt;
  text-align: left;
}

.screenplay-editable [data-type="parenthetical"]::before { content: "("; }
.screenplay-editable [data-type="parenthetical"]::after { content: ")"; }

/* Dialogue Blocks */
.screenplay-editable [data-type="dialogue"] {
  margin-left: 18%;
  margin-right: 20%;
  margin-bottom: 12pt;
  width: 62%;
  text-align: left;
}

/* Transitions */
.screenplay-editable [data-type="transition"] {
  text-transform: uppercase;
  text-align: right;
  margin-left: 55%;
  margin-top: 12pt;
  margin-bottom: 12pt;
}

/* Placeholder for empty editable screenplay */
.screenplay-editable:empty::before,
.novel-editable:empty::before {
  content: attr(placeholder);
  color: #999;
  font-style: italic;
  pointer-events: none;
}

/* ==================== NOVEL EDITOR SPECIFICS ==================== */
.novel-paper {
  background-color: var(--bg-secondary);
  color: var(--text-primary) !important;
  box-shadow: 6px 6px 0px var(--border-color);
  min-height: 800px;
  padding: 1.2in 1.2in;
}

.novel-editable {
  font-family: var(--font-novel);
  font-size: 1.15rem;
  line-height: 1.6;
  outline: none;
  min-height: 600px;
}

.novel-editable h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 40px;
  text-transform: uppercase;
  border-bottom: 3.5px solid #000;
  padding-bottom: 15px;
}

.novel-editable h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  text-align: center;
  margin: 30px 0;
  letter-spacing: 5px;
}

.novel-editable p {
  margin-bottom: 1.2rem;
  text-align: justify;
  text-indent: 2em;
}

.novel-editable p:first-of-type, 
.novel-editable h1 + p {
  text-indent: 0;
}

.novel-editable blockquote {
  border-left: 5px solid #000;
  background-color: #ffffff;
  padding: 15px 20px;
  margin: 20px 0;
  font-style: italic;
}

/* ==================== GAME STORY EDITOR SPECIFICS ==================== */
.game-layout {
  max-width: 100% !important;
}

.game-stage-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.node-editor-form {
  padding: 25px;
  background-color: var(--bg-secondary);
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.flex-row-layout {
  display: flex;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 15px;
}

/* Choice card */
.choices-container {
  padding: 20px;
  background-color: var(--bg-secondary);
}

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

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-fork-card {
  display: flex;
  align-items: flex-end;
  gap: 15px;
  padding: 15px;
  background-color: var(--bg-primary);
  border: 2.5px solid var(--border-color);
  box-shadow: 3px 3px 0px var(--border-color);
}

.choice-fork-input-group {
  flex: 3;
}

.choice-fork-select-group {
  flex: 2;
}

.btn-choice-del {
  background-color: var(--neon-magenta);
  color: #fff;
  padding: 11px 15px;
  border: 2.5px solid #000;
  font-size: 0.85rem;
}

/* Flowchart diagram styles */
.visual-map-panel {
  padding: 20px;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  height: 650px;
}

.map-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  border-bottom: 3px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.btn-refresh {
  padding: 5px 12px;
  font-size: 0.75rem;
  background-color: var(--neon-cyan);
}

.map-canvas-container {
  flex: 1;
  position: relative;
  overflow: auto;
  border: 3px solid var(--border-color);
  background-color: var(--bg-primary);
  background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
  cursor: grab;
}

.map-canvas-container:active {
  cursor: grabbing;
}

#flowchart-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 2000px;
  height: 2000px;
  pointer-events: none;
  z-index: 1;
}

.flowchart-nodes-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 2000px;
  height: 2000px;
  z-index: 2;
}

.flowchart-node-widget {
  position: absolute;
  width: 170px;
  padding: 12px;
  background-color: #ffffff;
  color: #000000 !important;
  border: 3px solid #000000;
  box-shadow: 4px 4px 0px #000000;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: move;
  user-select: none;
}

.flowchart-node-widget:hover {
  box-shadow: 6px 6px 0px #000000;
}

.flowchart-node-widget.active {
  background-color: var(--neon-cyan);
}

.flowchart-node-title {
  font-family: var(--font-heading);
  text-transform: uppercase;
  border-bottom: 2px solid #000;
  padding-bottom: 4px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flowchart-node-speaker {
  font-size: 0.65rem;
  background-color: var(--neon-magenta);
  color: #fff;
  padding: 2px 4px;
  width: fit-content;
  margin-bottom: 6px;
}

.flowchart-node-snippet {
  font-weight: 500;
  color: #333;
  line-height: 1.3;
  height: 2.6em;
  overflow: hidden;
}

/* ==================== WORLD BINDER DRAWER (Right) ==================== */
.workspace-binder {
  width: 320px;
  display: flex;
  flex-direction: column;
  background-color: var(--sidebar-bg);
  flex-shrink: 0;
  transition: width 0.3s ease, transform 0.3s ease;
}

.binder-header {
  padding: 15px;
  border-bottom: 3.5px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--border-color);
  color: var(--bg-secondary);
}

.binder-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
}

.binder-tabs {
  display: flex;
  border-bottom: 3px solid var(--border-color);
}

.binder-tab-btn {
  flex: 1;
  font-size: 0.72rem;
  padding: 8px 4px;
  box-shadow: none !important;
  border-radius: 0;
  background-color: var(--bg-primary);
  border: none;
  border-bottom: 3px solid transparent;
  border-right: 2.5px solid var(--border-color);
}

.binder-tab-btn:last-child {
  border-right: none;
}

.binder-tab-btn.active {
  background-color: var(--neon-yellow);
  font-weight: 800;
  border-bottom: 3px solid var(--border-color) !important;
}

.binder-list {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.lore-card {
  padding: 15px;
  transform: rotate(0.5deg);
}

.lore-card:nth-child(even) {
  transform: rotate(-0.5deg);
}

.lore-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 5px;
}

.lore-card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
}

.btn-lore-del {
  border: 1.5px solid #000;
  background: var(--neon-magenta);
  color: #fff;
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lore-card-role {
  margin-bottom: 8px;
}

.lore-card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: pre-wrap;
}

/* ==================== WORKSPACE FOOTER STATUS ==================== */
.workspace-footer {
  height: 36px;
  background-color: var(--border-color);
  color: var(--bg-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  font-size: 0.75rem;
  font-weight: 800;
  z-index: 10;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.neon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--neon-green);
  display: inline-block;
}

.pulse {
  animation: neon-pulse 1.5s infinite;
}

@keyframes neon-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(57, 255, 20, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 5px rgba(57, 255, 20, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(57, 255, 20, 0); }
}

.helper-badge {
  background-color: var(--neon-cyan);
  color: #000;
  padding: 2px 8px;
  border: 1.5px solid #000;
  font-size: 0.7rem;
}

/* Focus mode overrides */
.focus-mode #sidebar-panel,
.focus-mode #binder-panel {
  display: none !important;
}

.focus-mode .workspace-canvas {
  margin: 0 auto;
  max-width: 900px;
}

/* ==================== MODAL STYLING ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.brutalist-modal {
  width: 90%;
  max-width: 580px;
  background-color: var(--bg-primary);
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(1);
  animation: pop-modal 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

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

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-close-btn {
  background-color: var(--neon-magenta);
  color: #fff;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 0.9rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 3.5px solid var(--border-color);
  padding-top: 15px;
}

.btn-cancel {
  background-color: #ffffff;
}

.btn-submit {
  background-color: var(--neon-green);
}

/* Export Grid in Modal */
.export-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

@media (max-width: 500px) {
  .export-options-grid {
    grid-template-columns: 1fr;
  }
}

.export-option-btn {
  display: flex;
  flex-direction: column;
  padding: 15px;
  cursor: pointer;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  text-align: left;
  border: 3px solid var(--border-color);
  box-shadow: 3px 3px 0px var(--border-color);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.export-option-btn:hover {
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0px var(--border-color);
}

.export-icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.export-info h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.export-info p {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.export-option-btn .brutalist-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.55rem;
  padding: 2px 4px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  top: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  pointer-events: none;
}

.brutalist-toast {
  pointer-events: auto;
  background-color: var(--neon-green);
  color: #000000;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 15px 25px;
  border: 3.5px solid #000000;
  box-shadow: 6px 6px 0px #000000;
  display: flex;
  align-items: center;
  gap: 12px;
  text-transform: uppercase;
  animation: slide-in-toast 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-error {
  background-color: var(--neon-magenta);
  color: #ffffff;
}

@keyframes slide-in-toast {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}

.toast-exit {
  animation: slide-out-toast 0.2s ease forwards;
}

@keyframes slide-out-toast {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

/* ==================== ALIGNMENT & SUBJECT POLISH OVERRIDES ==================== */

/* Chunky Brutalist Custom Scrollbars */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-left: 3px solid var(--border-color);
  border-top: 3px solid var(--border-color);
}

::-webkit-scrollbar-thumb {
  background: var(--neon-yellow);
  border: 3px solid var(--border-color);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

/* Dropdown Arrow & Reset Alignments */
select.neo-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='square' stroke-linejoin='miter'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 16px;
  padding-right: 45px !important;
  appearance: none;
  -webkit-appearance: none;
}

[data-theme="midnight-neon"] select.neo-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='square' stroke-linejoin='miter'><polyline points='6 9 12 15 18 9'></polyline></svg>");
}

/* Button & Card default resets to align perfectly across browsers */
button.neo-btn, 
button.template-choice-btn,
button.export-option-btn {
  font-family: var(--font-heading);
  font-weight: 800;
  outline: none;
  border-radius: 0;
}

button.template-choice-btn,
button.export-option-btn {
  color: var(--text-primary);
}

/* Large Input Fields */
.input-large {
  font-size: 1.35rem !important;
  font-weight: 800 !important;
  padding: 15px 20px !important;
}

/* World Binder button specific fonts */
.binder-tab-btn {
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
}

/* ==================== HIGH-PERFORMANCE PRINT & PDF STYLESHEET ==================== */
@media print {
  /* Set document size and high-contrast backgrounds */
  @page {
    size: letter;
    margin: 0;
  }
  
  html, body {
    background-color: #ffffff !important;
    background-image: none !important;
    color: #000000 !important;
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
  }
  
  /* STRICT DOM TREE ISOLATION: Hide all elements except the active editor canvas content */
  body > * {
    display: none !important;
  }
  body > #workspace {
    display: block !important;
  }
  #workspace > * {
    display: none !important;
  }
  #workspace > .workspace-layout {
    display: block !important;
  }
  .workspace-layout > * {
    display: none !important;
  }
  .workspace-layout > .workspace-canvas {
    display: block !important;
  }
  .workspace-canvas > * {
    display: none !important;
  }
  .workspace-canvas > .editor-stage {
    display: block !important;
  }
  
  /* Reset workspace bounds to take absolute page coverage */
  #workspace,
  .workspace-layout {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    width: 100% !important;
  }
  
  .workspace-canvas {
    border: none !important;
    box-shadow: none !important;
    background-color: #ffffff !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  .editor-stage {
    padding: 0 !important;
    background-color: #ffffff !important;
    overflow: visible !important;
    display: block !important;
    height: auto !important;
    width: 100% !important;
  }
  
  .writing-canvas,
  .screenplay-layout,
  .novel-layout,
  .game-layout {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    height: auto !important;
    background-color: #ffffff !important;
  }
  
  .screenplay-paper {
    border: none !important;
    box-shadow: none !important;
    padding: 1.0in 1.0in 1.0in 1.5in !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    color: #000000 !important;
    background-color: #ffffff !important;
    display: block !important;
    box-sizing: border-box !important;
  }

  .novel-paper {
    border: none !important;
    box-shadow: none !important;
    padding: 1.0in !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    color: #000000 !important;
    background-color: #ffffff !important;
    display: block !important;
    box-sizing: border-box !important;
  }
  
  /* Screenplay-specific printing spacing standards */
  .screenplay-editable {
    font-family: var(--font-screenplay) !important;
    font-size: 12pt !important;
    line-height: 1.5 !important;
    color: #000000 !important;
    white-space: pre-wrap !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }
  
  .screenplay-editable p {
    margin: 0 0 12pt 0 !important;
    page-break-inside: avoid !important;
  }
  
  .screenplay-editable p[data-type="scene-heading"] {
    page-break-after: avoid !important; /* Never leave a scene header stranded at the bottom of a page */
    margin-top: 18pt !important;
    font-weight: bold !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: auto !important;
  }

  .screenplay-editable p[data-type="action"] {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: auto !important;
  }

  .screenplay-editable p[data-type="character"] {
    margin-left: 2.0in !important;
    width: 4.0in !important;
    margin-right: 0 !important;
  }

  .screenplay-editable p[data-type="parenthetical"] {
    margin-left: 1.5in !important;
    width: 2.5in !important;
    margin-right: 0 !important;
  }

  .screenplay-editable p[data-type="dialogue"] {
    margin-left: 1.0in !important;
    width: 3.5in !important;
    margin-right: 0 !important;
  }

  .screenplay-editable p[data-type="transition"] {
    margin-left: 4.0in !important;
    width: 2.0in !important;
    text-align: right !important;
  }
  
  /* Novel-specific printing standards */
  .novel-editable {
    font-family: var(--font-novel) !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
    color: #000000 !important;
  }
  
  .novel-editable h1 {
    page-break-before: always !important; /* Force each chapter onto a fresh printable PDF page */
    font-size: 24pt !important;
    text-align: center !important;
    margin-bottom: 30pt !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
  }

  .novel-editable h2 {
    font-size: 16pt !important;
    text-align: center !important;
    margin: 20pt 0 !important;
  }

  .novel-editable p {
    margin-bottom: 12pt !important;
    text-align: justify !important;
    text-indent: 2em !important;
  }
  
  .novel-editable p:first-of-type,
  .novel-editable h1 + p {
    text-indent: 0 !important;
  }
  
  .novel-editable blockquote {
    border-left: none !important;
    background-color: #ffffff !important;
    padding: 0 !important;
    margin: 15pt 0.5in !important;
    font-style: italic !important;
  }
}
