:root {
  color-scheme: light dark;
  --bg: #161a1f;
  --panel: #1f252d;
  --panel-border: #2d3642;
  --panel-hover: #2a333f;
  --accent: #4fc1ff;
  --accent-strong: #82f6ff;
  --text: #f7f9fc;
  --text-muted: #a0acbe;
  --splitter: #313a46;
  --context-bg: rgba(24, 28, 34, 0.98);
  --shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  font-family: "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top left, #1c232f, #11151b 55%);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  width: 100%;
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(15, 18, 23, 0.92);
  backdrop-filter: blur(24px);
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: stretch;
  padding: 6px 12px;
  background: rgba(24, 28, 34, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: 12px;
}

.branding {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}

.branding h1 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.08rem;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.tab-strip {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tab-list {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(130, 246, 255, 0.25) transparent;
}

.tab-list::-webkit-scrollbar {
  height: 6px;
}

.tab-list::-webkit-scrollbar-track {
  background: transparent;
}

.tab-list::-webkit-scrollbar-thumb {
  background: rgba(130, 246, 255, 0.25);
  border-radius: 999px;
}

.tab-item {
  display: inline-flex;
  align-items: stretch;
  background: rgba(26, 32, 41, 0.7);
  border: 1px solid rgba(90, 110, 130, 0.45);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  backdrop-filter: blur(8px);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  min-width: 0;
}

.tab-item.is-active {
  background: linear-gradient(145deg, rgba(46, 54, 66, 0.95), rgba(30, 36, 46, 0.95));
  border-color: rgba(130, 246, 255, 0.45);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.26);
  transform: translateY(2px);
}

.tab-trigger {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-trigger:focus {
  outline: none;
}

.tab-item:focus-within .tab-trigger,
.tab-item:hover .tab-trigger {
  color: var(--accent-strong);
}

.tab-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  transition: color 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.tab-item.is-active .tab-close {
  opacity: 1;
  pointer-events: auto;
}

.tab-item:hover .tab-close,
.tab-item:focus-within .tab-close {
  opacity: 1;
  pointer-events: auto;
}

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

.tab-action {
  flex: 0 0 auto;
  width: 28px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(90, 110, 130, 0.45);
  background: rgba(26, 32, 41, 0.85);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.tab-action:hover,
.tab-action:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-hover);
}

.layout-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
}

.preset-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.preset-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.preset-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preset-tools input {
  min-width: 150px;
}

.layout-controls button,
.layout-controls input,
.layout-controls select {
  background: rgba(26, 32, 41, 0.85);
  border: 1px solid rgba(90, 110, 130, 0.45);
  border-radius: 5px;
  color: var(--text);
  padding: 4px 10px;
  font-size: 0.74rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.layout-controls button:hover,
.layout-controls input:focus,
.layout-controls select:hover,
.layout-controls select:focus {
  border-color: var(--accent);
  background: var(--panel-hover);
  outline: none;
}

.layout-controls button {
  cursor: pointer;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(79, 193, 255, 0.25), rgba(130, 246, 255, 0.4));
  border-color: rgba(130, 246, 255, 0.45);
  color: var(--text);
  font-weight: 600;
}

.primary-action .action-indicator {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 6px rgba(79, 193, 255, 0.6);
}

.layout-controls .toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
}

.layout-controls .toggle {
  margin-left: 4px;
}

.more-actions {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.more-actions span {
  transform: translateY(-1px);
  letter-spacing: 2px;
}

.more-actions[aria-expanded="true"] {
  background: rgba(79, 193, 255, 0.18);
  border-color: rgba(130, 246, 255, 0.45);
}

.action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 6px;
  gap: 4px;
  background: rgba(18, 22, 28, 0.94);
  border: 1px solid rgba(130, 246, 255, 0.25);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 120;
}

.action-menu[hidden] {
  display: none;
}

.action-menu button {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
  font-size: 0.75rem;
  padding: 8px 10px;
  border-radius: 8px;
}

.action-menu button:hover,
.action-menu button:focus-visible {
  background: rgba(79, 193, 255, 0.18);
  border-color: rgba(130, 246, 255, 0.45);
}

.menu-icon {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  opacity: 0.75;
}

