:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e8e8e8;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border-color: #d0d0d0;
  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --success-color: #10b981;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --text-primary: #e8e8e8;
  --text-secondary: #b8b8b8;
  --text-tertiary: #888888;
  --border-color: #404040;
  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --success-color: #34d399;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow);
  z-index: 100;
}

.header-left h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.header-center {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  max-width: 500px;
}

.script-title-input,
.script-author-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  padding: 4px 8px;
  outline: none;
  font-family: inherit;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.script-title-input {
  font-weight: 600;
  font-size: 18px;
}

.script-author-input {
  font-size: 14px;
  color: var(--text-secondary);
}

.script-title-input:hover,
.script-author-input:hover {
  background-color: var(--bg-tertiary);
}

.script-title-input:focus,
.script-author-input:focus {
  background-color: var(--bg-tertiary);
}

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

.btn {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

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

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

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.icon-btn-small {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn-small:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.scripts-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.script-item {
  padding: 12px;
  margin-bottom: 4px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.script-item:hover {
  background-color: var(--bg-tertiary);
  transform: translateX(2px);
}

.script-item.active {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.script-item-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.script-item.active .script-item-title {
  color: white;
}

.script-item-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.script-item.active .script-item-meta {
  color: rgba(255, 255, 255, 0.8);
}

.script-item-actions {
  display: flex;
  gap: 4px;
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  transition: all 0.2s ease;
}

.delete-btn:hover {
  background-color: #ef4444;
  color: white;
}

.script-item.active .delete-btn {
  color: rgba(255, 255, 255, 0.8);
}

.script-item.active .delete-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.toolbar {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.format-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.format-btn {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-size: 13px;
}

.format-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.format-btn.active {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.format-icon {
  font-weight: 700;
  font-size: 14px;
}

.format-label {
  font-size: 12px;
}

.toolbar-info {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  align-items: center;
}

.auto-save-status {
  color: var(--success-color);
  font-size: 12px;
}

.editor {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  font-size: 12pt;
  line-height: 1.5;
  max-width: 8.5in;
  margin: 0 auto;
  width: 100%;
  outline: none;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.editor:focus {
  outline: none;
}

.editor > div {
  margin-bottom: 12px;
  min-height: 1.5em;
}

.editor div[data-format="action"] {
  text-align: left;
  margin-left: 0;
  font-weight: 400;
}

.editor div[data-format="heading"] {
  text-align: left;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 12px;
  text-decoration: underline;
}

.editor div[data-format="character"] {
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 12px;
}

.editor div[data-format="dialogue"] {
  text-align: left;
  margin-left: 1.5in;
  margin-right: 1.5in;
  font-weight: 400;
  font-style: normal;
}

.editor div[data-format="parenthetical"] {
  text-align: center;
  font-style: italic;
  font-weight: 400;
}

.editor div[data-format="transition"] {
  text-align: right;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 12px;
  margin-bottom: 12px;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary);
  font-style: italic;
}

@media (max-width: 768px) {
  .sidebar {
    width: 220px;
  }

  .header-center {
    max-width: 300px;
  }

  .format-label {
    display: none;
  }

  .format-btn {
    padding: 6px 10px;
  }

  .editor {
    padding: 20px;
  }

  .toolbar-info {
    font-size: 11px;
    gap: 8px;
  }
}

@media print {
  .app-header,
  .sidebar,
  .toolbar {
    display: none;
  }

  .editor {
    max-width: 100%;
    padding: 1in;
  }
}
