* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: #0f0f12;
  color: #eaeaea;
}

.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid #24242a;
  background: #131318;
}
.brand {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: block;
  height: 80px;
  width: auto;
  transform: translate(-20px, 3px);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45)) saturate(1) brightness(1);
}
.status { opacity: 0.9; margin-right: auto; }

.topbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  background: #24242a;
  opacity: 0.7;
}

.topbar-link {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #cfd3ff;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.3px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(108, 124, 255, 0.12);
  border: 1px solid rgba(108, 124, 255, 0.25);
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.topbar-link:hover {
  opacity: 1;
  background: rgba(108, 124, 255, 0.2);
  border-color: rgba(108, 124, 255, 0.4);
}

.kw-list-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  z-index: 15;
}

.kw-list-btn:hover {
  background: #242430;
}

.kw-asset-panel {
  position: absolute;
  top: 50px;
  left: 12px;
  min-width: 180px;
  max-height: 260px;
  overflow: auto;
  background: rgba(19, 19, 24, 0.6);
  border: 1px solid rgba(72, 72, 84, 0.55);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 6px;
  display: none;
  z-index: 16;
}

.kw-asset-panel.show {
  display: block;
}

.kw-selection-box {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border: 1px dashed rgba(122, 162, 255, 0.65);
  background: rgba(122, 162, 255, 0.08);
  border-radius: 6px;
  pointer-events: none;
  display: none;
  z-index: 10;
}

.kw-asset-item {
  width: 100%;
  background: transparent;
  color: #eaeaea;
  border: 0;
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.kw-asset-item:hover {
  background: #1b1b22;
}

.kw-asset-item.is-selected {
  background: #242430;
}

.kw-asset-item.is-hover {
  background: #2a2f45;
}

[data-kw-asset].kw-hovered {
  outline: 1px solid rgba(75, 132, 255, 0.65);
  outline-offset: 2px;
}

.kw-btn {
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.kw-btn:hover {
  background: #242430;
}

.kw-btn--primary {
  background: #1f2233;
  border-color: rgba(75, 132, 255, 0.5);
}

.kw-btn--primary:hover {
  background: #2a2f45;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: 1fr;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.scene-wrap {
  border: 1px solid #24242a;
  background: #0b0b0e;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  height: 100%;
  min-height: 0;
}

.scene {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.scene-svg {
  width: min(980px, 100%);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  outline: 1px solid rgba(255, 255, 255, 0.08);
  outline-offset: -1px;
}

.panel {
  border: 1px solid #24242a;
  background: #131318;
  border-radius: 12px;
  padding: 12px 12px 72px;
  height: 100%;
  max-height: none;
  overflow: auto;
}
.panel h3 { margin: 0 0 10px; font-size: 14px; opacity: 0.95; }

.kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px;
  border: 1px solid #24242a;
  border-radius: 10px;
  background: #0f0f12;
  margin-bottom: 10px;
}

.kw-group {
  margin-bottom: 12px;
}

.kw-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.kw-group-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.kw-group-title {
  font-size: 12px;
  opacity: 0.9;
}

.kw-group-toggle {
  background: transparent;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  color: #9a9aa5;
}

.kw-caret {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 6px solid #8b8b94;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(90deg);
  transition: transform 120ms ease;
}

.kw-group.is-collapsed .kw-caret {
  transform: rotate(0deg);
}

.kw-group-divider {
  height: 1px;
  background: #2a2a33;
  opacity: 0.35;
  margin: 6px 0 8px;
}

.kw-group.is-collapsed .kw-group-body {
  display: none;
}

.kw-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.7);
  display: grid;
  place-items: center;
  z-index: 50;
}

.kw-modal.is-hidden {
  display: none;
}

.kw-modal-card {
  width: min(420px, 90vw);
  background: #131318;
  border: 1px solid #2a2a33;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.kw-modal-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.kw-dropzone {
  border: 1px dashed #2a2a33;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: #b8b8c2;
  margin-bottom: 12px;
}

.kw-dropzone.is-dragover {
  border-color: #4b84ff;
  color: #d6e2ff;
  background: rgba(75, 132, 255, 0.08);
}

.kw-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.kw-modal-actions button {
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.kw-modal-actions button:hover {
  background: #242430;
}
.k { font-size: 12px; opacity: 0.7; }
.v { font-weight: 600; }

.kw-inspector-title {
  margin: 2px 0 8px;
  font-size: 12px;
  opacity: 0.8;
}

.kw-inspector-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.kw-inspector-actions button {
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  position: relative;
}

.kw-inspector-actions button:hover {
  background: #242430;
}

.kw-inspector-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.kw-inspector-actions button.has-kf::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #4b84ff;
  box-shadow: 0 0 0 1px rgba(15, 15, 18, 0.8);
}

.kw-pivot-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kw-appearance-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.kw-fill-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kw-fill-field input[type="color"] {
  padding: 0;
  height: 34px;
}

.kw-stroke-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kw-stroke-field input[type="color"] {
  padding: 0;
  height: 34px;
}

.kw-opacity-field {
  min-width: 120px;
  max-width: 160px;
}