@media (max-width: 1080px) {
  .tagline-inline {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout-controls {
    gap: 4px;
  }
}

@media (max-width: 760px) {
  .layout-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 4px;
  }

  .preset-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .preset-tools input {
    flex: 1;
    min-width: 120px;
  }

  .primary-action {
    order: 1;
  }

  .layout-controls .toggle {
    order: 2;
  }

  .more-actions {
    order: 3;
  }
}

.workspace-shell {
  position: relative;
  flex: 1;
  display: flex;
  padding: 8px 10px 12px;
  gap: 8px;
}

.workspace {
  flex: 1;
  background: rgba(18, 22, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  display: flex;
}

.floating-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  z-index: 30;
}

.split-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

.split-container.split-vertical {
  flex-direction: row;
}

.split-container.split-horizontal {
  flex-direction: column;
}

.split-child {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 40px;
  min-width: 40px;
}

.splitter {
  background: var(--splitter);
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splitter::before {
  content: "";
  background: var(--text-muted);
  opacity: 0.5;
  border-radius: 999px;
}

.splitter-vertical {
  width: 6px;
  margin: 0 4px;
  height: 100%;
  align-self: stretch;
  cursor: col-resize;
}

.splitter-vertical::before {
  width: 2px;
  height: 100%;
}

.splitter-horizontal {
  height: 6px;
  margin: 4px 0;
  width: 100%;
  align-self: stretch;
  cursor: row-resize;
}

.splitter-horizontal::before {
  height: 2px;
  width: 100%;
  max-width: none;
}

.splitter.is-dragging {
  background: var(--accent);
}

.pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  background: rgba(28, 34, 44, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.035);
  border-radius: 10px;
  margin: 2px;
  overflow: visible;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
}

.pane.is-focused {
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(79, 193, 255, 0.35);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  background: rgba(33, 39, 48, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: 8px;
  border-radius: 10px 10px 0 0;
  cursor: grab;
}

.pane-header.is-dragging {
  cursor: grabbing;
}

.pane-drag-region {
  flex: 1 1 auto;
  min-height: 18px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  color: var(--text-muted);
  pointer-events: none;
}

.pane.is-dragging-origin {
  opacity: 0.35;
  transition: opacity 0.12s ease;
}

.pane.is-drop-hover {
  opacity: 0.55;
  transition: opacity 0.18s ease;
}

.pane-drag-preview {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate3d(-9999px, -9999px, 0);
  pointer-events: none;
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(28, 34, 44, 0.92);
  border: 1px solid rgba(130, 246, 255, 0.35);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.8rem;
}

.pane-drag-preview-label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.pane-drag-preview-icon {
  box-shadow: none;
}

.pane-hover-overlay {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1900;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.24s ease;
  transform: translate3d(-9999px, -9999px, 0);
}

.pane-view-controls,
.pane-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.pane-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pane-icon-button:hover {
  background: rgba(79, 193, 255, 0.18);
  border-color: rgba(79, 193, 255, 0.45);
}

.pane-icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pane-icon-button[aria-expanded="true"] {
  background: rgba(79, 193, 255, 0.22);
  border-color: rgba(130, 246, 255, 0.55);
}

.pane-view-toggle {
  color: var(--text);
}

.pane-action-toggle {
  color: var(--text-muted);
}

.pane-action-toggle:hover,
.pane-action-toggle:focus-visible,
.pane-action-toggle[aria-expanded="true"] {
  color: var(--text);
}

.pane-view-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(79, 193, 255, 0.2);
  color: var(--text);
  text-transform: uppercase;
  border: 1px solid rgba(130, 246, 255, 0.4);
  box-shadow: 0 0 12px rgba(79, 193, 255, 0.25);
}

.pane-view-icon[data-view-id="map"],
.view-preview-icon[data-view-id="map"] {
  background: linear-gradient(135deg, rgba(63, 201, 255, 0.2), rgba(36, 144, 255, 0.35));
  border-color: rgba(94, 242, 255, 0.5);
}

.pane-view-icon[data-view-id="table"],
.view-preview-icon[data-view-id="table"] {
  background: linear-gradient(135deg, rgba(92, 255, 196, 0.2), rgba(46, 192, 144, 0.35));
  border-color: rgba(115, 255, 210, 0.5);
}

