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

:root {
  /* Solarized Light (default) */
  --bg-main: #fdf6e3;
  --bg-alt: #eee8d5;
  --bg-highlight: #fdf6e3;
  --border: #93a1a1;
  --text: #657b83;
  --text-bright: #586e75;
  --text-muted: #93a1a1;
  --accent: #268bd2;

  /* Syntax */
  --syn-keyword: #859900;
  --syn-string: #2aa198;
  --syn-comment: #93a1a1;
  --syn-function: #268bd2;
  --syn-class: #b58900;
  --syn-number: #d33682;
  --syn-decorator: #cb4b16;
  --syn-verse: #586e75;
}

[data-theme="dark"] {
  /* Solarized Dark */
  --bg-main: #002b36;
  --bg-alt: #073642;
  --bg-highlight: #002b36;
  --border: #586e75;
  --text: #839496;
  --text-bright: #93a1a1;
  --text-muted: #586e75;
  --accent: #268bd2;

  /* Syntax */
  --syn-keyword: #859900;
  --syn-string: #2aa198;
  --syn-comment: #586e75;
  --syn-function: #268bd2;
  --syn-class: #b58900;
  --syn-number: #d33682;
  --syn-decorator: #cb4b16;
  --syn-verse: #93a1a1;
}

html, body {
  height: 100%;
}

body {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  background: var(--bg-main);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

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

.titlebar {
  background: var(--bg-alt);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.titlebar-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.btn-close { background: #dc322f; }
.btn-min { background: #b58900; }
.btn-max { background: #859900; }

.titlebar-title {
  flex: 1;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-main);
  color: var(--text-bright);
}

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

/* Sidebar */
.sidebar {
  width: 200px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.sidebar-toggle:hover {
  color: var(--text-bright);
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.file-item {
  padding: 4px 12px 4px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  transition: background 0.1s;
}

.file-item:hover {
  background: var(--bg-main);
}

.file-item.active {
  background: var(--bg-main);
  color: var(--text-bright);
}

.file-item.folder {
  color: var(--text-muted);
}

.file-item .icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
}

.folder-contents {
  display: none;
}

.folder-contents.open {
  display: block;
}

.folder-contents .file-item {
  padding-left: 28px;
}

.folder-contents .folder-contents .file-item {
  padding-left: 44px;
}

/* Editor area */
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  background: var(--bg-alt);
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  padding: 8px 12px 8px 16px;
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  font-size: 13px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-close {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}

.tab:hover .tab-close,
.tab.active .tab-close {
  opacity: 1;
}

.tab-close:hover {
  background: var(--bg-alt);
  color: var(--text-bright);
}

.tab:hover {
  background: var(--bg-highlight);
  color: var(--text-bright);
}

.tab.active {
  background: var(--bg-main);
  color: var(--text-bright);
  border-bottom: 2px solid var(--accent);
}

.editor {
  display: flex;
  background: var(--bg-main);
  flex: 1;
  overflow: hidden;
}

.line-numbers {
  padding: 20px 0;
  text-align: right;
  color: var(--text-muted);
  user-select: none;
  min-width: 50px;
  background: var(--bg-main);
  border-right: 1px solid var(--bg-alt);
  overflow-y: auto;
}

.line-numbers span {
  display: block;
  padding: 0 12px;
}

.code {
  flex: 1;
  padding: 20px;
  overflow: auto;
}

.code-content {
  display: none;
}

.code-content.active {
  display: block;
}

.code-content.media-content {
  display: none;
  padding: 20px;
  text-align: center;
}

.code-content.media-content.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.code-content iframe,
.code-content embed {
  width: 100%;
  height: 100%;
  border: none;
}

.line {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Syntax highlighting */
.keyword { color: var(--syn-keyword); }
.string { color: var(--syn-string); }
.comment { color: var(--syn-comment); font-style: italic; }
.function { color: var(--syn-function); }
.class { color: var(--syn-class); }
.variable { color: var(--syn-function); }
.number { color: var(--syn-number); }
.decorator { color: var(--syn-decorator); }
.operator { color: var(--text); }
.property { color: var(--syn-function); }
.verse { color: var(--syn-verse); }

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

a:hover {
  text-decoration: underline;
}

.statusbar {
  background: var(--bg-alt);
  color: var(--text-bright);
  padding: 4px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.statusbar:hover {
  background: var(--bg-main);
}

/* Terminal */
.terminal {
  background: var(--bg-alt);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  height: 0;
  transition: height 0.15s ease;
}

.terminal.open {
  height: 200px;
}

.terminal-resize {
  height: 2px;
  background: transparent;
  cursor: ns-resize;
  flex-shrink: 0;
}

.terminal-resize:hover,
.terminal-resize.dragging {
  background: var(--accent);
  height: 3px;
}

.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px;
}

.terminal-output {
  color: var(--text-muted);
  margin-bottom: 8px;
  flex: 1;
  overflow-y: auto;
}

.terminal-output div {
  margin: 2px 0;
}

.terminal-output .cmd { color: var(--syn-string); }
.terminal-output .err { color: #dc322f; }
.terminal-output .success { color: var(--syn-keyword); }

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.terminal-prompt {
  color: var(--syn-keyword);
}

.terminal-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-bright);
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

.terminal-input::placeholder {
  color: var(--text-muted);
}

/* Prevent text selection while resizing */
body.resizing {
  user-select: none;
  cursor: ns-resize;
}