.kw-shape-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kw-shape-field input {
  width: 100%;
}

.kw-morph-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kw-morph-field input {
  width: 100%;
}

.kw-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.85;
  margin-top: 18px;
}

.kw-layer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
}

.kw-layer-row button,
.kw-flip-row button {
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.kw-layer-row button:hover,
.kw-flip-row button:hover {
  background: #242430;
}

.kw-layer-field {
  max-width: 100px;
}

.kw-layer-field input {
  width: 100%;
}

.kw-flip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kw-settings-row {
  display: flex;
  gap: 12px;
}

.kw-settings-field {
  flex: 1;
}

.kw-settings-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.kw-preset-btn {
  font-size: 11px;
  padding: 4px 10px;
}

.kw-preset-btn.is-active {
  background: #2a2f45;
  border-color: rgba(75, 132, 255, 0.55);
}

.kw-export-checkbox {
  margin-top: 10px;
  margin-bottom: 6px;
}

.kw-help {
  position: fixed;
  left: 12px;
  bottom: 80px;
  background: rgba(19, 19, 24, 0.6);
  border: 1px solid rgba(72, 72, 84, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11px;
  min-width: 200px;
  color: #b8b8c2;
  display: grid;
  gap: 4px;
  z-index: 12;
}

.kw-help.is-hidden {
  display: none;
}

.kw-help-title {
  font-size: 11px;
  font-weight: 600;
  color: #eaeaea;
  margin-bottom: 6px;
}

.kw-help-list {
  display: grid;
  gap: 6px;
  line-height: 1.3;
  color: rgba(234, 234, 234, 0.85);
}

.kw-help-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.kw-help-key {
  font-weight: 600;
  color: rgba(234, 234, 234, 0.95);
  white-space: nowrap;
}

.kw-help-desc {
  white-space: nowrap;
  color: #999;
}

.kw-help-dots {
  height: 1px;
  background-image: radial-gradient(
    circle,
    rgba(234, 234, 234, 0.25) 1px,
    transparent 1px
  );
  background-size: 6px 1px;
  background-repeat: repeat-x;
  background-position: center;
  opacity: 0.7;
}

.kw-help-hide {
  justify-self: end;
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-top: 8px;
}

.kw-help-hide:hover {
  background: #242430;
}

.kw-help-toggle {
  position: fixed;
  left: 12px;
  bottom: 80px;
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  z-index: 12;
}

.kw-help-toggle:hover {
  background: #242430;
}

.kw-help-toggle.is-hidden {
  display: none;
}

.kw-field {
  display: grid;
  gap: 4px;
}

.kw-field-label {
  font-size: 11px;
  opacity: 0.75;
}

.kw-field input {
  background: #0f0f12;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  width: 100%;
}

.hint {
  font-size: 12px;
  line-height: 1.4;
  opacity: 0.8;
}
code {
  background: #0b0b0e;
  border: 1px solid #24242a;
  padding: 1px 6px;
  border-radius: 6px;
}


/* ===== TIMELINE ===== */

.kw-timeline {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 10px 12px;
  background: #131318;
  border: 1px solid #24242a;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.kw-time-label {
  font-size: 12px;
  opacity: 0.85;
  width: 60px;
  text-align: right;
}

.kw-timeline input[type="range"] {
  flex: 1;
}

.kw-duration-input {
  width: 90px;
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
}

.kw-size-label {
  width: 20px;
  text-align: center;
}

.kw-size-input {
  width: 70px;
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
}


/* ===== PLAYER CONTROLS ===== */

.kw-player-controls {
  position: absolute;
  right: 12px;
  bottom: 64px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.kw-player-controls .kw-hotkey-btn {
  position: relative;
}

.kw-player-controls .kw-hotkey-btn::after {
  content: attr(title);
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.5;
  letter-spacing: 0.2px;
}

.kw-player-controls .kw-hotkey-btn[title="Space"]::after {
  content: "Space";
}

.kw-player-controls button {
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.kw-player-controls button:hover {
  background: #242430;
}

.kw-player-controls button.is-active {
  background: #2a2f45;
  border-color: rgba(75, 132, 255, 0.55);
}

.kw-speed-select {
  background: #1b1b22;
  color: #eaeaea;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
}


/* ===== KEYFRAMES ===== */

.kw-keys-layer {
  position: absolute;
  left: 82px;
  right: 12px;
  bottom: 18px;
  height: 10px;
  pointer-events: none;
}

.kw-key-dot {
  position: absolute;
  top: 0;
  width: 8px;
  height: 8px;
  background: #7aa2ff;
  border-radius: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
}

.kw-key-dot:hover {
  transform: translateX(-50%) scale(1.3);
}

.kw-key-menu {
  position: fixed;
  z-index: 5;
  min-width: 160px;
  background: #131318;
  border: 1px solid #2a2a33;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.kw-key-menu button {
  width: 100%;
  background: transparent;
  color: #eaeaea;
  border: 0;
  text-align: left;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
}

.kw-key-menu button:hover {
  background: #1b1b22;
  border-radius: 6px;
}
