/**
 * Generator UI Kit（ジェネレーター用の共通見た目）
 * 正本: GENKIT.md / js/gen-kit.js
 *
 * 使うツール: tools-registry で 'ui' => 'gen-kit'（1カラムにするなら 'layout' => 'stack'）
 * 接頭辞は gk-。ツール固有の調整は各ツールのCSS（例: css-slider.css）に書く。
 * FORM.md の dm-field / dm-control は互換のため残し、見た目だけ .gk 配下で上書きする。
 */

/* ---------- tokens ---------- */
.gk {
  --gk-primary: #1776cf;
  --gk-primary-dark: #125fa8;
  --gk-primary-soft: #eaf3fc;
  --gk-selected: #5b9ee8; /* 設定内のセグメントの選択色（ボタン色より少し薄い） */
  --gk-ink: #202b39;
  --gk-muted: #68778a;
  --gk-line: #e1e7ef;
  --gk-line-strong: #cfd8e3;
  --gk-surface: #fff;
  --gk-surface-alt: #f8fafd;
  --gk-radius: 15px;
  --gk-radius-sm: 9px;
  --gk-shadow: 0 3px 14px #263c5910;
  --gk-gap: 12px;
  color: var(--gk-ink);
  font-size: 14px;
  line-height: 1.6;
}

.gk *,
.gk *::before,
.gk *::after {
  box-sizing: border-box;
}

.gk [hidden] {
  display: none !important;
}

/* ---------- page shell: ワークスペース（layout => workspace） ----------
 * 左=入力（.yt-tool-ws-main） / 右=結果（.yt-tool-ws-side, sticky）。
 * 既存テーマの panel / result 枠は使わない。
 * ページ幅(1480px)は全ツール共通で tool.css の body.yt-tool-single が持つ（ここでは背景色のみ）。
 */
body.yt-tool-body:has(.yt-tool-page--wide) {
  background: #f6f8fb;
}

.yt-tool-workspace {
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
  gap: 20px;
  align-items: start;
}

.yt-tool-ws-main,
.yt-tool-ws-side {
  min-width: 0;
}

/* 右（結果）だけ画面に追従。画面より高いときは内部でスクロール。左（入力）は通常のページスクロール */
.yt-tool-ws-main {
  outline: 0;
}

.yt-tool-ws-side {
  position: sticky;
  top: var(--yt-sticky-top, 94px);
  outline: 0;
}

.yt-tool-ws-side {
  max-height: calc(100vh - var(--yt-sticky-top, 94px) - 12px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* 使い方は下段に横長で（手順とポイントを2列、見出し・プライバシーは全幅） */
.yt-tool-workspace + .yt-tool-guide {
  margin-top: 28px;
}

@media (min-width: 900px) {
  .yt-tool-guide.yt-tool-guide--wide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 28px;
    align-items: start;
  }

  .yt-tool-guide--wide > .yt-tool-heading,
  .yt-tool-guide--wide > .yt-tool-privacy {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1080px) {
  .yt-tool-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .yt-tool-ws-side {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

/* ---------- card ---------- */
.gk-card {
  background: var(--gk-surface);
  border: 1px solid var(--gk-line);
  border-radius: var(--gk-radius);
  box-shadow: var(--gk-shadow);
  overflow: hidden;
}

.gk-card + .gk-card {
  margin-top: 18px;
}

.gk-card-body {
  padding: 20px;
}

.gk-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 var(--gk-gap);
}

.gk-card-title {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--gk-ink);
}

.gk-sub {
  color: var(--gk-muted);
  font-size: 12px;
}

/* ---------- tabs ---------- */
.gk-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--gk-line);
  background: var(--gk-surface-alt);
}

.gk .gk-tab {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 64px;
  margin: 0;
  padding: 10px 6px;
  border: 0;
  border-right: 1px solid var(--gk-line);
  border-radius: 0;
  background: transparent;
  color: var(--gk-ink);
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.gk .gk-tab:last-child {
  border-right: 0;
}

.gk .gk-tab:hover {
  background: var(--gk-primary-soft);
}

.gk .gk-tab.is-active {
  background: var(--gk-primary);
  color: #fff;
}

.gk .gk-tab:focus-visible {
  outline: 2px solid var(--gk-primary-dark);
  outline-offset: -4px;
}

.gk-tab-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  color: var(--gk-primary);
}

