/* りそぱメーカー */
:root {
  --bg: #14161c;
  --bg2: #1b1e27;
  --bg3: #232733;
  --line: #333846;
  --text: #e7ebf3;
  --muted: #98a0b3;
  --accent: #6fd06f;
  --accent2: #63c6e8;
  --danger: #e06a6a;
  --radius: 10px;
  --shadow: 0 6px 22px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .92em; background: #000; padding: 1px 5px; border-radius: 5px; color: var(--accent2); }
h1, h2, h3 { margin: 0; font-weight: 700; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1d2130, #171a23);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 9px;
  background: linear-gradient(150deg, #4fae52, #2f7a44);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.28), inset 0 -3px 0 rgba(0,0,0,.28);
  font-weight: 800; font-size: 13px; letter-spacing: .5px;
  color: #eaffea;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; margin-left: auto; background: #12141b; padding: 4px; border-radius: 9px; border: 1px solid var(--line); }
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 16px; border-radius: 6px; cursor: pointer; font-weight: 600;
}
.tabs button:hover { color: var(--text); background: #1e222d; }
.tabs button.on { background: #2c3242; color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.07); }

button.primary {
  border: 0; cursor: pointer; font-weight: 700;
  color: #06210c;
  background: linear-gradient(180deg, #7ee07e, #4bb04b);
  padding: 10px 18px; border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 3px 0 #2c6a30, var(--shadow);
  transition: transform .06s;
}
button.primary:hover { filter: brightness(1.06); }
button.primary:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 1px 0 #2c6a30; }
button.primary:disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; box-shadow: none; }
button.primary.wide { width: 100%; margin-top: 6px; }

button.ghost {
  border: 1px solid var(--line); background: #20242f; color: var(--text);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
button.ghost:hover { background: #272c39; border-color: #414958; }
button.mini {
  border: 1px solid var(--line); background: #1e222c; color: var(--muted);
  padding: 3px 8px; border-radius: 6px; cursor: pointer; font-size: 11.5px;
}
button.mini:hover { color: var(--text); background: #2a2f3d; }
button.mini.danger:hover { color: #fff; background: #a33; border-color: #c55; }

/* ---------- panes ---------- */
main { height: calc(100% - 63px); }
.pane { display: none; height: 100%; overflow: auto; }
.pane.on { display: block; }

#tab-edit.on {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 0;
  overflow: hidden;
}
.col { overflow: auto; padding: 14px; min-width: 0; }
.col.left { border-right: 1px solid var(--line); background: var(--bg2); }
.col.right { border-left: 1px solid var(--line); background: var(--bg2); }
.col.stage { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.col.stage .card { background: transparent; border: 0; }
.card h2 { font-size: 13px; text-transform: none; color: var(--accent2); letter-spacing: .02em; margin-bottom: 10px; }
.card h3 { font-size: 12px; color: var(--muted); margin: 14px 0 8px; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- drop ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 22px 12px; text-align: center; cursor: pointer;
  border: 2px dashed #3c4456; border-radius: var(--radius);
  background: #191c25; transition: .15s;
}
.drop:hover, .drop.hot { border-color: var(--accent); background: #1b2a1e; }
.drop strong { font-size: 13.5px; }
.drop span { font-size: 12px; color: var(--muted); }
.drop small { font-size: 11px; color: #6f7788; margin-top: 4px; }

.image-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb {
  position: relative; border-radius: 8px; overflow: hidden; border: 2px solid var(--line);
  background: #0e1015; cursor: pointer; aspect-ratio: 1;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(111,208,111,.28); }
.thumb .nm { position: absolute; left: 0; right: 0; bottom: 0; font-size: 9.5px; padding: 2px 4px; background: rgba(0,0,0,.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .del { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }
.thumb .del:hover { background: #c33; }

/* ---------- target list ---------- */
.target-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow: auto; }
.target {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: #1e222c;
}
.target:hover { background: #242a36; }
.target.on { background: #223026; border-color: #3f6a45; }
.target .dot { width: 9px; height: 9px; border-radius: 50%; background: #464e60; flex: none; }
.target.has .dot { background: var(--accent); }
.target .tx { flex: 1; min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target .cnt { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.row-btns { display: flex; gap: 6px; margin-top: 10px; }
.row-btns button { flex: 1; }

/* ---------- stage ---------- */
.stage-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--bg2);
}
.seg { display: flex; background: #12141b; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 11px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 12px; }
.seg button.on { background: #2c3242; color: #fff; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.chk input { accent-color: var(--accent); }
.chk.block { display: flex; align-items: flex-start; gap: 8px; color: var(--text); font-size: 12.5px; line-height: 1.45; margin-top: 10px; }
.chk.block input { margin-top: 3px; }
.spacer { flex: 1; }

.stage-wrap { flex: 1; overflow: auto; padding: 20px; display: grid; place-items: start center; background:
  repeating-conic-gradient(#1a1d25 0% 25%, #15181f 0% 50%) 50% / 22px 22px; }
#stageInner { padding: 0; line-height: 0; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#preview { display: block; image-rendering: pixelated; cursor: grab; }
#preview.smooth { image-rendering: auto; }
#preview.drag { cursor: grabbing; }
.stage-note { padding: 6px 14px 10px; color: var(--muted); font-size: 11.5px; text-align: center; margin: 0; }

/* ---------- inspector ---------- */
.insp-head { margin-bottom: 3px; }
.insp-head strong { font-size: 14.5px; }
.badge {
  display: block; margin-bottom: 12px; font-family: var(--mono); font-size: 10px;
  color: #7f8ba3; word-break: break-all; line-height: 1.35;
}

.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field select, .field input[type=number] {
  width: 100%; background: #12141b; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent2); }

.ctl { margin-bottom: 9px; }
.ctl .lab { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.ctl .lab b { color: var(--text); font-family: var(--mono); font-weight: 600; }
input[type=range] { -webkit-appearance: none; width: 100%; height: 5px; border-radius: 3px; background: #2b3141; outline: none; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #d6ddeb; border: 2px solid #40485a; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb:hover { background: #fff; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.quick button {
  border: 1px solid var(--line); background: #20242f; color: var(--text);
  padding: 7px 4px; border-radius: 7px; cursor: pointer; font-size: 11.5px; font-weight: 600;
}
.quick button:hover { background: #2a2f3d; }
.quick button.on { background: #24402b; border-color: #4b8a55; color: #dfffe2; }

.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 7px; }
.colors label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--muted); align-items: center; }
.colors input[type=color] { width: 100%; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #12141b; cursor: pointer; }

details.sub { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
details.sub > summary { cursor: pointer; font-size: 12px; color: var(--accent2); list-style: none; }
details.sub > summary::-webkit-details-marker { display: none; }
details.sub > summary::before { content: "▸ "; }
details.sub[open] > summary::before { content: "▾ "; }
details.sub > div { padding-top: 9px; }

.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 26px 10px; }

/* ---------- export ---------- */
.export-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; padding: 16px; max-width: 1100px; margin: 0 auto; }
.summary { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.summary b { color: var(--text); }
.tree { font-family: var(--mono); font-size: 11.5px; background: #0e1015; border: 1px solid var(--line); border-radius: 8px; padding: 6px; max-height: 300px; overflow: auto; color: #b9c2d4; }
.frow { display: flex; align-items: baseline; gap: 10px; padding: 2px 6px; border-radius: 5px; }
.frow:hover { background: #171b23; }
.frow.root { border-bottom: 1px solid var(--line); margin-bottom: 4px; padding-bottom: 5px; font-weight: 700; color: #e7ebf3; }
.fname { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fname.sub { color: #9aa4b8; }
.fname.dir { color: var(--accent2); }
.fsz { flex: none; color: #6f7788; font-size: 10.5px; }
.preview-icon { display: flex; gap: 12px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#packIcon { width: 96px; height: 96px; border-radius: 8px; background: #0e1015; border: 1px solid var(--line); image-rendering: pixelated; flex: none; }
.preview-icon p { margin: 4px 0 0; }

/* ---------- help ---------- */
.help { max-width: 820px; margin: 0 auto; padding: 22px 18px 60px; }
.help h2 { font-size: 16px; margin: 24px 0 10px; color: var(--accent2); }
.help h2:first-child { margin-top: 0; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 12px; }
.steps p, .tips li { color: var(--muted); font-size: 13px; margin: 3px 0; }
.paths { list-style: none; padding: 0; }
.paths li { margin-bottom: 6px; font-size: 13px; }
.paths code { user-select: all; }
.tips li { margin-bottom: 8px; }
.tips b { color: var(--text); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #262c3a; border: 1px solid #3d455a; color: #fff;
  padding: 11px 20px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .22s; z-index: 200; font-size: 13px;
  max-width: 90vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #40222a; border-color: #7a3a44; }

.hint { color: var(--muted); font-size: 11.5px; }

@media (max-width: 1100px) {
  #tab-edit.on { grid-template-columns: 260px minmax(0,1fr); }
  .col.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  main { height: auto; }
  .pane { height: auto; }
  #tab-edit.on { overflow: visible; }
  .export-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 780px) {
  .top { flex-wrap: wrap; }
  .tabs { margin-left: 0; order: 3; width: 100%; }
  #tab-edit.on { grid-template-columns: minmax(0,1fr); }
  .brand-text small { display: none; }
}

/* ================= テクスチャ / フォント スタジオ ================= */
.studio { display: grid; grid-template-columns: 300px minmax(0,1fr) 320px; height: 100%; }
#tab-textures.on { display: block; }
.scol { overflow: auto; padding: 12px; min-width: 0; }
.scol.left { background: var(--bg2); border-right: 1px solid var(--line); }
.scol.right { background: var(--bg2); border-left: 1px solid var(--line); }
.scol.stage { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.jarinfo { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; padding: 8px 10px; background: #1a2a1d; border: 1px solid #33613a; border-radius: 8px; }
.jarinfo strong { color: var(--accent); font-family: var(--mono); }
.loadbox { display: flex; flex-direction: column; gap: 6px; }
button.wide { width: 100%; }
.prog { margin-top: 10px; }
.prog .bar { height: 8px; background: #12141b; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.prog .bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #4bb04b, #7ee07e); transition: width .15s; }
.prog span { font-size: 11px; color: var(--muted); font-family: var(--mono); }

input.search { width: 100%; background: #12141b; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; margin-bottom: 8px; }
input.search:focus { border-color: var(--accent2); }

.catlist { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.catlist button {
  border: 1px solid var(--line); background: #1e222c; color: var(--muted);
  padding: 4px 9px; border-radius: 99px; cursor: pointer; font-size: 11px; white-space: nowrap;
}
.catlist button:hover { color: var(--text); background: #262b38; }
.catlist button.on { background: #24402b; border-color: #4b8a55; color: #dfffe2; }
.catlist button i { font-style: normal; opacity: .6; margin-left: 4px; font-size: 10px; }

.texlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px,1fr)); gap: 6px; margin-top: 8px; }
.texitem {
  position: relative; border: 2px solid transparent; border-radius: 7px; background: #191c24;
  cursor: pointer; padding: 3px; text-align: center; overflow: hidden;
}
.texitem:hover { background: #232834; }
.texitem.on { border-color: var(--accent2); background: #1c2832; }
.texitem.edited { border-color: var(--accent); }
.texitem img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; image-rendering: pixelated; }
.texitem span { display: block; font-size: 8.5px; color: #8b93a5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.texitem .badge2 { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,.5); }

.stage-bar .ttl { font-size: 12.5px; font-weight: 600; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#texStageInner.checker { background: repeating-conic-gradient(#2a2e39 0% 25%, #1e222b 0% 50%) 50% / 16px 16px; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#texPreview { display: block; image-rendering: pixelated; cursor: crosshair; }
#texPreview.smooth { image-rendering: auto; }

.toolrow { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.toolrow button {
  border: 1px solid var(--line); background: #20242f; color: var(--text);
  padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 11.5px; min-width: 34px;
}
.toolrow button:hover { background: #2a2f3d; }
.toolrow button.on { background: #24402b; border-color: #4b8a55; color: #dfffe2; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin: 6px 0; }
.swatches i { display: block; aspect-ratio: 1; border-radius: 3px; cursor: pointer; border: 1px solid rgba(255,255,255,.15); }
.swatches i.on { outline: 2px solid var(--accent2); outline-offset: 1px; }
.palette { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.palette i { display: block; width: 16px; height: 16px; border-radius: 3px; cursor: pointer; border: 1px solid rgba(255,255,255,.15); }
.sizechips { display: flex; gap: 4px; flex-wrap: wrap; }
.sizechips button { border: 1px solid var(--line); background: #1e222c; color: var(--muted); padding: 4px 9px; border-radius: 99px; cursor: pointer; font-size: 11px; }
.sizechips button.on { background: #24402b; border-color: #4b8a55; color: #dfffe2; }

.fontgrid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; }
.fontsample { background: #12141b; border: 1px solid var(--line); border-radius: 8px; padding: 14px; font-size: 22px; line-height: 1.5; word-break: break-all; min-height: 70px; }
.fontatlas { margin: 10px 0; }
.fontatlas canvas { width: 100%; max-width: 420px; image-rendering: pixelated; background: #12141b; border: 1px solid var(--line); border-radius: 6px; display: block; }

@media (max-width: 1100px) {
  .studio { grid-template-columns: 250px minmax(0,1fr); }
  .scol.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .fontgrid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 780px) { .studio { grid-template-columns: minmax(0,1fr); } }
