@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Symbols 2";
  src: url("./fonts/NotoSansSymbols2-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Symbols Nerd Font Mono";
  src: url("./fonts/SymbolsNerdFontMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  background: #111;
  color: #ccc;
}

body {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

main {
  position: fixed;
  inset: 0;
  background: #090909;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.pane-root {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.settings-fab-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 5000;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.settings-fab {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #3a3a3a;
  background: rgba(18, 18, 18, 0.92);
  color: #d7d7d7;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  padding: 0;
  font-size: 0;
  line-height: 0;
  text-decoration: none;
  cursor: pointer;
}

.settings-fab:hover {
  background: rgba(36, 36, 36, 0.96);
}

.settings-fab-link {
  display: inline-flex;
}

.settings-fab-social {
  width: 36px;
  height: 36px;
}

.settings-fab-text {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #d7d7d7;
}

.settings-fab-social.settings-fab-text {
  font-size: 11px;
}

.settings-fab-icon {
  width: 23px;
  height: 23px;
  display: block;
  fill: currentColor;
}

.settings-fab-social .settings-fab-icon {
  width: 19px;
  height: 19px;
}

.settings-dialog {
  position: fixed;
  inset: auto 10px 74px auto;
  width: min(420px, calc(100vw - 20px));
  max-height: min(88vh, 820px);
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.settings-panel {
  width: 100%;
  max-height: min(88vh, 820px);
  border-radius: 12px;
  border: 1px solid #262626;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.56);
}

@media (max-width: 640px) {
  .settings-fab-stack {
    right: 12px;
    bottom: 12px;
  }

  .settings-dialog {
    inset: auto 8px 64px 8px;
    width: auto;
    max-height: min(85vh, 760px);
  }
}

.settings-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
}

.pane-split {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  gap: 0;
  padding: 0;
  background: #111;
}

.pane-split.is-vertical {
  flex-direction: row;
}

.pane-split.is-horizontal {
  flex-direction: column;
}

.pane {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  background: #000;
  border: 0;
  overflow: hidden;
  filter: grayscale(0.82) brightness(0.72);
}

.pane.is-active {
  filter: none;
}

.pane-divider {
  position: relative;
  z-index: 2;
  flex: 0 0 1px;
  touch-action: none;
}

.pane-divider.is-vertical {
  cursor: col-resize;
  background: transparent;
}

.pane-divider.is-horizontal {
  cursor: row-resize;
  background: transparent;
}

.pane-divider.is-vertical:hover,
.pane-divider.is-vertical.is-dragging {
  background:
    radial-gradient(
      100px 46% at 50% 50%,
      rgba(235, 235, 235, 0.92) 0%,
      rgba(200, 200, 200, 0.48) 46%,
      rgba(155, 155, 155, 0.12) 68%,
      rgba(120, 120, 120, 0) 100%
    ),
    rgba(185, 185, 185, 0.24);
}

.pane-divider.is-horizontal:hover,
.pane-divider.is-horizontal.is-dragging {
  background:
    radial-gradient(
      46% 100px at 50% 50%,
      rgba(235, 235, 235, 0.92) 0%,
      rgba(200, 200, 200, 0.48) 46%,
      rgba(155, 155, 155, 0.12) 68%,
      rgba(120, 120, 120, 0) 100%
    ),
    rgba(185, 185, 185, 0.24);
}

body.is-resizing-split {
  user-select: none;
}

.pane-canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.pane-ime-input {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.pane-term-debug {
  display: none;
}

.pane-context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 200px;
  padding: 6px;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  background: #161616;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.pane-context-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d6d6d6;
  text-align: left;
  cursor: pointer;
}

.pane-context-menu-item:hover {
  background: #252525;
}

.pane-context-menu-item:disabled {
  opacity: 0.4;
  cursor: default;
}

.pane-context-menu-item.is-danger {
  color: #f1a1a1;
}

.pane-context-menu-label {
  font-size: 12px;
}

.pane-context-menu-shortcut {
  font-size: 10px;
  color: #868686;
}

.pane-context-menu-separator {
  height: 1px;
  margin: 6px 4px;
  background: #2a2a2a;
}

/* Panel */
.panel {
  display: flex;
  flex-direction: column;
  background: #161616;
  overflow-y: auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 9px;
  background: #1a1a1a;
  border-bottom: 1px solid #272727;
  position: sticky;
  top: 0;
  z-index: 1;
}

header h1 {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.status-bar {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: #666;
  min-width: 0;
  flex: 1 1 auto;
}

.status-bar span:first-child {
  color: #4a9eff;
}

/* Sections */
.section {
  padding: 10px 12px;
  border-bottom: 1px solid #222;
}

.panel > .section:last-child {
  border-bottom: 0;
}

.section-title {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.row:last-child {
  margin-bottom: 0;
}

.hint {
  font-size: 10px;
  color: #555;
  margin-top: 4px;
}

.btn-row,
.field-row {
  display: flex;
  gap: 6px;
}

.field-row {
  margin-top: 6px;
}

.field-row label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.field-row label > span {
  color: #777;
}

.file-input {
  position: relative;
  overflow: hidden;
}

.file-input input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-input span {
  display: inline-block;
  padding: 5px 8px;
  border: 1px solid #333;
  border-radius: 3px;
  background: #1e1e1e;
  color: #ccc;
}

.pty-status {
  margin-top: 6px;
  color: #888;
  font-size: 10px;
}

.atlas-row {
  display: flex;
  gap: 6px;
}

.atlas-info {
  margin-top: 6px;
  color: #888;
  font-size: 10px;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Controls */
button, select, input[type="text"], input[type="number"] {
  font-family: inherit;
  font-size: 11px;
  padding: 5px 8px;
  border: 1px solid #333;
  border-radius: 3px;
  background: #1e1e1e;
  color: #ccc;
  outline: none;
}

button {
  cursor: pointer;
}

button:hover {
  background: #252525;
}

button:active {
  background: #2a2a2a;
}

select {
  flex: 1;
  min-width: 0;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
}

input[type="number"] {
  width: 50px;
}

input[type="file"] {
  font-size: 10px;
  color: #666;
}

input:focus, select:focus {
  border-color: #4a9eff;
}

/* Details/collapsible */
details.section {
  padding: 0;
}

details.section > summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

details.section > summary::before {
  content: "▸";
  font-size: 9px;
}

details.section[open] > summary::before {
  content: "▾";
}

details.section > summary::-webkit-details-marker {
  display: none;
}

details.section > *:not(summary) {
  padding: 0 12px 10px;
}

details.section > summary span {
  color: #444;
  font-weight: normal;
  text-transform: none;
}

/* Debug grid */
.debug-grid {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 2px 8px;
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
}

.debug-grid > span:nth-child(odd) {
  color: #555;
}

.debug-grid > span:nth-child(even) {
  color: #888;
}

/* Atlas */
#atlasCanvas {
  width: 100%;
  margin-top: 8px;
  border: 1px solid #333;
  image-rendering: pixelated;
}

/* Log */
#logDump {
  width: 100%;
  height: 100px;
  margin-top: 6px;
  padding: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  background: #111;
  color: #777;
  border: 1px solid #222;
  border-radius: 3px;
  resize: none;
  outline: none;
}