.gk-tab.is-active .gk-tab-icon {
  color: #fff;
}

.gk-tab-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gk-panel {
  padding: 16px;
}

/* 小さなタブ（デバイス切替など） */
.gk-tabs.is-compact {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  border: 1px solid var(--gk-line-strong);
  border-radius: var(--gk-radius-sm);
  overflow: hidden;
  background: #f7f9fc;
  margin: 0 0 var(--gk-gap);
}

.gk .gk-tabs.is-compact .gk-tab {
  flex-direction: row;
  min-height: 0;
  padding: 8px 18px;
  font-size: 13px;
  border-right: 1px solid var(--gk-line-strong);
}

.gk .gk-tabs.is-compact .gk-tab:last-child {
  border-right: 0;
}

/* ---------- headings / groups ---------- */
/* 見出し h3: 左に歯車アイコン（設定のまとまりを示す）。色は --gk-primary */
.gk-h {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--gk-ink);
}

.gk-h::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  background: var(--gk-primary);
  -webkit-mask: var(--gk-gear) center / contain no-repeat;
  mask: var(--gk-gear) center / contain no-repeat;
  --gk-gear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

/* グループ: 中身は縦に同じ間隔（--gk-gap）で並べる。個別の margin は使わない */
.gk-group {
  display: grid;
  gap: var(--gk-gap);
  align-content: start;
  min-width: 0;
}

.gk-group + .gk-group {
  margin-top: 27px;
  padding-top: 24px;
  border-top: 1px solid var(--gk-line);
}

.gk p.gk-note {
  margin: 0;
  color: var(--gk-muted);
  font-size: 12px;
  line-height: 1.6;
}

/* 注釈は直前の部品にくっつける */
.gk .gk-group > p.gk-note {
  margin: calc(var(--gk-gap) * -0.5) 0 -3px;
}

.gk-group > .gk-card-head {
  margin: 0;
}

.gk-group > .gk-tabs.is-compact {
  margin: 0;
  justify-self: start;
}

/* 折りたたみ（詳細設定） */
.gk-details {
  padding: 10px 12px;
  border: 1px solid #e0e6ee;
  border-radius: var(--gk-radius-sm);
  background: var(--gk-surface-alt);
}

.gk-details > summary {
  cursor: pointer;
  font-weight: 700;
}

.gk-details[open] > summary {
  margin-bottom: var(--gk-gap);
}

/* ---------- fields ---------- */
/* 列数は --cols。非表示の項目は数えず、残った項目が行いっぱいに広がる（右に隙間が出ない） */
.gk-grid {
  --cols: 2;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gk-gap) 14px;
}

.gk-grid.is-3 {
  --cols: 3;
}

.gk-grid.is-4 {
  --cols: 4;
}

/* 表示中の項目が1つもないグリッドは出さない（空でも gap の分だけ余白ができるため） */
.gk-grid:not(:has(> :not([hidden]))) {
  display: none;
}

.gk-grid > * {
  flex: 1 1 calc((100% - (var(--cols) - 1) * 14px) / var(--cols) - 1px);
  min-width: 0;
}

.gk .dm-field {
  margin: 0;
  min-width: 0;
}

.gk .dm-field > label,
.gk .gk-q > legend {
  display: block;
  margin: 0 0 5px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--gk-ink);
}

/* tool.css の .yt-tool-panel .dm-field .dm-control と同じ詳細度。後読みで上書き */
.gk .dm-field .dm-control {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--gk-line-strong);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--gk-ink);
}

.gk .dm-field .dm-control:focus {
  outline: 2px solid #1776cf55;
  outline-offset: 0;
  border-color: var(--gk-primary);
}