.pane-view-icon[data-view-id="console"],
.view-preview-icon[data-view-id="console"] {
  background: linear-gradient(135deg, rgba(255, 206, 88, 0.18), rgba(255, 164, 46, 0.32));
  border-color: rgba(255, 196, 102, 0.5);
}

.pane-view-icon[data-view-id="chart"],
.view-preview-icon[data-view-id="chart"] {
  background: linear-gradient(135deg, rgba(255, 130, 178, 0.2), rgba(208, 74, 146, 0.32));
  border-color: rgba(255, 155, 196, 0.5);
}

.pane-view-icon[data-view-id="editor"],
.view-preview-icon[data-view-id="editor"] {
  background: linear-gradient(135deg, rgba(130, 177, 255, 0.2), rgba(92, 127, 255, 0.32));
  border-color: rgba(133, 182, 255, 0.5);
}

.pane-view-icon[data-view-id="scene3d"],
.view-preview-icon[data-view-id="scene3d"] {
  background: linear-gradient(135deg, rgba(166, 130, 255, 0.2), rgba(124, 82, 255, 0.35));
  border-color: rgba(186, 144, 255, 0.5);
}

.pane-action-toggle::before {
  content: "";
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
  pointer-events: none;
}

.pane-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  background: var(--context-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  min-width: 160px;
  box-shadow: var(--shadow);
  transform-origin: top right;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.16s ease, opacity 0.16s ease;
  z-index: 1200;
}

.pane-action-menu.is-open {
  transform: scale(1);
  opacity: 1;
}

.pane-action-menu button {
  width: 100%;
  border-radius: 0;
  border: none;
  padding: 6px 12px;
  font-size: 0.78rem;
  text-align: left;
  background: transparent;
  color: var(--text-muted);
}

.pane-action-menu button:hover {
  color: var(--text);
}

.pane-action-menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.pane-view-menu {
  left: 0;
  right: auto;
  transform-origin: top left;
}

.pane-view-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pane-view-option-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 0.58rem;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(79, 193, 255, 0.18);
}

.pane-view-option-label {
  flex: 1;
  text-align: left;
  font-size: 0.78rem;
}

.pane-view-option.is-active {
  color: var(--text);
  background: rgba(79, 193, 255, 0.14);
}

.pane-view-option.is-active .pane-view-option-icon {
  box-shadow: 0 0 0 1px rgba(130, 246, 255, 0.45);
}

.pane-body {
  flex: 1;
  padding: 6px;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  background: transparent;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
}

.view-preview {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: rgba(31, 37, 46, 0.78);
  border-radius: 8px;
  border: 1px solid rgba(130, 246, 255, 0.12);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: left;
  padding: 12px;
  line-height: 1.5;
  width: 100%;
  height: 100%;
}

.view-preview strong {
  color: var(--accent-strong);
}

.view-preview-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.view-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-preview-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.64rem;
  letter-spacing: 0.02em;
  background: rgba(79, 193, 255, 0.18);
  border: 1px solid rgba(130, 246, 255, 0.35);
  text-transform: uppercase;
  color: var(--text);
}

.view-preview-inner p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.context-menu {
  position: absolute;
  background: var(--context-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px 0;
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 1000;
}

.context-menu button {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
}

.context-menu button:hover {
  background: rgba(79, 193, 255, 0.15);
  color: var(--text);
}

.context-menu.hidden {
  display: none;
}

.floating-pane {
  position: absolute;
  top: 60px;
  left: 60px;
  width: 320px;
  height: 220px;
  pointer-events: auto;
  border-radius: 12px;
  overflow: visible;
  border: 1px solid rgba(130, 246, 255, 0.2);
  background: rgba(26, 32, 41, 0.95);
  box-shadow: var(--shadow);
}

.floating-pane.is-new {
  animation: float-pop 0.32s ease-out;
}

.floating-pane .pane {
  margin: 0;
  height: 100%;
}

.floating-pane.is-active {
  box-shadow: 0 0 0 2px rgba(79, 193, 255, 0.4), var(--shadow);
}

@keyframes float-pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.empty-workspace {
  display: grid;
  place-items: center;
  width: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.empty-workspace strong {
  color: var(--accent);
}

@media (max-width: 960px) {
  body {
    min-height: 100vh;
  }

  #app {
    border-radius: 0;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .layout-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace-shell {
    flex-direction: column;
    padding: 12px;
  }
}
