:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #8a93a6;
  --accent: #5b8cff;
  --accent-hover: #7aa1ff;
  --check-a: #1a1d24;
  --check-b: #14171d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.file-button {
  display: inline-block;
  padding: 7px 14px;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  transition: background 0.15s ease;
}
.file-button:hover { background: var(--accent-hover); }

.file-name {
  color: var(--text-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presets-label {
  color: var(--text-dim);
  margin-right: 4px;
}

.preset-btn {
  padding: 6px 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.preset-btn:hover {
  background: #2a2f3a;
  border-color: #3a4150;
}
.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.fit-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}

#fit-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.size-readout {
  font-variant-numeric: tabular-nums;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 10px;
  min-width: 110px;
  text-align: center;
  color: var(--text);
}

.layout-note {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 560px;
  padding: 8px 14px;
  background: rgba(91, 140, 255, 0.08);
  border: 1px solid rgba(91, 140, 255, 0.25);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}
.layout-note strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow: auto;
  position: relative;
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--check-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--check-a) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
}

.resizable {
  position: relative;
  width: 414px;
  height: 600px;
  min-width: 32px;
  min-height: 32px;
  background: #ffffff10;
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: both;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#rive-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Custom right-edge drag handle for nicer side-only resizing */
.drag-handle {
  position: absolute;
  background: transparent;
  z-index: 10;
}
.drag-handle-right {
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
}
.drag-handle-right::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 36px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.drag-handle-right:hover::after,
.resizable.dragging .drag-handle-right::after {
  opacity: 0.7;
}

.drop-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 12px;
  pointer-events: none;
  opacity: 0.7;
}

.stage.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}
