body {
  margin: 0;
}

.layout {
  --selection-panel-min: 260px;
  --selection-panel-max: 520px;
  display: flex;
  gap: 0;
  padding: 12px 16px;
  background: radial-gradient(circle at 20% 20%, #182040 0, #0b1021 50%, #060913 100%);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
  width: 100%;
}

.layout.selection-closed {
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.layout h1,
.layout h2,
.layout h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.layout p {
  margin: 6px 0 10px;
  color: var(--muted);
}

.layout button {
  background: var(--accent);
  border: none;
  color: #041018;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  margin: 4px 0;
  width: auto;
  min-width: 120px;
}

.layout button.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.workspace-panel {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.selection-panel-wrapper {
  flex: 0 0 auto;
  display: flex;
  min-width: var(--selection-panel-min, 260px);
  max-width: var(--selection-panel-max, 520px);
  transition: width 0.15s ease-out;
  position: relative;
  z-index: 1;
}

.selection-panel-wrapper .selection-panel {
  width: 100%;
  flex: 1 1 auto;
}

.panel-resize-handle {
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  margin: 0;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  border-radius: 6px;
  background: transparent;
}

.panel-resize-handle__bar {
  width: 2px;
  height: 36px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0;
  transition: height 0.15s ease, opacity 0.15s ease;
}

.panel-resize-handle:hover,
.panel-resize-handle.is-dragging {
  opacity: 1;
  background: rgba(91, 209, 215, 0.08);
}

.panel-resize-handle:hover .panel-resize-handle__bar,
.panel-resize-handle.is-dragging .panel-resize-handle__bar {
  opacity: 0.55;
}

.panel-resize-handle.is-dragging .panel-resize-handle__bar {
  opacity: 1;
  height: 56px;
}

.panel-resize-handle.is-dragging + .selection-panel-wrapper {
  transition: none;
}

.canvas-shell {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.canvas {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
  min-height: 0;
  scrollbar-width: none;
}

.canvas svg {
  display: block;
}

.canvas:hover {
  scrollbar-width: thin;
  scrollbar-color: rgba(91, 209, 215, 0.6) transparent;
}

.canvas::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.canvas:hover::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.canvas:hover::-webkit-scrollbar-track {
  background: transparent;
}

.canvas:hover::-webkit-scrollbar-thumb {
  background-color: rgba(91, 209, 215, 0.6);
  border-radius: 6px;
}

.pill {
  display: inline-block;
  background: rgba(91, 209, 215, 0.12);
  color: var(--accent);
  border: 1px solid rgba(91, 209, 215, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

ul {
  margin: 0;
  padding-left: 16px;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.tab {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 10px;
}

.toolbar-select {
  min-width: 180px;
}

.toolbar-select--template {
  min-width: 200px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--panel-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 0;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn:active {
  transform: translateY(1px);
}
.icon-btn svg,
.inline-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  flex-shrink: 0;
}
.icon-btn svg path,
.inline-icon path {
  stroke: currentColor;
}
.panel-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.ability-search input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}
.ability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}
.ability-card {
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 140px;
}
.ability-card button {
  width: 100%;
  margin-top: auto;
}
.ability-card h4 {
  margin: 0;
  font-size: 14px;
}
.ability-card span {
  font-size: 12px;
  color: var(--muted);
}
.ability-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ability-card ul li {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 2px 6px;
}
.panel-toggle-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.panel-toggle-btn--floating {
  align-self: stretch;
  min-width: 44px;
  margin-left: 16px;
}

.hide-panel-btn {
  width: 32px;
  height: 32px;
}

.mobile-selection-backdrop {
  display: none;
}

@media (max-width: 1200px) {
  .layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .workspace-panel {
    min-height: 0;
  }

  .selection-panel-wrapper {
    width: 100% !important;
    max-width: none;
    flex: 1 1 auto;
  }

  .panel-resize-handle {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout {
    padding: 10px 12px 70px;
  }

  .selection-panel-wrapper {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    flex: 0 0 auto;
    height: min(70vh, 520px);
    max-height: 90vh;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.7);
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 1300;
  }

  .layout.selection-open .selection-panel-wrapper {
    transform: translateY(0);
  }

  .selection-panel-wrapper .selection-panel {
    overflow-y: auto;
  }

  .mobile-selection-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.65);
    border: none;
    z-index: 1250;
    cursor: pointer;
  }

  .panel-toggle-btn--floating {
    position: fixed;
    bottom: 18px;
    right: 18px;
    margin-left: 0;
    z-index: 1251;
  }
}