/* 任意の空欄は白のまま（必須だけ既定のピンクを残す） */
.gk .dm-field:not(.is-required) .dm-control.is-empty {
  background: #fff;
  border-color: var(--gk-line-strong);
}

.gk .gk-q {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.gk .gk-q > legend {
  float: none;
  width: auto;
}

.gk .dm-req-badge {
  margin-left: 0.5em;
}

/* 関連する入力を1つの薄い箱にまとめる（外側の余白の上下左右など）。見出しは箱の中 */
.gk .gk-q.gk-box {
  padding: 10px 12px 12px;
  border: 1px solid var(--gk-line);
  border-radius: var(--gk-radius-sm);
  background: var(--gk-primary-soft);
}

.gk .gk-q.gk-box > legend {
  float: left;
  width: 100%;
  margin: 0 0 8px;
}

.gk .gk-q.gk-box > legend + * {
  clear: both;
}

.gk .gk-box .dm-field > label {
  color: var(--gk-muted);
  font-size: 12px;
  text-align: center;
}

.gk .gk-box .dm-field .dm-control {
  text-align: center;
}

/* 効かない項目はグレーアウト（入力不可） */
.gk .dm-field:has(input:disabled, select:disabled) {
  opacity: 0.45;
}

.gk .dm-field input:disabled,
.gk .dm-field select:disabled {
  cursor: not-allowed;
}

/* カラーコード欄: クリックでカラーピッカーを開く（js/gen-kit.js の initColorFields）。右端に現在色の見本 */
.gk-color {
  position: relative;
}

.gk-color > .dm-control {
  padding-right: 38px;
}

.gk-color-swatch {
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--gk-line-strong);
  border-radius: 6px;
  background: var(--gk-swatch, #fff);
  pointer-events: none;
}

/* 実際のピッカー。見えないが、ポップアップは入力欄の位置に出る */
.gk-color > input[type="color"] {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---------- segmented（実体は radio。値・name は通常のフォームのまま） ---------- */
.gk-seg {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  border: 1px solid #d7e0e9;
  border-radius: var(--gk-radius-sm);
  overflow: hidden;
  background: #f7f9fc;
}

.gk .gk-seg label {
  position: relative;
  flex: 1 1 0;
  display: flex;
  margin: 0;
  cursor: pointer;
  font-weight: 650;
}

.gk .gk-seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.gk .gk-seg label > span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 6px 8px;
  border-right: 1px solid #d7e0e9;
  text-align: center;
  line-height: 1.35;
  transition: background 0.15s, color 0.15s;
}

.gk .gk-seg label:last-child > span {
  border-right: 0;
}

.gk .gk-seg label:hover > span {
  background: var(--gk-primary-soft);
}

.gk .gk-seg input:checked + span {
  background: var(--gk-selected);
  color: #fff;
}

.gk .gk-seg input:focus-visible + span {
  outline: 2px solid var(--gk-primary-dark);
  outline-offset: -3px;
}

.gk .gk-seg input:disabled + span {
  opacity: 0.45;
  cursor: not-allowed;
}

.gk-seg.is-wrap {
  flex-wrap: wrap;
}

.gk-seg.is-wrap label {
  flex: 1 1 140px;
}

/* ---------- check ---------- */
.gk .gk-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 18px 0 0;
  font-weight: 650;
  cursor: pointer;
}

.gk .gk-check input {
  width: 1.1em;
  height: 1.1em;
  margin: 0;
}

.gk .gk-check:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- switch（ON/OFF。実体は checkbox。yt_gk_switch_html） ---------- */
.gk .gk-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}

.gk .gk-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.gk .gk-switch-ui {
  position: relative;
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #c3ccd8;
  transition: background-color 0.15s ease;
}

.gk .gk-switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.gk .gk-switch input:checked + .gk-switch-ui {
  background: var(--gk-primary);
}

.gk .gk-switch input:checked + .gk-switch-ui::after {
  transform: translateX(18px);
}

.gk .gk-switch input:focus-visible + .gk-switch-ui {
  outline: 2px solid var(--gk-primary-dark);
  outline-offset: 2px;
}

