:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e9ecf1;
  --muted: #aeb6c2;
  --border: rgba(255,255,255,0.10);
  --accent: #4ea1ff;
  --accent2: #ff6bd6;
  --ok: #6bffb5;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 30% 0%, #1a2240 0%, var(--bg) 55%, #0a0c10 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

/* 余白を詰めて、埋め込みでもスクロールしにくく */
.app {
  width: min(920px, 92vw);
  margin: 16px auto;
  display: grid;
  gap: 14px;
}

/* iframe内は “画面ぴったり” に寄せる */
body.in-iframe {
  background: transparent;
}
body.in-iframe .app {
  width: 100%;
  margin: 0;
  padding: 12px;
  min-height: 100vh;      /* 重要：余白スクロールを抑える */
}

.panel {
  background: rgba(23, 26, 33, 0.92);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(6px);
}

.label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.75);
  color: var(--text);
  outline: none;
  line-height: 1.6;
  font-size: 15px;
}
.textarea:focus {
  border-color: rgba(78, 161, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.15);
}

.controls { padding-top: 16px; }

.step-row {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  gap: 12px;
  align-items: center;
}

.step-btn {
  height: 62px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.7);
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.step-btn:active { transform: translateY(1px); }

.step-btn.flat { box-shadow: inset 0 0 0 1px rgba(78, 161, 255, 0.18); }
.step-btn.sharp { box-shadow: inset 0 0 0 1px rgba(255, 107, 214, 0.18); }

.step-center { display: grid; gap: 10px; }

/* ✅ 数値バー：stepValue を中央固定 */
.step-display {
  position: relative;
  display: flex;
  align-items: baseline;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.6);
  min-height: 46px;
}

.step-label {
  color: var(--muted);
  font-size: 12px;
}

/* ✅ スライダー中央(0)の真上に寄せる */
.step-value {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
}

.slider-row { display: grid; gap: 6px; }

.slider { width: 100%; accent-color: var(--accent); }

.slider-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px;
}

.btn {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.7);
  color: var(--text);
  padding: 11px 14px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.btn.primary {
  border-color: rgba(78, 161, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.10);
}
.btn:active { transform: translateY(1px); }

.out-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.status {
  color: var(--ok);
  font-size: 12px;
  min-height: 1em;
}

#btnRealtimeToggle.is-on {
  border-color: rgba(255, 255, 255, 0.30);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.10);
}

/* 転調ボタンの幅を固定して、ON/OFFで横幅が変わらないようにする */
#btnRealtimeToggle {
  min-width: 105px;
  text-align: center;
  white-space: nowrap;
}

/* 4ボタンを同じ幅にする（等幅） */
.btn-row{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px; 
  margin-top: 18px;
  margin-bottom: -18px;
}

/* ボタンはセルいっぱいに広げる */
.btn-row .btn{
  width: 100%;
  justify-content: center;
  text-align: center;
  white-space: nowrap;     /* 改行させない */
}

@media (max-width: 520px){
  .btn-row{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px){
  .textarea{
    font-size: 16px;
  }
  textarea, input{
    -webkit-text-size-adjust: 100%;
  }
}