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

:root {
  --bg-dark: #1a1a1a;
  --bg-dark: #1f1f1f;
  --bg-mid: #242424;
  --bg-light: #2d2d2d;
  --bg-header: #2a2a2a;
  --bg-hover: #353535;
  --bg-active: #3a3a3a;
  --text-primary: #e0e0e0;
  --text-secondary: #999999;
  --text-muted: #666666;
  --accent: #4a90d9;
  --accent-hover: #5ba0e9;
  --danger: #e05050;
  --warning: #d9a040;
  --success: #50b070;
  --cardBorders: #3a3a3a;
  --border: #000000;
  --scrollbar-bg: #2a2a2a;
  --scrollbar-thumb: #444;
  --tab-height: 32px;
  --corner-size: 14px;
}

/* ============ Material Symbols ============ */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400;
  src: url(https://fonts.gstatic.com/s/materialsymbolsoutlined/v352/kJF1BvYX7BgnkSrUwT8OhrdQw4oELdPIeeII9v6oDMzByHX9rA6RzaxHMPdY43zj-jCxv3fzvRNU22ZXGJpEpjC_1v-p_4MrImHCIJIZrDCvHOej.woff2) format('woff2');
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-dark);
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Tab Bar */
#tab-bar {
  display: flex;
  align-items: stretch;
  height: var(--tab-height);
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

#tab-list {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}

#tab-list::-webkit-scrollbar {
  height: 4px;
}

.tab {
  display: flex;
  align-items: center;
  padding: 0 10px;
  min-width: 80px;
  max-width: 160px;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.tab.active {
  background: var(--bg-light);
  border-bottom: 2px solid var(--accent);
}

.tab-dragging {
  opacity: 0.4;
}

.tab-drag-left {
  border-left: 2px solid var(--accent);
}

.tab-drag-right {
  border-right: 2px solid var(--accent);
}

.tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--text-secondary);
}

.tab.active .tab-name {
  color: var(--text-primary);
}

.tab-rename-input {
  background: var(--bg-dark);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  font-size: 12px;
  padding: 1px 4px;
  width: 100%;
  outline: none;
}

.tab-close {
  margin-left: 6px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.1s;
  padding: 2px;
  line-height: 1;
}

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

.tab-close:hover {
  color: var(--danger);
}

#add-tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 100%;
  padding: 0 6px;
  background: var(--bg-dark);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

#add-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Tab context menu */
.tab-context-menu {
  position: fixed;
  z-index: 10001;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 0;
  min-width: 120px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.tab-context-item {
  padding: 5px 16px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}

.tab-context-item:hover {
  background: var(--accent);
  color: #fff;
}

/* Page Container */
#page-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.layout-root {
  width: 100%;
  height: 100%;
  display: flex;
}

/* Split containers */
.layout-split {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.layout-split-horizontal {
  flex-direction: row;
}

.layout-split-vertical {
  flex-direction: column;
}

.layout-child {
  overflow: hidden;
  display: flex;
  min-width: 0;
  min-height: 0;
}

/* Resize handles between split children */
.resize-handle {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  background: var(--border);
  transition: background 0.1s;
}

.resize-handle-horizontal {
  width: 3px;
  cursor: ew-resize;
}

.resize-handle-horizontal:hover,
.resize-handle-horizontal:active {
  background: var(--accent);
}

.resize-handle-vertical {
  height: 3px;
  cursor: ns-resize;
}

.resize-handle-vertical:hover,
.resize-handle-vertical:active {
  background: var(--accent);
}

/* View Leaf */
.view-leaf {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-dark);
  min-height: 0;
  min-width: 0;
  padding:0 4px;
  border-radius: 10px;
  outline: 8px solid var(--border);
}

.view-leaf.merge-target {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(74, 144, 217, 0.08);
}

/* View Body */
.view-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
  min-width: 0;
}

.view-body ::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

.view-body ::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

.view-body ::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* Corner Handles */
.corner-handle {
  position: absolute;
  width: var(--corner-size);
  height: var(--corner-size);
  z-index: 10;
  cursor: crosshair;
  opacity: 0;
  transition: opacity 0.15s;
}

.view-leaf:hover .corner-handle {
  opacity: 1;
}

.corner-handle::before,
.corner-handle::after {
  content: '';
  position: absolute;
  background: var(--text-muted);
}

.corner-tl { top: -1px; left: -1px; }
.corner-tl::before { width: 8px; height: 1px; top: 2px; left: 2px; }
.corner-tl::after { width: 1px; height: 8px; top: 2px; left: 2px; }

.corner-tr { top: -1px; right: -1px; }
.corner-tr::before { width: 8px; height: 1px; top: 2px; right: 2px; }
.corner-tr::after { width: 1px; height: 8px; top: 2px; right: 2px; }

.corner-bl { bottom: -1px; left: -1px; }
.corner-bl::before { width: 8px; height: 1px; bottom: 2px; left: 2px; }
.corner-bl::after { width: 1px; height: 8px; bottom: 2px; left: 2px; }

.corner-br { bottom: -1px; right: -1px; }
.corner-br::before { width: 8px; height: 1px; bottom: 2px; right: 2px; }
.corner-br::after { width: 1px; height: 8px; bottom: 2px; right: 2px; }

.corner-handle:hover {
  opacity: 1 !important;
}

.corner-handle:hover::before,
.corner-handle:hover::after {
  background: var(--accent);
}

/* Drag overlay */
.drag-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  cursor: crosshair;
}

/* Split Ghost */
.split-ghost {
  display: none;
  pointer-events: none;
}

/* Merge target highlight */
.merge-target {
  outline: 2px solid var(--accent) !important;
  outline-offset: -2px !important;
  background: rgba(74, 144, 217, 0.08) !important;
}

.view-error {
  padding: 20px;
  color: var(--danger);
  text-align: center;
  font-size: 12px;
}
