/* ============================================================
   GSBone — Lightweight 2D Bone Animation
   minimal dark theme
   ============================================================ */

:root {
  --bg-0: #1a1d22;
  --bg-1: #22262d;
  --bg-2: #2a2f37;
  --bg-3: #353b45;
  --border: #3a414d;
  --text-0: #e6e8ec;
  --text-1: #aab0bc;
  --text-2: #6e7686;
  --accent: #ffb347;
  --accent-dim: #b87a2a;
  --bone-default: #d8dde6;
  --bone-selected: #ffb347;
  --bone-tip: #6fc3ff;
  --bone-parent: #76e0a6;
  --danger: #ef6b6b;
  --grid: #262a31;
  --grid-strong: #2e333c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* HTML標準のhidden属性が display:flex/grid 等で上書きされないように */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", sans-serif;
  font-size: 13px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------- Title bar ---------- */
#title-bar {
  height: 40px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
}

.title-bar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.brand-sub {
  color: var(--text-2);
  font-size: 11px;
}

.title-bar-right {
  display: flex;
  gap: 6px;
}

.tb-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 7px 14px;
  min-height: 32px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
}

.tb-btn:hover {
  background: var(--bg-3);
}

/* ---------- App layout ---------- */
#app {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 64px 1fr 260px;
}

/* ---------- Left toolbar ---------- */
#toolbar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  gap: 2px;
}

.tool-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-1);
  padding: 14px 4px;
  min-height: 56px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.12s, color 0.12s;
}

.tool-btn:hover {
  background: var(--bg-2);
  color: var(--text-0);
}

.tool-btn.active {
  background: var(--bg-3);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tool-ico {
  font-size: 18px;
  line-height: 1;
}

.tool-label {
  font-size: 10px;
}

.tool-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 8px;
}

/* ---------- Canvas area ---------- */
#canvas-area {
  position: relative;
  background: var(--bg-0);
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  /* タッチでブラウザのスクロール/ズーム/パン抑止 — ピンチ等は自前で処理 */
  touch-action: none;
}

#stage.tool-select {
  cursor: default;
}

#hud {
  position: absolute;
  left: 10px;
  bottom: 56px;
  display: flex;
  gap: 14px;
  padding: 6px 10px;
  background: rgba(34, 38, 45, 0.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-1);
  pointer-events: none;
}

#hud span { white-space: nowrap; }
#hud-hint { color: var(--text-2); }

/* ---------- Timeline bar (canvas 下部) ---------- */
#timeline-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  touch-action: none;
}

.tl-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 6px 12px;
  min-width: 38px;
  min-height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s;
}

.tl-btn:hover { background: var(--bg-3); }
.tl-btn.playing { background: var(--accent-dim); color: #1a1d22; border-color: var(--accent); }

#tl-frame, #tl-time {
  font-size: 11px;
  color: var(--text-1);
  font-family: "Consolas", "Menlo", monospace;
  min-width: 70px;
  text-align: center;
}

#tl-scrub {
  flex: 1;
  height: 24px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

#tl-scrub::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
}
#tl-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -6px;
  cursor: grab;
  border: 2px solid var(--bg-1);
}
#tl-scrub::-moz-range-track { height: 6px; background: var(--bg-3); border-radius: 3px; }
#tl-scrub::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: grab; border: 2px solid var(--bg-1);
}

.insp-row-stack { flex-direction: column; align-items: stretch; gap: 4px; }
.insp-row input[type="range"] { width: 100%; }

.insp-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 5px 6px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  width: 100%;
}
.insp-select:focus { outline: none; border-color: var(--accent); }
.insp-select optgroup { background: var(--bg-1); color: var(--text-2); font-style: normal; }
.insp-select option { background: var(--bg-2); color: var(--text-0); }

.insp-fps-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 6px 0;
  font-size: 11px;
  color: var(--text-2);
}
.insp-fps-note b { color: var(--text-1); font-weight: 600; }
.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
}
.link-btn:hover { background: var(--bg-3); }

/* ---------- Right inspector ---------- */
#inspector {
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.insp-section {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.insp-title {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.insp-body {
  font-size: 12px;
  color: var(--text-0);
}

.insp-empty {
  color: var(--text-2);
  font-style: italic;
  padding: 8px 0;
}

.insp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  gap: 8px;
}

.insp-row label {
  color: var(--text-1);
  font-size: 11px;
  flex: 0 0 auto;
  min-width: 60px;
}

.insp-row input[type="text"],
.insp-row input[type="number"] {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  padding: 3px 6px;
  border-radius: 3px;
  width: 100%;
  font-family: inherit;
  font-size: 12px;
}

.insp-row input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Bone list ---------- */
.bone-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.bone-list li {
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bone-list li:hover {
  background: var(--bg-2);
  color: var(--text-0);
}

.bone-list li.selected {
  background: var(--bg-3);
  color: var(--accent);
}

.bone-list li .bone-depth {
  display: inline-block;
  width: 10px;
  color: var(--text-2);
}
