/* Windows XP "Luna" theme */
:root {
  --face: #ece9d8;
  --edge: #919b9c;
  --field: #7f9db9;
  --sel: #316ac5;
  --sel-soft: #c1d2ee;
  --xp-blue: #0054e3;
  --ui: Tahoma, "Segoe UI", Geneva, Verdana, sans-serif;
  --xp: "Trebuchet MS", Tahoma, sans-serif;
  --btn: linear-gradient(180deg, #fff, #ecebe6 86%, #d6d0c5);
  --btn-down: linear-gradient(180deg, #cdcac3, #e3e3db 8%, #e5e5de 94%, #f2f2f1);
  --btn-hover: inset -1px 1px #fff0cf, inset 1px 2px #fdd889, inset -2px 2px #fbc761, inset 2px -2px #e5a01a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 12px/1.35 var(--ui); color: #000; background: #245edb; overflow: hidden; }

/* Rolling-hill desktop */
.desktop {
  position: fixed; inset: 0 0 30px 0;
  padding: 12px;
  background:
    radial-gradient(ellipse 28% 10% at 20% 20%, rgba(255,255,255,.85), transparent 70%),
    radial-gradient(ellipse 20% 8% at 68% 12%, rgba(255,255,255,.8), transparent 70%),
    radial-gradient(ellipse 24% 9% at 88% 36%, rgba(255,255,255,.65), transparent 70%),
    radial-gradient(ellipse 140% 55% at 35% 118%, #7cc242 0, #4e9a2a 50%, #3b8a1f 55%, transparent 55.5%),
    linear-gradient(#245fdc, #5e9cf0 55%, #a9cdf6);
}

/* ---------- Window chrome ---------- */
.window {
  background: var(--face);
  border: 3px solid var(--xp-blue); border-top: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.titlebar {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; margin: 0 -3px; padding: 0 5px 0 8px;
  background: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
  border-radius: 8px 8px 0 0;
  color: #fff; user-select: none;
}
.titlebar .title { font: bold 13px var(--xp); text-shadow: 1px 1px #0f1089; letter-spacing: .2px; }
.titlebar small { font-weight: normal; opacity: .85; margin-left: 8px; font-size: 11px; }
.tb-btns { display: flex; gap: 2px; }
.tb-btns button {
  width: 21px; height: 21px; padding: 0; border: 1px solid #fff; border-radius: 3px; cursor: pointer;
  font: bold 12px/1 var(--ui); color: #fff;
  background: radial-gradient(circle at 90% 90%, #0054e9, #2263d5 55%, #4479e4 70%, #a3bbec 90%, #fff);
}
.tb-btns button.close { background: radial-gradient(circle at 90% 90%, #cc4600, #dc6527 55%, #cd7546 70%, #ffccb2 90%, #fff); }

/* ---------- Controls ---------- */
.btn {
  font: 12px var(--ui); color: #000;
  background: var(--btn); border: 1px solid #003c74; border-radius: 3px;
  padding: 3px 10px; min-height: 23px; cursor: pointer; white-space: nowrap;
}
.btn:hover { box-shadow: var(--btn-hover); }
.btn:active, .btn.active { background: var(--btn-down); box-shadow: none; }
.btn.active { border-color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel-soft); }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.btn.wide { width: 100%; margin: 6px 0; }

input[type="text"], select {
  font: 12px var(--ui); border: 1px solid var(--field); background: #fff; padding: 2px 4px; min-height: 22px; border-radius: 0;
}
input[type="checkbox"], input[type="radio"] { accent-color: #21a121; margin: 0 6px 0 0; }
input[type="color"] { width: 44px; height: 22px; padding: 1px; border: 1px solid var(--field); background: #fff; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border: 1px solid #9d9c99; border-radius: 2px; background: #f0efe9; box-shadow: inset 1px 1px #d4d2c8; }
input[type="range"]::-moz-range-track { height: 4px; border: 1px solid #9d9c99; border-radius: 2px; background: #f0efe9; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 21px; margin-top: -9px;
  border: 1px solid #1c5180; border-radius: 2px 2px 5px 5px;
  background: linear-gradient(180deg, #fff, #f0efea 50%, #dedcd2); box-shadow: inset 0 -3px #21a121;
}
input[type="range"]::-moz-range-thumb { width: 9px; height: 19px; border: 1px solid #1c5180; border-radius: 2px 2px 5px 5px; background: linear-gradient(180deg, #fff, #dedcd2); box-shadow: inset 0 -3px #21a121; }

/* ---------- App layout (landscape first) ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 6px;
  border-bottom: 1px solid #d5d2c2; box-shadow: 0 1px #fff;
}
.toolbar .btn { border-color: transparent; background: transparent; }
.toolbar .btn:hover { border-color: #ceceC3; background: var(--btn); box-shadow: none; }
.toolbar .btn:active, .toolbar .btn.active { border-color: #9d9d92; background: var(--btn-down); }
.sep { width: 1px; height: 22px; margin: 0 4px; background: #c5c2b2; box-shadow: 1px 0 #fff; }

.body { display: grid; grid-template-columns: 330px minmax(0, 1fr) 290px; gap: 8px; min-height: 0; padding: 8px; }
.panel { display: flex; flex-direction: column; min-height: 0; }

.tabs { display: flex; gap: 0 1px; padding-left: 3px; position: relative; z-index: 1; }
.tab {
  font: 11px var(--ui); padding: 3px 7px 4px; cursor: pointer; position: relative; top: 2px;
  background: linear-gradient(180deg, #fff, #fafaf9 26%, #f0f0ea 95%, #ecebe5);
  border: 1px solid var(--edge); border-bottom: 0; border-radius: 3px 3px 0 0;
}
.tab:hover { border-top: 2px solid #ffc83c; padding-top: 2px; }
.tab.active { top: 1px; padding-bottom: 6px; background: #fcfcfe; border-top: 3px solid #e68b2c; padding-top: 1px; font-weight: bold; }
.tab-body {
  flex: 1; overflow: auto; padding: 8px;
  background: #fcfcfe; border: 1px solid var(--edge); box-shadow: 1px 1px #fff inset;
}

/* Properties: XP Explorer task pane */
.panel.right { background: linear-gradient(180deg, #7ba2e7, #6375d6); border-radius: 4px; padding: 10px 10px 0; }
.panel-title {
  font: bold 12px var(--ui); color: #215dc6; padding: 6px 10px;
  background: linear-gradient(90deg, #fff, #c6d3f7); border-radius: 5px 5px 0 0;
}
.props { flex: 1; overflow: auto; padding: 10px; background: #d6dff7; border: 1px solid #fff; border-top: 0; margin-bottom: 10px; }

.center { display: grid; grid-template-rows: 1fr auto; gap: 6px; min-height: 0; min-width: 0; }
.viewport {
  position: relative; min-height: 0; overflow: hidden;
  border: 1px solid var(--edge);
  background: radial-gradient(ellipse at 50% 40%, #3b4f73, #1d2a44 75%);
}
/* Fill the viewport and letterbox, so tall/vertical media is never cropped. */
#stage { position: absolute; inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px); object-fit: contain; display: block; touch-action: none; }
.hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #ffffe1; border: 1px solid #000; border-radius: 6px; padding: 6px 12px; pointer-events: none; white-space: nowrap;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, .3);
}
.transport { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 1px solid var(--edge); background: linear-gradient(#fff, #ecebe5); }
.seek-wrap { position: relative; flex: 1; }
.seek-wrap input { width: 100%; display: block; }
.keys { position: absolute; inset: 0; pointer-events: none; }
.kmark {
  position: absolute; top: 1px; width: 9px; height: 9px; padding: 0; cursor: pointer; pointer-events: auto;
  transform: translateX(-50%) rotate(45deg); background: #f5a623; border: 1px solid #8a5a00;
}
.kmark:hover { background: #ffd36b; }
#loopWrap { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#loopLen { width: 52px; font: 12px var(--ui); border: 1px solid var(--field); padding: 1px 3px; }
.key { border: 0; background: none; padding: 0 4px 0 0; cursor: pointer; color: #6d7fb0; font-size: 12px; line-height: 1; }
.key.on { color: #e07b00; }
.key:hover { color: #000; }
.plabel { display: flex; align-items: center; }
.transport #time { min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; }

.statusbar { display: flex; gap: 0; border-top: 1px solid #d5d2c2; }
.statusbar span { padding: 3px 8px; border-left: 1px solid #c5c2b2; box-shadow: inset 1px 0 #fff; }
.statusbar #status { flex: 1; border-left: 0; box-shadow: none; }

/* ---------- Panel content ---------- */
.help { color: #444; margin: 2px 0 8px; }
.empty { padding: 18px 8px; text-align: center; color: #555; border: 1px dashed var(--edge); border-radius: 4px; margin-top: 8px; }
.cat { font: bold 12px var(--ui); color: #215dc6; margin: 12px 0 5px; padding-bottom: 3px; border-bottom: 1px solid #c6d3f7; }
.cat:first-child { margin-top: 0; }
.props .cat { border-color: #fff; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  background: #fff; border: 1px solid #d5d2c2; border-radius: 3px; padding: 4px; cursor: pointer; font: 11px var(--ui); text-align: left;
}
.tile:hover { border-color: #b0c4ec; background: #f2f6fd; }
.tile canvas { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #1d2a44; display: block; border-radius: 2px; }
.tile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tile.active { border-color: var(--sel); background: var(--sel-soft); }
.tile.active span { background: var(--sel); color: #fff; }
.tile .ref { position: absolute; top: 7px; left: 7px; width: 34px; height: 34px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.tile .x {
  position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; line-height: 16px; text-align: center; color: #fff;
  border: 1px solid #fff; border-radius: 3px; background: radial-gradient(circle at 90% 90%, #cc4600, #dc6527 55%, #ffccb2 90%, #fff);
}
.swatches { display: flex; height: 12px; border: 1px solid #d5d2c2; margin: 2px 0 4px; }
.swatches i { flex: 1; }

.fxrow { display: flex; align-items: center; padding: 3px 4px; cursor: pointer; border-radius: 2px; }
.fxrow span { flex: 1; }
.fxrow em { font-style: normal; color: #666; }
.fxrow:hover { background: #e8eefa; }
.fxrow.active { background: var(--sel); color: #fff; }
.fxrow.active em { color: #dfe8fb; }

.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
.radios { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.radios label { display: flex; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.chips .btn { padding: 2px 8px; min-height: 21px; }
.stickers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sticker { background: #fff; border: 1px solid #d5d2c2; border-radius: 3px; padding: 2px; cursor: pointer; }
.sticker:hover { border-color: #b0c4ec; background: #f2f6fd; }
.sticker:active { background: var(--sel-soft); }
.sticker canvas { width: 100%; display: block; }

.prop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: #215dc6; }
.prop-head label { display: flex; align-items: center; font-size: 12px; color: #000; }
.param { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; margin-bottom: 6px; }
.param input[type="range"] { grid-column: 1 / -1; }
.param output { font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; border: 1px solid var(--field); background: #fff; padding: 0 4px; }
.param.inline select { max-width: 150px; }
.row { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Taskbar ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 30px;
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, #1f2f86 0, #3165c4 3%, #3682e5 6%, #4490e6 10%, #3883e5 12%, #2b71e0 15%, #2663da 18%, #235bd6 20%, #2258d5 23%, #2157d6 38%, #245ddb 54%, #2562df 86%, #245fdc 89%, #2158d4 92%, #1d4ec0 95%, #1941a5 98%);
}
.start {
  height: 30px; padding: 0 22px 0 12px; border: 0; border-radius: 0 12px 12px 0; cursor: pointer;
  font: italic bold 18px var(--xp); color: #fff; text-shadow: 1px 1px 2px #1d3a10;
  background: radial-gradient(circle at 10% 50%, #6fd36a, #39a33a 40%, #2d8a2e 80%, #1f6e1f);
  box-shadow: inset 0 1px 1px #9be796, 2px 0 4px rgba(0, 0, 0, .4);
}
.start:hover { filter: brightness(1.08); }
.task {
  height: 24px; display: flex; align-items: center; padding: 0 12px; min-width: 170px;
  color: #fff; font: 11px var(--ui); border-radius: 3px;
  background: #1e52b7; box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .5), inset -1px -1px #3c7ef0;
}
.tray {
  margin-left: auto; height: 100%; display: flex; align-items: center; padding: 0 14px;
  color: #fff; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #0c59b9 1%, #139ee9 6%, #18b5f2 10%, #139beb 14%, #1290e8 19%, #0d8dea 63%, #0d9ff1 81%, #0f9eed 88%, #119be9 91%, #1392e2 94%, #137ed7 97%, #095bc9);
  border-left: 1px solid #1042af; box-shadow: inset 1px 0 #18bbff;
}

#video { position: fixed; width: 2px; height: 2px; left: -10px; top: -10px; opacity: 0; pointer-events: none; }

/* ---------- Dialogs ---------- */
.dialog { padding: 0 3px 3px; min-width: 340px; }
.dialog::backdrop { background: rgba(0, 20, 60, .3); }
.dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.dialog-body p { margin: 0; align-self: stretch; white-space: pre-wrap; max-height: 50vh; overflow: auto; }
.progress { width: 100%; height: 16px; padding: 2px; border: 1px solid #686868; border-radius: 3px; background: #fff; }
#busyBar {
  height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, transparent 0 1px, #2ec92e 1px 8px, transparent 8px 10px);
}

/* Narrow screens: stack panels under the preview */
@media (max-width: 1000px) {
  body { overflow: auto; }
  .desktop { position: static; padding: 6px; min-height: calc(100vh - 30px); }
  .app { height: auto; }
  .body { grid-template-columns: 1fr; }
  .center { order: -1; }
  .viewport { height: 56vh; }
  .tab-body, .props { max-height: 60vh; }
}
