* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: all 0.3s ease;
}

#lineNumbers {
  white-space: pre;
  text-align: right;
  padding-right: 10px;
  font-family: monospace;
  user-select: none;
  overflow: hidden;
}

:root {
  --bg-primary: #1e1e1e;
  --bg-secondary: #2d2d30;
  --bg-tertiary: #323233;
  --bg-editor: #1e1e1e;
  --bg-preview: #ffffff;
  --text-primary: #d4d4d4;
  --text-secondary: #cccccc;
  --text-muted: #858585;
  --border-color: #2d2d30;
  --border-light: #3e3e42;
  --accent-color: #007acc;
  --accent-hover: #1177bb;
  --button-bg: #0e639c;
  --scrollbar-bg: #424242;
  --scrollbar-hover: #4f4f4f;
  --font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  --font-size: 14px;
  --line-height: 1.5;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f3f3f3;
  --bg-tertiary: #e5e5e5;
  --bg-editor: #ffffff;
  --bg-preview: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #e0e0e0;
  --border-light: #d0d0d0;
  --accent-color: #0066cc;
  --accent-hover: #0052a3;
  --button-bg: #0066cc;
  --scrollbar-bg: #cccccc;
  --scrollbar-hover: #aaaaaa;
}

.container {
  display: flex;
  height: 100vh;
  flex-direction: column;
}

/* Title Bar */
.title-bar {
  background: var(--bg-tertiary);
  height: 35px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-bottom: 1px solid var(--border-color);
  justify-content: space-between;
}

.title-bar h1 {
  font-size: 13px;
  font-weight: normal;
  color: var(--text-secondary);
}

.title-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Buttons */
.theme-toggle,
.settings-btn {
  background: var(--button-bg);
  border: none;
  color: white;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s;
}

.theme-toggle:hover,
.settings-btn:hover {
  background: var(--accent-hover);
}

/* Editor Layout */
.editor-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.editor-panel,
.preview-panel {
  width: 50%;
  display: flex;
  flex-direction: column;
}

.editor-panel {
  background: var(--bg-editor);
  border-right: 1px solid var(--border-color);
}

.preview-panel {
  background: var(--bg-preview);
}

/* Panel Header */
.panel-header {
  background: var(--bg-secondary);
  height: 35px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-bottom: 1px solid var(--border-light);
}

.panel-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: normal;
}

/* Code Editor */
.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.code-editor {
  width: 100%;
  height: 100%;
  background: var(--bg-editor);
  color: var(--text-primary);
  border: none;
  outline: none;
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: var(--line-height);
  padding: 20px 20px 20px 70px;
  resize: none;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
}

/* Scrollbar */
.code-editor::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.code-editor::-webkit-scrollbar-track {
  background: var(--bg-editor);
}

.code-editor::-webkit-scrollbar-thumb {
  background: var(--scrollbar-bg);
  border-radius: 10px;
  border: 3px solid var(--bg-editor);
}

.code-editor::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* Line Numbers */
.line-numbers {
  position: absolute;
  left: 0;
  top: 20px;
  width: 50px;
  height: calc(100% - 40px);
  background: var(--bg-editor);
  border-right: 1px solid var(--border-color);
  font-size: 12px;
  line-height: var(--line-height);
  color: var(--text-muted);
  text-align: right;
  padding: 0 10px 0 0;
  user-select: none;
  overflow: hidden;
  z-index: 1;
  font-family: var(--font-family);
}

/* Preview Frame */
.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-preview);
}

/* Status Bar */
.status-bar {
  background: var(--accent-color);
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  font-size: 11px;
  color: white;
  justify-content: space-between;
}

.status-left,
.status-right {
  display: flex;
  gap: 15px;
}

/* Toolbar */
.toolbar {
  background: var(--bg-secondary);
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-bottom: 1px solid var(--border-light);
  gap: 10px;
}

.toolbar button {
  background: var(--button-bg);
  border: none;
  color: white;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s;
}

.toolbar button:hover {
  background: var(--accent-hover);
}

/* File Tabs */
.file-tabs {
  background: var(--bg-secondary);
  height: 35px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.tab {
  background: var(--bg-editor);
  border: none;
  color: var(--text-secondary);
  padding: 8px 20px;
  font-size: 12px;
  border-right: 1px solid var(--border-color);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.tab.active {
  color: var(--text-primary);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color);
}

/* Settings Modal */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.settings-modal.active {
  display: flex;
}

.settings-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.settings-header {
  background: var(--bg-secondary);
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.close-btn:hover {
  background: var(--bg-tertiary);
}

.settings-body {
  padding: 20px;
}

.setting-group {
  margin-bottom: 25px;
}

.setting-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.setting-input,
.setting-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-editor);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.2s;
}

.setting-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.setting-range {
  width: 100%;
  margin: 10px 0;
}

.range-value {
  display: inline-block;
  margin-left: 10px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 30px;
}

.setting-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.setting-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Settings Actions */
.settings-actions {
  padding: 15px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--button-bg);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

/* Resizer */
.resizer {
  width: 4px;
  background: var(--border-color);
  cursor: col-resize;
  transition: background 0.2s;
}

.resizer:hover {
  background: var(--accent-color);
}