@font-face {
  font-family: "Comic Neue";
  src: url("../fonts/comic-neue/ComicNeue-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Comic Neue";
  src: url("../fonts/comic-neue/ComicNeue-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Comic Neue";
  src: url("../fonts/comic-neue/ComicNeue-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Bangers";
  src: url("../fonts/bangers/Bangers-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lilita One";
  src: url("../fonts/lilita-one/LilitaOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #12141a;
  --rail: #191c24;
  --rail-2: #21262f;
  --line: #313744;
  --text: #f2efe8;
  --muted: #a39e93;
  --accent: #e2a23a;
  --accent-ink: #241a09;
  --blue: #8eb6ff;
  --danger: #e36b5d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app {
  height: 100%;
  min-width: 980px;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto 36px;
}

#top, #tools, #props, #status {
  background: var(--rail);
}

#top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 22px;
  height: 28px;
  border-radius: 3px;
  background:
    linear-gradient(#171717, #171717) 50% 0 / 2px 100% no-repeat,
    linear-gradient(#171717, #171717) 0 46% / 100% 2px no-repeat,
    #fffef8;
  box-shadow: 0 0 0 2px var(--accent);
}
.brand strong { display: block; font-size: 16px; letter-spacing: 0.01em; }
.brand em { font-style: normal; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#shortcuts-open { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.key-ico { display: block; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

button, .file-btn {
  background: var(--rail-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  line-height: 1.2;
}
button:hover, .tool:hover { border-color: #4a5366; }
button:focus-visible, .tool:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
button.danger { color: #ffd0cb; border-color: #6a3a36; }

#workspace {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 300px;
  min-height: 0;
}
#tools, #props {
  overflow: auto;
  padding: 14px;
  border-right: 1px solid var(--line);
}
#props { border-right: 0; border-left: 1px solid var(--line); }
h2 {
  margin: 16px 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
#tools h2:first-child, #props h2:first-child { margin-top: 0; }

.tool {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  margin-bottom: 6px;
  background: transparent;
}
.tool .ico { width: 1.4rem; text-align: center; color: var(--accent); font-weight: 700; }
.tool kbd, .hint kbd {
  margin-left: auto;
  font: 11px ui-monospace, monospace;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
}
.tool-preview { margin-left: auto; flex: 0 0 auto; position: relative; }
.tool-preview + kbd { margin-left: 8px; }
.preview-bubble, .preview-thought, .preview-caption {
  background: #fffef8;
  border: 1.5px solid #1b1b1b;
  box-sizing: border-box;
}
.preview-bubble {
  width: 48px;
  height: 22px;
  border-radius: 11px;
}
.preview-bubble::after {
  content: "";
  position: absolute;
  left: 9px;
  bottom: -6px;
  width: 7px;
  height: 7px;
  background: #fffef8;
  border-left: 1.5px solid #1b1b1b;
  border-bottom: 1.5px solid #1b1b1b;
  transform: skewX(-24deg);
  border-bottom-left-radius: 6px;
}
.preview-thought {
  width: 42px;
  height: 20px;
  border-radius: 50%;
  margin-right: 14px;
}
.preview-thought::before, .preview-thought::after {
  content: "";
  position: absolute;
  background: #fffef8;
  border: 1.5px solid #1b1b1b;
  border-radius: 50%;
}
.preview-thought::before { width: 7px; height: 7px; left: -8px; bottom: -1px; }
.preview-thought::after { width: 4px; height: 4px; left: -14px; bottom: -4px; }
.preview-caption { width: 52px; height: 20px; border-radius: 2px; }
.preview-sfx {
  font-family: "Bangers", sans-serif;
  font-size: 20px;
  line-height: 1;
  color: #ffe14a;
  text-shadow: -1px -1px 0 #141414, 1px -1px 0 #141414, -1px 1px 0 #141414, 1px 1px 0 #141414, 0 1px 0 #141414;
}
.tool[aria-pressed="true"] {
  background: #342a18;
  border-color: var(--accent);
  color: #ffe7b8;
}

.layouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.layouts button { text-align: left; padding: 8px; font-size: 12px; font-weight: 700; }
.layouts button small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 12px 0 0; }

#stage-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
}
#stage {
  position: absolute;
  inset: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  background:
    radial-gradient(900px 420px at 50% 0%, rgba(226, 162, 58, 0.08), transparent 55%),
    #0d0f14;
}
#view { position: relative; }
#page {
  position: absolute;
  display: block;
  background: #fff;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.06);
  touch-action: none;
}
#stage.space #page { cursor: grab; }
#stage.panning #page { cursor: grabbing; }
#view-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(25, 28, 36, 0.94);
  box-shadow: var(--shadow);
}
#view-controls button { min-width: 32px; padding: 6px 8px; font-weight: 700; }
#view-zoom {
  width: auto;
  min-width: 5.5rem;
  background: #101319;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

#props label, .field {
  display: grid;
  gap: 4px;
  margin: 0 0 10px;
  font-size: 13px;
}
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
input[type="number"], select, textarea {
  width: 100%;
  background: #101319;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
}
textarea { min-height: 72px; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 100%; height: 32px; padding: 0; border: 1px solid var(--line); background: transparent; border-radius: 8px; }
.check { display: flex; align-items: center; gap: 8px; }
.prop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.prop-actions button { flex: 1 1 46%; }
label .deg { display: flex; align-items: center; gap: 4px; }
label .deg input { width: 5.5rem; }

#foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--rail);
  color: var(--muted);
  font-size: 12px;
}
#status { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#privacy { margin-right: auto; }
#meta { color: var(--muted); white-space: nowrap; }

#editor {
  display: none;
  position: fixed;
  z-index: 5;
  margin: 0;
  padding: 8px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: rgba(255, 253, 246, 0.96);
  color: #1b1b1b;
  resize: none;
  box-shadow: var(--shadow);
}
#editor.show { display: block; }