.gk .gk-switch:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- buttons ---------- */
.gk .gk-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid var(--gk-line-strong);
  border-radius: var(--gk-radius-sm);
  background: #fff;
  color: var(--gk-ink);
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.gk .gk-btn:hover {
  background: var(--gk-primary-soft);
  border-color: #9ab6d4;
}

.gk .gk-btn[data-gk-copy]:active,
.gk .gk-btn[data-gk-copy].is-done {
  border-color: var(--gk-primary);
  background: var(--gk-primary);
  color: #fff;
}

.gk .gk-btn.is-primary {
  flex: 1;
  padding: 14px 16px;
  border-color: var(--gk-primary);
  background: var(--gk-primary);
  color: #fff;
  font-size: 15px;
}

.gk .gk-btn.is-primary:hover {
  background: var(--gk-primary-dark);
  border-color: var(--gk-primary-dark);
}

.gk .gk-btn.is-small {
  padding: 6px 12px;
  font-size: 13px;
}

.gk .gk-btn[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.gk .gk-btn.is-small[disabled] {
  cursor: not-allowed;
}

.gk .gk-btn:focus-visible {
  outline: 2px solid var(--gk-primary-dark);
  outline-offset: 2px;
}

.gk .gk-btn.is-dashed {
  width: 100%;
  border-style: dashed;
  border-color: #9ab6d4;
  background: #fafdff;
  color: #176ebd;
}

.gk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 16px;
  border-top: 1px solid var(--gk-line);
  background: var(--gk-surface-alt);
}

.gk p.gk-error {
  margin: 0;
  padding: 8px 16px 12px;
  color: #c53030;
  font-weight: 650;
  background: var(--gk-surface-alt);
}

/* ---------- repeater（画像カードなど） ---------- */
.gk-item {
  margin: 0;
  border: 1px solid #dfe6ee;
  border-radius: 12px;
  background: #fbfcfe;
}

.gk-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.gk-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 38px;
  border-radius: 6px;
  background: linear-gradient(145deg, #b4d6ea, #d8eacb);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #4d7189;
}

.gk-thumb svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gk-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gk .gk-item-toggle {
  appearance: none;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.gk-item-title {
  font-weight: 700;
  white-space: nowrap;
}

.gk-item-sub {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gk-muted);
  font-size: 12px;
}

.gk-item-caret {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid #4e6074;
  border-bottom: 2px solid #4e6074;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}

.gk-item-toggle[aria-expanded="true"] .gk-item-caret {
  transform: rotate(-135deg) translateY(-2px);
}

.gk .gk-icon-btn {
  appearance: none;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4e6074;
  cursor: pointer;
}

.gk .gk-icon-btn:hover {
  background: #fde8e8;
  color: #c53030;
}

.gk .gk-icon-btn:focus-visible {
  outline: 2px solid var(--gk-primary-dark);
  outline-offset: 1px;
}

.gk-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gk-item-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  padding: 4px 12px 12px;
}

.gk-item-body > :first-child {
  grid-column: 1 / -1;
}

[data-gk-list] {
  display: grid;
  gap: 8px;
}

.gk-item-body[hidden] {
  display: none;
}

/* ---------- preview ---------- */
/* プレビュー枠。iframe は実寸（PC=1100px 等）で描画し、枠幅に合わせて縮小表示する
 * （枠が狭くても iframe 内のメディアクエリが「その端末幅」で効く）。縮小は ytGenKit.fitPreview。 */
.gk-preview-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--gk-line);
  border-radius: 12px;
  background: #eef3f9;
  overflow: hidden;
}

/* 生成前の案内は枠いっぱい */
.gk-preview-wrap.is-empty {
  width: auto;
}

.gk-preview-stage {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 6px #263c5918;
}

.gk-preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  max-width: none;
  border: 0;
  background: #fff;
  transform-origin: 0 0;
  transition: opacity 0.35s ease;
}

