:root {
  color: #17201c;
  background: #f4f6f5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-strong: #eef3f0;
  --ink: #17201c;
  --muted: #66736d;
  --faint: #8f9c96;
  --line: #d9e0dc;
  --line-strong: #c4cec8;
  --accent: #167d68;
  --accent-ink: #ffffff;
  --coral: #d05c34;
  --gold: #a97617;
  --violet: #6657a0;
  --shadow: 0 12px 30px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 246, 245, 0.84)),
    var(--bg);
}

.login-page {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
  padding: 42px 20px;
  background:
    linear-gradient(rgba(23, 32, 28, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 28, 0.035) 1px, transparent 1px),
    #eef1ef;
  background-size: 40px 40px;
}

.login-shell {
  display: grid;
  width: min(520px, 100%);
  gap: 18px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--coral));
  box-shadow: 0 12px 24px rgba(22, 125, 104, 0.18);
  font-size: 20px;
  font-weight: 800;
}

.login-brand h1 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 28px;
  letter-spacing: 0;
}

.login-brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.login-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--accent);
}

.login-card-head strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 20px;
}

.login-input {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.login-input svg {
  justify-self: center;
  color: var(--faint);
}

.login-input input {
  border: 0;
  padding-left: 0;
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 38px;
  gap: 7px;
  margin-top: 4px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 13px;
  font-weight: 750;
}

.login-submit:hover {
  background: #126d5b;
}

.login-submit:disabled {
  color: var(--faint);
  border-color: var(--line);
  background: var(--panel-strong);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto auto auto minmax(230px, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--coral));
  box-shadow: 0 10px 20px rgba(22, 125, 104, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 22px;
  letter-spacing: 0;
}

.brand span,
.stage-topbar span,
.layer-main span,
.asset-desc {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 6px;
}

.toolbar-group--right {
  justify-content: flex-end;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
}

.icon-button {
  width: 34px;
}

.text-button {
  min-width: 58px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
  background: var(--panel-strong);
  border-color: var(--line);
}

.text-button--solid {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.icon-button:hover,
.text-button:hover,
.icon-button.is-active {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.text-button--solid:hover {
  background: #126d5b;
}

.text-button:disabled,
.text-button--solid:disabled {
  color: var(--faint);
  border-color: var(--line);
  background: rgba(23, 32, 28, 0.04);
}

.icon-button--solid {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.icon-button--solid:hover {
  background: #126d5b;
}

.icon-button--danger {
  color: var(--coral);
}

.icon-button:disabled {
  color: var(--faint);
  background: transparent;
}

.zoom-label {
  min-width: 46px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(560px, 1fr) 348px;
  min-height: 0;
  flex: 1;
}

.left-panel,
.right-panel {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.right-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.center-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 224px;
  min-width: 0;
  min-height: 0;
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--muted);
}

.section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.adminapi-panel {
  padding-bottom: 12px;
}

.adminapi-compact-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-bottom: 9px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.adminapi-compact-status .login-status {
  min-width: 0;
  margin: 0;
}

.adminapi-compact-status .login-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adminapi-compact-status button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: 28px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent);
  background: rgba(22, 125, 104, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.adminapi-compact-status button:hover {
  border-color: rgba(22, 125, 104, 0.36);
  background: rgba(22, 125, 104, 0.12);
}

.compact-field {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.compact-field input,
.search-input input {
  width: 100%;
  min-width: 0;
  height: 31px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.compact-field input {
  padding: 0 8px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin: 9px 0 8px;
}

.search-input {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.search-input svg {
  justify-self: center;
  color: var(--faint);
}

.search-input input {
  border: 0;
  padding: 0 8px 0 0;
}

.adminapi-hint,
.login-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
}

.admin-login-box {
  margin: 9px 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.admin-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  gap: 6px;
  margin-bottom: 8px;
  border: 1px solid rgba(22, 125, 104, 0.28);
  border-radius: 7px;
  color: var(--accent);
  background: rgba(22, 125, 104, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.admin-action-button:hover {
  border-color: rgba(22, 125, 104, 0.48);
  background: rgba(22, 125, 104, 0.12);
}

.admin-action-button:disabled {
  color: var(--faint);
  border-color: var(--line);
  background: var(--panel-strong);
}

.store-result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 182px;
  overflow: auto;
}

.store-result {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

.store-result:hover,
.store-result.is-selected {
  border-color: rgba(22, 125, 104, 0.36);
  background: rgba(22, 125, 104, 0.08);
}

.store-result img,
.store-fallback {
  width: 36px;
  height: 36px;
  border-radius: 7px;
}

.store-result img {
  object-fit: cover;
}

.store-fallback {
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(22, 125, 104, 0.1);
}

.store-result strong,
.store-result small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-result strong {
  font-size: 12px;
  line-height: 17px;
}

.store-result small {
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
}

.asset-tile {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-rows: 18px 17px;
  align-items: center;
  gap: 1px 8px;
  min-height: 72px;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
}

.asset-tile:hover {
  border-color: rgba(22, 125, 104, 0.44);
  box-shadow: 0 8px 18px rgba(22, 125, 104, 0.09);
}

.asset-icon {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--accent);
  background: rgba(22, 125, 104, 0.1);
}

.asset-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-tree {
  padding-bottom: 18px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.layer-row:hover,
.layer-row.is-selected {
  border-color: rgba(22, 125, 104, 0.28);
  background: rgba(22, 125, 104, 0.08);
}

.layer-grip {
  color: var(--faint);
}

.layer-main {
  min-width: 0;
}

.layer-main strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-actions {
  display: flex;
  gap: 1px;
}

.layer-actions .icon-button {
  width: 26px;
  height: 26px;
}

.stage-shell {
  position: relative;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  min-height: 0;
  background:
    linear-gradient(rgba(23, 32, 28, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 28, 0.035) 1px, transparent 1px),
    #eef1ef;
  background-size: 36px 36px;
}

.stage-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}

.stage-topbar-title {
  min-width: 0;
}

.surface-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.surface-tabs button {
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
}

.surface-tabs button.is-active {
  color: var(--accent);
  border-color: rgba(22, 125, 104, 0.24);
  background: #fff;
  box-shadow: 0 6px 12px rgba(23, 32, 28, 0.06);
}

.stage-topbar strong {
  display: block;
  overflow: hidden;
  max-width: 520px;
  font-size: 14px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-topbar-title span {
  overflow: hidden;
  max-width: 560px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-chip {
  max-width: 230px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.stage-scroll {
  min-height: 0;
  overflow: auto;
  padding: 34px;
}

.device-frame {
  position: relative;
  margin: 0 auto;
}

.device-frame.has-frame {
  border-radius: 46px;
  box-shadow:
    0 0 0 12px #1c201f,
    0 0 0 13px rgba(255, 255, 255, 0.72),
    0 18px 52px rgba(23, 32, 28, 0.26),
    var(--shadow);
}

.stage-canvas {
  position: relative;
  overflow: hidden;
  transform-origin: top left;
  border-radius: 22px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.stage-canvas--preview {
  border-radius: 38px;
}

.stage-canvas--panorama {
  border-radius: 8px;
}

.stage-canvas.has-grid::after {
  position: absolute;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
  mix-blend-mode: screen;
}

.stage-canvas.is-preview .safe-area,
.stage-canvas.is-preview.has-grid::after {
  display: none;
}

.safe-area {
  position: absolute;
  z-index: 998;
  border: 1px dashed rgba(255, 255, 255, 0.46);
  pointer-events: none;
}

.device-notch,
.device-home-indicator {
  position: absolute;
  left: 50%;
  z-index: 1200;
  pointer-events: none;
  transform: translateX(-50%);
}

.device-notch {
  top: 0;
  width: 210px;
  height: 30px;
  border-radius: 0 0 18px 18px;
  background: #070908;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.device-home-indicator {
  bottom: 8px;
  width: 134px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  mix-blend-mode: screen;
}

.stage-node {
  position: absolute;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.34);
  user-select: none;
  transform-origin: center;
}

.stage-node:not(.is-locked) {
  cursor: move;
}

.stage-node.is-preview {
  cursor: pointer;
}

.stage-node.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stage-node.is-locked {
  cursor: default;
}

.stage-node--background {
  border-color: transparent;
}

.stage-node.has-raster-visual {
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
}

.stage-node.has-raster-visual.is-selected {
  border: 0;
  box-shadow: none;
  outline: 0;
}

.stage-node--hotspot {
  border-width: 2px;
  border-style: dashed;
  background: rgba(208, 92, 52, 0.18);
}

.stage-node--npc {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.05);
}

.node-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.node-image--animation {
  object-fit: contain;
}

.sprite-frame-clip {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.sprite-frame-clip-inner,
.sprite-frame-preview {
  background-repeat: no-repeat;
  transform-origin: top left;
}

.shape-visual,
.hotspot-visual {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 8px;
  color: #fff;
  text-align: center;
}

.shape-visual span,
.hotspot-visual span {
  overflow: hidden;
  max-width: 100%;
  font-size: 12px;
  font-weight: 750;
  line-height: 16px;
  text-overflow: ellipsis;
}

.hotspot-visual {
  background: rgba(208, 92, 52, 0.24);
}

.npc-figure {
  display: grid;
  justify-items: center;
  width: 100%;
  height: 100%;
  padding: 6px;
}

.npc-figure--breath {
  animation: npc-breath 2.2s ease-in-out infinite;
}

.npc-figure--wave .npc-body::after {
  transform: rotate(-26deg);
}

.npc-head {
  width: 36%;
  aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: #f2c8a7;
}

.npc-body {
  position: relative;
  display: grid;
  place-items: center;
  width: 58%;
  height: 50%;
  border-radius: 8px 8px 14px 14px;
  color: #fff;
  background: var(--accent);
}

.npc-body::before,
.npc-body::after {
  position: absolute;
  top: 12%;
  width: 12px;
  height: 48%;
  border-radius: 12px;
  background: #f2c8a7;
  content: "";
}

.npc-body::before {
  left: -11px;
  transform: rotate(14deg);
}

.npc-body::after {
  right: -11px;
  transform: rotate(-14deg);
}

.npc-body span {
  max-width: 100%;
  overflow: hidden;
  padding: 0 5px;
  font-size: 11px;
  line-height: 14px;
  text-overflow: ellipsis;
}

.npc-figure small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
}

.resize-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  background: #fff;
  cursor: nwse-resize;
  box-shadow: var(--shadow);
}

.preview-bubble {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  max-width: min(520px, 70%);
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.preview-bubble span {
  overflow: hidden;
  font-size: 13px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.right-panel .panel-section {
  border-bottom: 0;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.field input,
.field textarea,
.field select,
.path-row input,
.animation-toolbar select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.field input,
.field select,
.path-row input,
.animation-toolbar select {
  height: 32px;
  padding: 0 9px;
}

.field textarea {
  resize: vertical;
  min-height: 66px;
  padding: 8px 9px;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.path-row input:focus,
.animation-toolbar select:focus {
  border-color: rgba(22, 125, 104, 0.72);
  box-shadow: 0 0 0 3px rgba(22, 125, 104, 0.12);
}

.field input[type="color"] {
  padding: 3px;
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.scale-control {
  display: grid;
  gap: 8px;
  margin: 4px 0 10px;
}

.scale-lock-row {
  margin-bottom: 2px;
}

.scale-axis-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: center;
  gap: 10px;
}

.scale-axis-row input[type="range"] {
  min-width: 0;
}

.scale-axis-row input[type="number"] {
  text-align: right;
}

.two-col,
.four-col {
  display: grid;
  gap: 8px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink);
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.sub-heading {
  margin: 18px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  line-height: 18px;
  letter-spacing: 0;
}

.mini-heading {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
}

.mini-heading button,
.path-row button {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-strong);
  font-size: 12px;
}

.path-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) minmax(0, 1fr) 48px;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.upload-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  gap: 6px;
}

.upload-input.has-resource-picker {
  grid-template-columns: minmax(0, 1fr) 34px 34px 34px;
}

.upload-input-preview {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
}

.upload-input-preview img {
  display: block;
  width: 72px;
  height: 52px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.upload-input-preview a {
  overflow: hidden;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.resource-url-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
}

.upload-input button,
.resource-url-input button,
.animation-toolbar button,
.animation-card-head button {
  display: inline-grid;
  place-items: center;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-strong);
}

.upload-input button:hover,
.resource-url-input button:hover,
.animation-toolbar button:hover,
.animation-card-head button:hover {
  border-color: var(--line-strong);
}

.animation-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.animation-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  font-size: 12px;
}

.animation-card {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.animation-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.animation-card-head strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.animation-card-head button {
  width: 30px;
  height: 30px;
  color: var(--coral);
}

.animation-preview {
  position: relative;
  display: grid;
  place-items: center;
  height: 112px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background:
    linear-gradient(45deg, rgba(23, 32, 28, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 32, 28, 0.06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 32, 28, 0.06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 32, 28, 0.06) 75%),
    #fff;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.animation-preview img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sprite-frame-preview {
  display: block;
}

.animation-preview span {
  font-size: 12px;
}

.animation-preview small {
  position: absolute;
  right: 8px;
  bottom: 7px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  padding: 3px 6px;
  border-radius: 999px;
  color: #fff;
  background: rgba(23, 32, 28, 0.62);
  font-size: 10px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-list-input {
  display: grid;
  gap: 8px;
}

.frame-list-tools {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.frame-list-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(22, 125, 104, 0.2);
  color: var(--accent-ink);
  background: rgba(22, 125, 104, 0.08);
  font-size: 12px;
}

.frame-list-tools span {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 32, 28, 0.42);
  backdrop-filter: blur(8px);
}

.editor-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(23, 32, 28, 0.22);
}

.image-editor-modal {
  width: min(1480px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 32px));
}

.frame-editor-modal {
  width: min(1060px, calc(100vw - 48px));
}

.editor-modal-head,
.editor-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.editor-modal-foot {
  position: relative;
  z-index: 2;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.editor-modal-head strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 19px;
}

.editor-modal-head span,
.modal-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.editor-modal button,
.inline-tools button,
.image-editor-action-strip button,
.image-editor-presets button,
.tool-block button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 700;
}

.editor-modal button:hover,
.inline-tools button:hover,
.image-editor-action-strip button:hover,
.image-editor-presets button:hover,
.tool-block button:hover {
  border-color: var(--line-strong);
}

.editor-modal button:disabled {
  color: var(--faint);
  background: rgba(23, 32, 28, 0.04);
}

.editor-modal button.is-primary {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.editor-modal button.is-danger {
  color: var(--coral);
}

.editor-modal-head > button {
  width: 32px;
  min-height: 32px;
  padding: 0;
}

.editor-modal-foot button {
  min-width: 86px;
  padding: 0 12px;
}

.image-editor-layout,
.frame-editor-layout {
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.image-editor-layout {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  padding: 14px;
  overflow: hidden;
}

.image-editor-controls {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.image-editor-controls::-webkit-scrollbar,
.image-editor-layout::-webkit-scrollbar,
.crop-preview-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.image-editor-controls::-webkit-scrollbar-thumb,
.image-editor-layout::-webkit-scrollbar-thumb,
.crop-preview-wrap::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(23, 32, 28, 0.28);
  background-clip: content-box;
}

.image-editor-controls::-webkit-scrollbar-track,
.image-editor-layout::-webkit-scrollbar-track,
.crop-preview-wrap::-webkit-scrollbar-track {
  background: rgba(23, 32, 28, 0.05);
}

.inline-tools,
.image-editor-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.image-editor-presets {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.image-editor-presets button.is-active {
  color: var(--accent);
  border-color: rgba(22, 125, 104, 0.28);
  background: rgba(22, 125, 104, 0.08);
}

.image-editor-controls input,
.image-editor-controls select,
.frame-editor-tools input,
.frame-rect-editor textarea,
.frame-editor-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.image-editor-controls input,
.image-editor-controls select,
.frame-editor-tools input {
  height: 32px;
  padding: 0 9px;
}

.image-editor-controls input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.image-editor-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 700;
}

.image-editor-toggle.is-active {
  color: var(--accent);
  border-color: rgba(22, 125, 104, 0.28);
  background: rgba(22, 125, 104, 0.08);
}

.image-editor-toggle.is-disabled {
  color: var(--faint);
  background: rgba(23, 32, 28, 0.04);
}

.image-editor-toggle input {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

.range-stack {
  display: grid;
  gap: 8px;
}

.image-editor-quick-actions {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.image-editor-quick-actions button {
  min-width: 0;
}

.image-editor-quick-actions span {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-editor-action-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(22, 125, 104, 0.22);
  border-radius: 8px;
  background: rgba(22, 125, 104, 0.06);
}

.image-editor-action-strip button {
  min-width: 0;
  min-height: 36px;
}

.image-editor-action-strip button.is-primary {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.image-editor-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 12px;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.image-editor-preview > .empty-media {
  grid-column: 1 / -1;
}

.image-editor-source,
.crop-preview-wrap,
.empty-media {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(23, 32, 28, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 32, 28, 0.06) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 32, 28, 0.06) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 32, 28, 0.06) 75%),
    #fff;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.image-editor-source {
  position: relative;
  min-height: 0;
  touch-action: none;
  user-select: none;
}

.image-editor-source img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.crop-box {
  position: absolute;
  z-index: 2;
  min-width: 12px;
  min-height: 12px;
  border: 2px solid rgba(22, 125, 104, 0.95);
  border-radius: 4px;
  background:
    linear-gradient(rgba(22, 125, 104, 0.13), rgba(22, 125, 104, 0.13)),
    linear-gradient(90deg, transparent 33.333%, rgba(255, 255, 255, 0.82) 33.333%, rgba(255, 255, 255, 0.82) 34%, transparent 34%, transparent 66.666%, rgba(255, 255, 255, 0.82) 66.666%, rgba(255, 255, 255, 0.82) 67.333%, transparent 67.333%),
    linear-gradient(0deg, transparent 33.333%, rgba(255, 255, 255, 0.82) 33.333%, rgba(255, 255, 255, 0.82) 34%, transparent 34%, transparent 66.666%, rgba(255, 255, 255, 0.82) 66.666%, rgba(255, 255, 255, 0.82) 67.333%, transparent 67.333%);
  box-shadow:
    0 0 0 9999px rgba(23, 32, 28, 0.3),
    0 10px 22px rgba(23, 32, 28, 0.18);
  cursor: move;
  outline: none;
  touch-action: none;
}

.crop-box:focus-visible {
  box-shadow:
    0 0 0 9999px rgba(23, 32, 28, 0.3),
    0 0 0 4px rgba(22, 125, 104, 0.22),
    0 10px 22px rgba(23, 32, 28, 0.18);
}

.crop-box-move-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  color: rgba(22, 125, 104, 0.92);
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.86));
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.editor-modal .crop-handle {
  position: absolute;
  z-index: 3;
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(23, 32, 28, 0.24);
}

.crop-handle--nw {
  top: -8px;
  left: -8px;
  cursor: nwse-resize;
}

.crop-handle--n {
  top: -8px;
  left: 50%;
  cursor: ns-resize;
  transform: translateX(-50%);
}

.crop-handle--ne {
  top: -8px;
  right: -8px;
  cursor: nesw-resize;
}

.crop-handle--e {
  top: 50%;
  right: -8px;
  cursor: ew-resize;
  transform: translateY(-50%);
}

.crop-handle--se {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.crop-handle--s {
  bottom: -8px;
  left: 50%;
  cursor: ns-resize;
  transform: translateX(-50%);
}

.crop-handle--sw {
  bottom: -8px;
  left: -8px;
  cursor: nesw-resize;
}

.crop-handle--w {
  top: 50%;
  left: -8px;
  cursor: ew-resize;
  transform: translateY(-50%);
}

.crop-preview {
  max-width: 100%;
  max-height: 220px;
  border: 1px solid rgba(22, 125, 104, 0.42);
  border-radius: 7px;
  background-repeat: no-repeat;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.74);
}

.crop-preview-wrap {
  align-content: start;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  overflow: auto;
}

.crop-preview-wrap small {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.empty-media {
  min-height: 280px;
  color: var(--muted);
  gap: 8px;
  font-size: 12px;
}

.modal-error {
  padding: 8px 10px;
  border: 1px solid rgba(208, 92, 52, 0.28);
  border-radius: 7px;
  color: #9c321b;
  background: rgba(208, 92, 52, 0.08);
  font-size: 12px;
  line-height: 16px;
}

.frame-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
  padding: 14px;
}

.frame-editor-main {
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr);
  min-width: 0;
  gap: 10px;
}

.frame-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.frame-editor-toolbar button {
  padding: 0 10px;
}

.frame-editor-textarea,
.frame-rect-editor textarea {
  resize: vertical;
  min-height: 240px;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 18px;
}

.frame-editor-tools {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.tool-block {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.tool-block-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.tool-block-head strong,
.frame-rect-editor span {
  color: var(--ink);
  font-size: 12px;
  line-height: 17px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.frame-rect-editor {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
  color: var(--muted);
}

.frame-rect-editor textarea {
  min-height: 110px;
  max-height: 190px;
}

.resource-manager-modal {
  width: min(1180px, calc(100vw - 48px));
}

.resource-manager-body {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.resource-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.resource-tabs button,
.resource-actions button,
.resource-detail-actions button,
.resource-detail-actions a,
.resource-detail-footer button,
.resource-card-actions button,
.resource-edit-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.resource-tabs button {
  color: var(--muted);
}

.resource-tabs button.is-active {
  color: var(--accent);
  border-color: rgba(22, 125, 104, 0.26);
  background: #fff;
}

.resource-tabs button:disabled {
  color: var(--faint);
  background: transparent;
}

.resource-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto auto auto;
  gap: 8px;
  align-items: center;
}

.resource-search {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.resource-search svg {
  justify-self: center;
  color: var(--faint);
}

.resource-search input {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 0;
  color: var(--ink);
  outline: none;
}

.resource-upload-type {
  display: grid;
  grid-template-columns: auto minmax(84px, 112px);
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.resource-upload-type select {
  min-width: 0;
  height: 28px;
  border: 0;
  color: var(--ink);
  background: transparent;
  outline: none;
  font: inherit;
}

.resource-edit-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(22, 125, 104, 0.2);
  border-radius: 8px;
  background: rgba(22, 125, 104, 0.06);
}

.resource-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.resource-edit-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.resource-edit-grid label.is-wide {
  grid-column: 1 / -1;
}

.resource-edit-grid input,
.resource-edit-grid select,
.resource-edit-grid textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.resource-edit-grid input,
.resource-edit-grid select {
  height: 32px;
  padding: 0 9px;
}

.resource-edit-grid textarea {
  resize: vertical;
  min-height: 86px;
  padding: 8px 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 18px;
}

.resource-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.resource-card-actions button.is-primary,
.resource-edit-actions button.is-primary {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.resource-card-actions button.is-danger {
  color: var(--coral);
}

.resource-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 12px;
  min-height: 360px;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  min-height: 0;
}

.resource-card {
  display: grid;
  grid-template-rows: 142px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 302px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.resource-card:hover,
.resource-card.is-selected {
  border-color: rgba(22, 125, 104, 0.36);
  box-shadow: 0 12px 30px rgba(30, 51, 45, 0.08);
}

.resource-card.is-selected {
  outline: 2px solid rgba(22, 125, 104, 0.16);
}

.resource-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--accent);
  background:
    linear-gradient(45deg, rgba(23, 32, 28, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 32, 28, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 32, 28, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 32, 28, 0.05) 75%),
    #fbfcfb;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.resource-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.resource-card-main {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 10px;
}

.resource-card-main strong,
.resource-card-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-card-main strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 18px;
}

.resource-card-main span {
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}

.resource-meta-line,
.resource-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.resource-meta-line small,
.resource-tags small {
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 10px;
  line-height: 15px;
}

.resource-meta-line small.is-referenced {
  color: var(--accent);
  background: rgba(22, 125, 104, 0.09);
}

.resource-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 10px 10px;
}

.resource-card-actions button {
  flex: 1 1 70px;
  min-width: 0;
}

.resource-detail-panel {
  position: sticky;
  top: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.resource-detail-panel.is-empty {
  place-items: center;
  align-content: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.resource-detail-panel.is-empty strong {
  color: var(--ink);
  font-size: 13px;
}

.resource-detail-panel.is-empty span {
  max-width: 220px;
  font-size: 12px;
  line-height: 18px;
}

.resource-detail-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  max-height: 320px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  background:
    linear-gradient(45deg, rgba(23, 32, 28, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 32, 28, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 32, 28, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 32, 28, 0.05) 75%),
    #fbfcfb;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.resource-detail-preview img {
  display: block;
  max-width: 100%;
  max-height: 318px;
  object-fit: contain;
}

.resource-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.resource-detail-head strong,
.resource-detail-head span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-detail-head strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}

.resource-detail-head span {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.resource-detail-actions,
.resource-detail-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.resource-detail-actions button,
.resource-detail-actions a,
.resource-detail-footer button {
  flex: 1 1 108px;
  min-width: 0;
}

.resource-detail-head button.is-primary,
.resource-detail-footer button.is-primary {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.resource-detail-footer button.is-danger {
  color: var(--coral);
}

.resource-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.resource-detail-meta div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
}

.resource-detail-meta dt,
.resource-detail-meta dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-detail-meta dt {
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
}

.resource-detail-meta dd {
  margin-top: 2px;
  color: var(--ink);
  font-size: 12px;
  line-height: 18px;
  font-weight: 700;
}

.resource-detail-meta dd.is-referenced {
  color: var(--accent);
}

.resource-detail-url {
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fbfcfb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.resource-reference-list small {
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(22, 125, 104, 0.09);
  font-size: 10px;
  line-height: 15px;
}

.resource-metadata-preview {
  max-height: 136px;
  margin: 0;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #22302b;
  background: #fbfcfb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 16px;
}

.resource-result-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.resource-result-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 220px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfb;
  font-size: 12px;
}

.spin {
  animation: spin 0.8s linear infinite;
}

.bottom-panel {
  display: grid;
  grid-template-columns: minmax(260px, 38%) minmax(0, 1fr);
  min-height: 0;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.validation-list,
.json-preview {
  min-width: 0;
  min-height: 0;
  padding: 12px 14px;
}

.validation-list {
  border-right: 1px solid var(--line);
}

.issue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 156px;
  overflow: auto;
}

.empty-state,
.issue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 16px;
}

.empty-state {
  color: var(--accent);
  background: rgba(22, 125, 104, 0.08);
}

.issue-row {
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  background: #fff;
}

.issue-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issue-row--error {
  color: #9c321b;
  border-color: rgba(208, 92, 52, 0.3);
  background: rgba(208, 92, 52, 0.08);
}

.issue-row--warning {
  color: #80580f;
  border-color: rgba(169, 118, 23, 0.28);
  background: rgba(169, 118, 23, 0.08);
}

.json-preview pre {
  height: 156px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #22302b;
  background: #f9fbfa;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 16px;
}

.json-preview .section-heading {
  gap: 10px;
}

.json-preview .section-heading h2 {
  margin-bottom: 2px;
}

.json-preview .section-heading small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.preview-actions button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent);
  background: #fff;
}

.preview-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.preview-tabs button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.preview-tabs button.is-active {
  color: var(--accent);
  border-color: rgba(22, 125, 104, 0.25);
  background: rgba(22, 125, 104, 0.08);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: 360px;
  padding: 10px 13px;
  border: 1px solid rgba(22, 125, 104, 0.2);
  border-radius: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.task-toast {
  position: fixed;
  right: 18px;
  bottom: 64px;
  z-index: 51;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 11px 13px;
  border: 1px solid rgba(22, 125, 104, 0.18);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.task-toast strong,
.task-toast small {
  display: block;
}

.task-toast strong {
  font-size: 13px;
  line-height: 18px;
}

.task-toast small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.task-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(22, 125, 104, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

@keyframes npc-breath {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 270px minmax(520px, 1fr) 320px;
  }

  .toolbar {
    grid-template-columns: minmax(220px, 1fr) auto auto auto auto;
  }

  .resource-manager-modal {
    width: min(1040px, calc(100vw - 32px));
  }

  .resource-workspace {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .resource-actions {
    grid-template-columns: minmax(220px, 1fr) auto auto auto auto;
  }

  .resource-upload-type {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 980px) {
  .resource-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .resource-actions {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .resource-actions button:last-child {
    grid-column: span 3;
  }

  .resource-workspace {
    grid-template-columns: 1fr;
  }

  .resource-detail-panel {
    position: static;
    max-height: none;
  }

  .resource-grid {
    grid-template-columns: 1fr;
  }

  .image-editor-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: auto;
  }

  .image-editor-controls {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .image-editor-preview {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 44vh) minmax(140px, auto);
    height: auto;
    overflow: visible;
  }

  .image-editor-source {
    min-height: 320px;
  }

  .image-editor-source img {
    max-height: 320px;
  }
}