#bank {
  background: var(--rail);
  border-top: 1px solid var(--line);
  min-width: 0;
}
.bank-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 0;
}
#bank.collapsed .bank-bar { padding-bottom: 8px; }
#bank-toggle {
  background: transparent;
  border: 0;
  padding: 4px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
#bank-toggle::before {
  content: "▾ ";
  color: var(--accent);
}
#bank.collapsed #bank-toggle::before { content: "▸ "; }
#bank-count { color: var(--text); font-size: 12px; font-weight: 700; }
.bank-note { color: var(--muted); font-size: 12px; margin-right: auto; }
#bank-tray {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px 12px;
  min-height: 92px;
}
#bank.collapsed #bank-tray { display: none; }
#bank-tray.hot { outline: 2px dashed var(--accent); outline-offset: -6px; }
.bank-card {
  position: relative;
  flex: 0 0 92px;
  width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101319;
  padding: 4px;
  cursor: grab;
}
.bank-card img {
  display: block;
  width: 100%;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  background: #fff;
  pointer-events: none;
}
.bank-name {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bank-used {
  position: absolute;
  left: 8px;
  top: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 1px 6px;
}
.bank-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  opacity: 0;
  background: #1b1e27;
}
.bank-card:hover .bank-x,
.bank-card:focus-within .bank-x { opacity: 1; }

#confirm {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.confirm-card {
  width: min(440px, 100%);
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.confirm-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}
.confirm-card p { margin: 0; color: var(--text); line-height: 1.45; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

#shortcuts {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.shortcuts-card {
  width: min(880px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 10px;
  box-shadow: var(--shadow);
}
.shortcuts-head { display: flex; align-items: center; gap: 12px; }
.shortcuts-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}
.shortcuts-head button { margin-left: auto; }
.shortcuts-card > .hint { margin: 10px 0 0; }
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 28px;
  margin-top: 12px;
}
.shortcuts-grid section { margin: 0 0 12px; }
.shortcuts-grid h3 {
  margin: 8px 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.shortcuts-grid p { margin: 0 0 6px; font-size: 13px; line-height: 1.4; }
.shortcuts-grid kbd, .hint kbd {
  font: 11px ui-monospace, monospace;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  background: #101319;
}
