
:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --primary: #3b82f6;
  --primaryfg: #ffffff;
  --danger: #ef4444;
  --sidebar-bg: #f9fafb;
  --sidebar-hover: #f3f4f6;
  --line-height: 24px;
  --gutter-bg: #f8f9fa;
  --gutter-active: #e8f0fe;
  --tab-bg: #ffffff;
  --tab-active: #3b82f6;
  --font-ui: 'Inter', sans-serif;
  --font-editor: 'JetBrains Mono', monospace;
  --editor-bg: #ffffff;
  --editor-font-size: 16px; /* default */
  --editor-text: #000000;
}

:root[data-theme="dark"] {
  --bg: #000000;            /* Pure black background */
  --fg: #e5e7eb;            /* Light gray text */
  --muted: #9ca3af;         /* Muted gray text */

  --card: #0b0b0b;          /* Slightly lifted black */
  --border: #1f2937;        /* Subtle borders */

  --primary: #3b82f6;       /* Blue accent */
  --primaryfg: #ffffff;

  --danger: #ef4444;

  --sidebar-bg: #000000;    /* True black sidebar */
  --sidebar-hover: #111827; /* Hover contrast */

  --gutter-bg: #000000;     /* Line number gutter */
  --gutter-active: #111827;

  --tab-bg: #000000;
  --tab-active: #3b82f6;
}

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

html{
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

body {
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}


.line-sidebar {
  width: calc(var(--gutter-digits, 3) * 1ch + 24px);
  min-width: 48px;
  height: 100%;
  background: var(--gutter-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.line-gutter {
  flex: 1;
  padding: 16px 8px 16px 12px; 
  text-align: right;
  color: var(--muted);
  user-select: none;
  font-family: var(--font-editor);
  font-size: var(--editor-font-size);
  line-height: var(--line-height);
  overflow-y: auto;
  overflow-x: hidden;
  cursor: pointer;
  height: auto; 
}

.line-gutter::-webkit-scrollbar { display: none; }

.line-number {
  padding: 0 8px 0 0;
  margin: 0;
  line-height: var(--line-height);
  height: var(--line-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-radius: 4px;
}

.line-number:hover:not(.is-wrap-cont) { background: rgba(59, 130, 246, 0.08); }

.line-number.active-line-number:not(.is-wrap-cont) {
  background: var(--gutter-active);
  color: var(--primary);
  font-weight: 600;
  text-shadow: inset 3px 0 0 var(--primary);
}

.line-number.is-wrap-cont {
  color: transparent;
  pointer-events: none;
  background: transparent;
}


.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}


.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 50;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sidebar-bg);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

.badge--warn {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.icon-btn svg { width: 18px; height: 18px; }


.tab-bar {
  height: 48px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 8px;
  gap: 8px;
}

.tabs-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.tabs-container::-webkit-scrollbar { height: 6px; }
.tabs-container::-webkit-scrollbar-track { background: transparent; }
.tabs-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--tab-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: unset;
  max-width: unset;
  width: auto;
  white-space: nowrap;
  position: relative;
  flex-shrink: 0;
}

.tab:hover { background: var(--sidebar-hover); border-color: var(--muted); }

.tab.active {
  background: var(--sidebar-bg);
  border-color: var(--tab-active);
  color: var(--tab-active);
  font-weight: 600;
}

.tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  min-width: 0;
}

.tab-name-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--fg);
  font-family: inherit;
  padding: 0;
  width: 100%;
}

.tab-close {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 0;
  padding: 0;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-close:hover { background: var(--tab-active); color: white; }

.tab-add-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tab-add-btn:hover {
  background: var(--primary);
  color: var(--primaryfg);
  border-color: var(--primary);
}

.tab-add-btn svg { width: 18px; height: 18px; }


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

.editor-shell { flex: 1; display: flex; overflow: hidden; }


.editor {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 16px 24px;
  border: none;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  resize: none;
  font-family: var(--font-editor);
  font-size: var(--editor-font-size);
  line-height: var(--line-height);
  white-space: pre-wrap;
  overflow-y: auto;
  overflow-x: auto;
  tab-size: 4;
}

.editor::placeholder { color: var(--muted); opacity: 0.5; }

.editor::-webkit-scrollbar { width: 10px; height: 10px; }
.editor::-webkit-scrollbar-track { background: transparent; }
.editor::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.editor::-webkit-scrollbar-thumb:hover { background: var(--muted); }


.stats-bar {
  height: 40px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  font-size: 13px;
  color: var(--muted);
}

.stats-bar strong { color: var(--fg); font-weight: 600; }


.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: min(500px, calc(100% - 32px));
 /* max-height: 85vh;*/
  max-height: 73vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: auto;
  outline: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.modal-title { font-size: 18px; font-weight: 600; }
.modal-body { padding: 20px; }


.setting-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--fg);
}

.font-size-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.font-size-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.font-size-slider {
  flex: 1;
  min-width: 120px;
  accent-color: var(--primary);
}

.font-size-value {
  min-width: 50px;
  text-align: center;
  font-weight: 700;
  color: var(--primary);
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar-bg);
  transition: all 0.2s ease;
}

.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.setting-row span { font-size: 14px; font-weight: 500; }


.wrap-measure {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}


.line-sidebar-header {
  height: 56px; /* SAME as .topbar */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gutter-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.line-sidebar-tabs-spacer {
  height: 48px; /* SAME as .tab-bar */
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}


@media (max-width: 768px) {
  .line-sidebar { width: 50px; }
  .line-gutter { padding: 12px 6px 12px 8px; font-size: 13px; }
  .topbar { padding: 0 12px; height: 52px; }
  .topbar-right { gap: 6px; }
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .tab-bar { height: 44px; padding: 0 6px; }
  .tab { padding: 5px 10px; }
  .tab-name { font-size: 12px; }
  .tab-add-btn { width: 32px; height: 32px; }
  .editor { padding: 12px 16px; font-size: 14px; }
  .stats-bar {
    padding: 0 16px;
    font-size: 12px;
    gap: 16px;
    height: 36px;
    overflow-x: auto;
  }
  /*.badge { font-size: 9px; padding: 3px 8px; } */
  .badge { font-size: 8px; padding: 3px 6px; }
  .line-sidebar-header { height: 52px; }
  .line-sidebar-tabs-spacer { height: 44px; }
}

@media (max-width: 480px) {
  .line-sidebar { width: 44px; }
  .line-gutter { padding: 12px 4px 12px 6px; font-size: 12px; }
  .topbar { padding: 0 8px; }
  .topbar-right { gap: 4px; }
  .icon-btn { width: 30px; height: 30px; }
  .tab { padding: 4px 8px; }
  .tab-name { font-size: 11px; }
  .tab-add-btn { width: 30px; height: 30px; }
  .tab-add-btn svg { width: 16px; height: 16px; }
  .line-sidebar-header { height: 52px; }
  .line-sidebar-tabs-spacer { height: 44px; }
}