/* 読み込み中：枠の大きさは保ったまま、中身は隠してスピナーを出す。
 * ::before = 覆い、::after = スピナー（彗星のように尾を引く輪）。
 * 端末切り替え（.is-forced）はすぐ出して JS 側で最低1秒保つ。それ以外は 0.4 秒以上かかったときだけ出す。 */
.gk-preview-stage.is-loading .gk-preview-frame {
  opacity: 0;
}

.gk-preview-stage::before,
.gk-preview-stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.gk-preview-stage::before {
  inset: 0;
  background: linear-gradient(160deg, #f6f9fd, #eaf1f9);
}

.gk-preview-stage::after {
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 2.5px, var(--gk-primary) 2.5px, transparent 3px),
    conic-gradient(from 0deg, #d5e3f3 0%, #d5e3f3 22%, var(--gk-primary) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.5px));
  animation: gk-spin 0.95s linear infinite;
  animation-play-state: paused;
}

.gk-preview-stage.is-loading::before,
.gk-preview-stage.is-loading::after {
  opacity: 1;
  transition: opacity 0.25s ease 0.4s;
  animation-play-state: running;
}

.gk-preview-stage.is-loading.is-forced::before,
.gk-preview-stage.is-loading.is-forced::after {
  transition-delay: 0s;
}

/* 端末切り替え（PC / タブレット / スマホ）：
 * 押した瞬間に覆いを出し切り（中身がチラ見えしない）、その裏で枠の幅・高さをなめらかに変える。
 * 覆いが消えるとき（is-loading が外れたあと）は通常のフェードで戻る。 */
.gk-preview-stage.is-forced {
  transition:
    width 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.gk-preview-stage.is-loading.is-forced::before,
.gk-preview-stage.is-loading.is-forced::after {
  transition: none;
}

.gk-preview-stage.is-loading.is-forced .gk-preview-frame {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .gk-preview-stage.is-forced {
    transition: none;
  }
}

@keyframes gk-spin {
  to {
    transform: rotate(360deg);
  }
}

.gk-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 24px;
  border: 1px dashed var(--gk-line-strong);
  border-radius: 10px;
  background: #fafcff;
  color: var(--gk-muted);
  text-align: center;
  line-height: 1.7;
}

.gk-empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--gk-ink);
  font-size: 15px;
}

/* ---------- code output ---------- */
.gk-code {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.gk-code-col {
  min-width: 0;
}

.gk-code-col.is-wide {
  grid-column: 1 / -1;
}

.gk-code-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  margin: 0 0 6px;
}

.gk .gk-code-head label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.gk-code-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.gk-bytes {
  color: var(--gk-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gk .gk-code-out {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 9px 10px;
  border: 1px solid #dce5ef;
  border-radius: 8px;
  background: #f8fafc;
  color: #224d78;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, Menlo, monospace;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .gk-grid.is-4 {
    --cols: 2;
  }
}

@media (max-width: 768px) {
  .gk-tabs {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gk .gk-tab {
    min-height: 64px;
    border-bottom: 1px solid var(--gk-line);
    font-size: 12px;
  }

  .gk .gk-tab:nth-child(2n) {
    border-right: 0;
  }

  .gk-panel,
  .gk-card-body {
    padding: 12px;
  }

  .gk-grid,
  .gk-grid.is-3,
  .gk-grid.is-4 {
    --cols: 1;
  }

  .gk-item-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .gk-code {
    grid-template-columns: minmax(0, 1fr);
  }

  .gk-seg.is-stack-sm {
    flex-direction: column;
  }

  .gk .gk-seg.is-stack-sm label > span {
    border-right: 0;
    border-bottom: 1px solid #d7e0e9;
  }

  .gk .gk-seg.is-stack-sm label:last-child > span {
    border-bottom: 0;
  }

  .gk-actions {
    padding: 14px;
  }

  .gk .gk-btn.is-primary {
    flex-basis: 100%;
  }

}

@media (prefers-reduced-motion: reduce) {
  .gk *,
  .gk *::before,
  .gk *::after {
    transition: none !important;
  }
}
