/* ==========================================================================
   箱ダイヤ描画ソフト - モダン・シンプル スタイルシート
   - カラーパレット: ニュートラルグレー基調 + 深みのある青緑アクセント (#2F6F73)
   - 不要なグラデーション・ネオン・ガラス風エフェクト・絵文字過多を完全排除
   - 2ペイン分割 + ドラッグ幅変更対応
   - 1:1 ベクター印刷対応 (@media print)
   ========================================================================== */

:root {
  /* ニュートラルパレット */
  --bg-app: #f4f5f7;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;

  /* 罫線・区切り */
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --border-focus: #2F6F73;

  /* テキスト色 */
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* アクセントカラー: 落ち着いた青緑 (#2F6F73) */
  --primary: #2F6F73;
  --primary-hover: #26595d;
  --primary-active: #1d4346;
  --primary-light: #edf5f5;
  --primary-text: #ffffff;

  /* アラート・ステータス */
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --success: #16a34a;

  /* フォント指定 */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Meiryo UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  /* モーションイージング */
  --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-main);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   アプリケーション全体レイアウト
   ========================================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* 上部メインバー */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mobile-header-quick {
  display: none;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn.mobile-only-btn,
.mobile-only-btn {
  display: none;
}

.brand-icon {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
  border-radius: 5px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  white-space: nowrap;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e6f4f1;
  color: #1f5156;
  border: 1px solid #b9dfd8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  flex-shrink: 0;
}

.portal-back-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  padding: 0 9px;
  margin-left: 2px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.portal-back-link:hover {
  color: var(--primary);
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.preset-select-control {
  width: clamp(140px, 14vw, 220px);
}

.footer-portal-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.footer-portal-link:hover {
  text-decoration: underline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 1380px) {
  .app-header {
    padding: 0 8px;
    gap: 8px;
  }
  .portal-back-link {
    padding: 0 7px;
    font-size: 10.5px;
  }
  .preset-select-control {
    width: clamp(118px, 12vw, 175px);
  }
  .header-actions {
    gap: 4px;
  }
  .header-actions .btn-sm {
    padding: 0 6px;
    font-size: 11px;
  }
}

.history-group {
  display: flex;
  align-items: center;
  gap: 2px;
  border-right: 1px solid var(--border-color);
  padding-right: 8px;
  margin-right: 4px;
}

/* メイン2ペイン領域 */
.main-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* 左ペイン: 表形式エディタ */
.editor-pane {
  width: 660px;
  min-width: 460px;
  max-width: 950px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* スプリッター（ドラッグで幅変更） */
.workspace-splitter {
  width: 5px;
  cursor: col-resize;
  background-color: transparent;
  transition: background-color 0.15s ease;
  z-index: 20;
}

.workspace-splitter:hover,
.workspace-splitter.dragging {
  background-color: var(--primary);
}

/* 右ペイン: プレビュー表示 */
.preview-pane {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #64748b22;
  overflow: hidden;
}

/* ==========================================================================
   ボタン・フォーム要素の統一デザイン
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-focus);
}

.btn:active:not(:disabled) {
  background-color: var(--bg-active);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  background-color: var(--primary-active);
  border-color: var(--primary-active);
}

.btn-secondary {
  background-color: var(--bg-subtle);
}

.btn-primary-outline {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.btn-primary-outline:hover:not(:disabled) {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.btn-xs {
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
}

.btn-xs.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-icon {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}

.btn-icon.btn-icon-label {
  width: auto;
  min-width: 28px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  border-color: var(--border-subtle);
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.btn-icon:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-icon.text-danger:hover:not(:disabled) {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* セレクト・インプット */
.form-control, .form-select {
  height: 28px;
  padding: 0 8px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.12s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ==========================================================================
   エディタタブ & ボディ
   ========================================================================== */
.editor-tabs {
  display: flex;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}

.editor-tab-btn {
  padding: 8px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.editor-tab-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.editor-tab-btn.active {
  color: var(--primary);
  font-weight: 700;
  border-bottom-color: var(--primary);
  background-color: var(--bg-surface);
}

.editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px;
}

.tab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
  gap: 8px;
}

.roster-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title-sm {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   スプレッドシート風グリッドテーブル
   ========================================================================== */
.table-scroll-container {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-surface);
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: left;
}

.grid-table thead th {
  position: sticky;
  top: 0;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-subtle);
  padding: 4px 3px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  z-index: 2;
}

.grid-table tbody td {
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: 2px 2px;
  vertical-align: middle;
  white-space: nowrap;
}

.grid-table tbody tr:hover td {
  background-color: var(--bg-hover);
}

.grid-table tbody tr.row-error td {
  background-color: var(--danger-light);
}

.grid-table tbody tr.row-warning td {
  background-color: var(--warning-light);
}

/* セル内入力フィールド */
.cell-input {
  width: 100%;
  height: 22px;
  padding: 0 2px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  color: inherit;
  outline: none;
}

.cell-input-sm {
  height: 20px;
  font-size: 10px;
  padding: 0 2px;
}

.cell-input:hover {
  border-color: var(--border-subtle);
  background-color: var(--bg-surface);
}

.cell-input:focus {
  border-color: var(--primary);
  background-color: var(--bg-surface);
}

.cell-select {
  width: 100%;
  height: 22px;
  padding: 0 1px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  color: inherit;
  outline: none;
}

.cell-select-sm {
  height: 20px;
  font-size: 10px;
  padding: 0 1px;
}

.cell-select:hover {
  border-color: var(--border-subtle);
  background-color: var(--bg-surface);
}

.cell-select:focus {
  border-color: var(--primary);
  background-color: var(--bg-surface);
}

.coupled-cell-flex {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-icon-xs {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0 3px;
  height: 18px;
  font-size: 10px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 16px;
  flex-shrink: 0;
}

.btn-icon-xs:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--primary);
}

.btn-icon-xs:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.color-picker-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-hex-input {
  width: 68px;
  height: 22px;
  padding: 0 4px;
  font-size: 11px;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
}

.action-cell {
  text-align: center;
  white-space: nowrap;
}

.table-footer-info {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

/* 併結位置選択・3両以上ポップオーバー・部分継走・同期コントロール */
#trainsGridTable {
  table-layout: fixed;
  width: 100%;
}

#trainsGridTable thead th,
#trainsGridTable tbody td {
  padding: 2px 1px;
  overflow: hidden;
}

#trainsGridTable .cell-input,
#trainsGridTable .cell-select {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 10.5px;
  padding: 0 1px;
}

#trainsGridTable input[type="number"]::-webkit-inner-spin-button,
#trainsGridTable input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#trainsGridTable input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.coupled-cell-flex {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.coupled-pos-select {
  width: 34px !important;
  flex: 0 0 34px;
  font-size: 9.5px !important;
  padding: 0 !important;
}

.coupled-cell-flex .btn-icon-xs {
  padding: 0 2px;
  height: 18px;
  font-size: 9.5px;
}

.coupled-multi-badge {
  flex: 1;
  min-width: 36px;
  height: 20px;
  padding: 0 3px;
  font-size: 9.5px;
  font-weight: 600;
  color: #1d4ed8;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.coupled-multi-badge:hover {
  background-color: #dbeafe;
}

.action-btns-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

#trainsGridTable .action-cell .btn-icon {
  width: 14px;
  min-width: 0;
  padding: 0 1px;
  font-size: 9.5px;
  line-height: 1.25;
  height: 20px;
}

#trainsGridTable .action-cell .btn-icon.btn-icon-label {
  width: auto;
  min-width: 0;
  padding: 0 2px;
  font-size: 9.5px;
}

.btn-icon-clip-copy:hover:not(:disabled) {
  color: #1d4ed8;
  border-color: #93c5fd;
  background-color: #eff6ff;
}

.btn-icon-clip-cut:hover:not(:disabled) {
  color: #b45309;
  border-color: #fcd34d;
  background-color: #fffbeb;
}

.btn-icon-clip-paste {
  color: var(--primary-hover);
  border-color: #6ee7b7;
  background-color: #ecfdf5;
  font-weight: 600;
}

.btn-icon-clip-paste:hover:not(:disabled) {
  background-color: #d1fae5;
  border-color: var(--primary);
}

.sync-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sync-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  user-select: none;
}

.sync-toggle-label input {
  margin: 0;
  cursor: pointer;
}

.sync-status-badge {
  font-size: 11px;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 4px;
  padding: 2px 7px;
  font-weight: 600;
}

.roster-name-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.roster-name-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}

.roster-name-badge.is-auto {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.roster-name-badge.is-manual {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.roster-detail-row > td {
  background-color: #f8fafc;
  padding: 8px 10px !important;
  border-bottom: 1px solid #cbd5e1;
}

.roster-detail-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.roster-detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.roster-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
}

.roster-detail-preview {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.roster-detail-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.scale-control-card {
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 8px 10px;
  background-color: #f8fafc;
  margin-bottom: 8px;
}

.scale-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.scale-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scale-slider-row input[type="range"] {
  flex: 1;
  min-width: 100px;
  accent-color: var(--primary);
  cursor: pointer;
}

.scale-pct-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.scale-pct-input {
  width: 58px !important;
  text-align: right;
}

.scale-note-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 4px;
}

.editor-inline-alert {
  margin-top: 6px;
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 4px;
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.editor-floating-popover {
  position: fixed;
  z-index: 3000;
  min-width: 240px;
  max-width: 310px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
  padding: 10px;
  font-size: 12px;
  color: var(--text-main);
}

.editor-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-subtle);
}

.formation-preview-chip {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.formation-slot-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.formation-slot-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: #ffffff;
}

.formation-slot-item.is-self {
  background: #fef2f2;
  border-color: #fca5a5;
  font-weight: 700;
}

.formation-slot-label {
  flex: 1;
  font-size: 12px;
}

.formation-add-row {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
}

.editor-popover-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.split-station-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

/* ==========================================================================
   設定フォーム・グループ
   ========================================================================== */
.form-settings-container {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-width: 0;
  padding-right: 4px;
}

.settings-group {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 12px;
  min-width: 0;
}

.group-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.form-row {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.form-row-grid {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.form-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-col > .form-control,
.form-col > .form-select,
.form-row > .form-control,
.form-row > .form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.radio-group-horizontal {
  display: flex;
  gap: 16px;
  align-items: center;
}

.radio-label, .checkbox-simple {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
}

/* 部位別フォント・装飾詳細設定 */
.font-theme-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.font-theme-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 2px;
}

.font-roles-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.font-role-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-subtle);
}

.font-role-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.font-role-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
}

.font-role-sample {
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background-color: #ffffff;
  color: #0f172a;
  font-size: 11.5px;
  line-height: 1.35;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.font-role-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.font-family-select {
  flex: 1 1 150px;
  min-width: 130px;
  height: 26px;
  font-size: 11.5px;
  padding: 2px 6px;
}

.font-style-toggle-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  background-color: #ffffff;
}

.btn-style-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border: none;
  border-right: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.14s var(--ease-out-expo), color 0.14s var(--ease-out-expo);
}

.btn-style-mini:last-child {
  border-right: none;
}

.btn-style-mini.is-italic {
  font-style: italic;
  font-family: Georgia, serif;
}

.btn-style-mini.is-underline {
  text-decoration: underline;
}

.btn-style-mini.is-tabular {
  font-family: var(--font-mono);
  font-size: 10px;
}

.btn-style-mini:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.btn-style-mini.active {
  background-color: var(--primary);
  color: #ffffff;
}

.font-metric-field {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.font-metric-field .form-control {
  width: 50px;
  height: 26px;
  padding: 2px 4px;
  font-size: 11px;
  text-align: right;
}

.font-custom-family-row[hidden] {
  display: none !important;
}

.font-custom-input {
  height: 26px;
  font-size: 11.5px;
  padding: 2px 8px;
}

.note-font-cell {
  display: flex;
  align-items: center;
  gap: 3px;
}

.note-font-cell .btn-style-mini {
  border: 1px solid var(--border-color);
  border-radius: 3px;
  height: 22px;
  min-width: 22px;
}

/* ==========================================================================
   生JSONエディタ
   ========================================================================== */
.raw-json-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.json-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.json-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.5;
  outline: none;
}

.json-textarea:focus {
  border-color: var(--primary);
  background-color: var(--bg-surface);
}

.alert-box {
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.alert-warning {
  background-color: var(--warning-light);
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-danger {
  background-color: var(--danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
  white-space: pre-wrap;
}

/* ==========================================================================
   プレビューペイン & シート表示
   ========================================================================== */
.preview-toolbar {
  min-height: 40px;
  height: auto;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  padding: 4px 12px;
  flex-shrink: 0;
}

.preview-toolbar-primary,
.preview-toolbar-advanced {
  display: contents;
}

.export-menu-dropdown {
  position: fixed;
  z-index: 1200;
  min-width: 248px;
  max-width: min(300px, calc(100vw - 16px));
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-menu-dropdown[hidden] {
  display: none !important;
}

.export-menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-family: inherit;
  transition: background-color 0.12s ease;
}

.export-menu-item:hover {
  background-color: var(--primary-light);
}

.export-menu-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.export-menu-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.mobile-inapp-hint-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  background-color: #ecfdf5;
  border-bottom: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 11px;
  line-height: 1.3;
  flex-shrink: 0;
}

.mobile-inapp-hint-bar[hidden] {
  display: none !important;
}

.mobile-inapp-hint-text {
  min-width: 0;
}

.image-export-modal-dialog {
  max-width: 680px;
  width: min(94vw, 680px);
}

.image-export-preview-wrap {
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: #f1f5f9;
  padding: 8px;
  text-align: center;
}

.image-export-preview-img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  background: #ffffff;
}

.preview-controls-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 1px;
  gap: 1px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  height: 21px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.preview-quick-size {
  height: 24px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  width: auto;
}

.quick-separate-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  white-space: nowrap;
}

.quick-size-readout {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  white-space: nowrap;
}

.quick-custom-dim-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.quick-custom-dim-group[hidden],
.quick-size-readout[hidden] {
  display: none !important;
}

.quick-dim-input {
  width: 50px;
  height: 22px;
  padding: 0 4px;
  font-size: 11px;
  text-align: right;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.seg-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.layout-suggestion-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  background-color: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #78350f;
  font-size: 11.5px;
  flex-shrink: 0;
}

.layout-suggestion-bar[hidden] {
  display: none !important;
}

.layout-suggestion-msg {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.layout-suggestion-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  background-color: #d97706;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.layout-suggestion-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.preview-scroll-viewport {
  flex: 1;
  overflow: auto;
  display: block;
  text-align: center;
  padding: 24px;
  background-color: var(--bg-app);
  -webkit-overflow-scrolling: touch;
}

.preview-scroll-viewport.is-panning {
  cursor: grabbing !important;
  user-select: none !important;
}

.preview-page-wrapper {
  display: inline-block;
  margin: 0 auto 32px auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
  background-color: #ffffff;
  vertical-align: top;
  position: relative;
  text-align: left;
}

.preview-page-sheet {
  background-color: #ffffff;
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
}

.preview-page-sheet svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ドロップダウンメニュー */
.dropdown-inline {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  z-index: 50;
  margin-top: 4px;
  padding: 4px 0;
}

.dropdown-item {
  display: block;
  padding: 8px 12px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 12px;
}

.dropdown-item:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

/* ユーティリティ */
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   使い方・ヘルプ モーダルダイアログ
   ========================================================================== */
.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-dialog {
  width: min(880px, 100%);
  max-height: min(86vh, 820px);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.modal-close-btn {
  width: 28px;
  height: 28px;
  font-size: 14px;
  flex-shrink: 0;
}

.modal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.help-nav-btn {
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.help-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.help-nav-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
  line-height: 1.65;
}

.help-section + .help-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.help-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.help-section h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  margin: 12px 0 6px;
}

.help-section code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
}

.help-section kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-main);
}

.help-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.help-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-subtle);
}

.step-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.help-step p {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.help-note-box {
  margin-top: 12px;
  padding: 9px 12px;
  border-left: 3px solid var(--primary);
  background-color: var(--primary-light);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.help-table th,
.help-table td {
  border: 1px solid var(--border-subtle);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.help-table th {
  background-color: var(--bg-subtle);
  font-weight: 600;
}

.help-table.compact td {
  padding: 5px 8px;
}

.help-list {
  margin-left: 18px;
  font-size: 12.5px;
}

.help-list li + li {
  margin-top: 5px;
}

.help-sublist {
  margin: 4px 0 2px 18px;
  font-size: 12px;
  color: var(--text-main);
}

.help-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.help-card {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px 14px;
  background-color: var(--bg-subtle);
}

.help-card h4 {
  margin-top: 0;
}

.help-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.help-support-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-subtle);
}

.help-support-box h4 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--text-main);
}

.help-support-box p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

.help-support-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 20px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
}

.modal-header-actions,
.modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.feedback-modal-dialog {
  width: min(760px, 100%);
  height: min(88vh, 820px);
  max-height: min(88vh, 820px);
}

.feedback-modal-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: #eaf1f1;
}

.feedback-loading {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}

.feedback-loading[hidden] {
  display: none;
}

.feedback-iframe {
  width: 100%;
  flex: 1;
  min-height: 360px;
  border: 0;
  display: block;
}

/* ==========================================================================
   OuDia / OuDiaSecond インポート設定モーダル
   ========================================================================== */
.oud-modal-dialog {
  width: min(760px, 100%);
  max-height: min(88vh, 800px);
}

.oud-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.oud-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.oud-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.oud-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.oud-checkbox-stack {
  justify-content: center;
  gap: 6px;
  padding-top: 12px;
}

.oud-summary-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.oud-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.oud-summary-item.oud-summary-wide {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 6px;
  margin-top: 2px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.oud-summary-label {
  font-size: 11px;
  color: var(--text-muted);
}

.oud-summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.oud-summary-source {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
}

.oud-warnings-list {
  margin: 0;
  padding: 8px 12px 8px 26px;
  border-left: 3px solid var(--warning);
  background-color: var(--warning-light);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #92400e;
}

.oud-warnings-list[hidden] {
  display: none;
}

.oud-stations-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.oud-stations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.oud-stations-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

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

.oud-station-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-subtle);
}

.oud-station-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  cursor: pointer;
}

.oud-station-item:hover {
  border-color: var(--primary);
}

.oud-station-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.oud-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 3px;
  flex-shrink: 0;
}

.oud-tag-major {
  background-color: var(--primary-light);
  color: var(--primary);
}

.oud-tag-end {
  background-color: #e2e8f0;
  color: #334155;
}

/* ==========================================================================
   見本案内バー / 空列車ガイド / 新規ダイヤ作成モーダル
   ========================================================================== */
.welcome-sample-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  background-color: #f0fdfa;
  border-bottom: 1px solid #99f6e4;
  color: #134e4a;
  font-size: 11.5px;
  flex-shrink: 0;
}

.welcome-sample-bar[hidden] {
  display: none !important;
}

.welcome-sample-msg {
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.4;
}

.welcome-sample-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  background-color: var(--primary);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.welcome-sample-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.empty-trains-guide {
  margin: 18px 8px 8px;
  padding: 18px 16px;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-subtle);
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.new-diagram-modal-dialog {
  width: min(680px, 100%);
  max-height: min(88vh, 780px);
}

.new-diagram-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.new-form-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 12px;
}

.new-form-options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.new-stations-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.new-stations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-subtle);
}

.new-station-row {
  display: grid;
  grid-template-columns: 28px 1fr 78px 66px 28px;
  align-items: center;
  gap: 6px;
}

.new-station-idx {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.new-station-move-btns {
  display: flex;
  gap: 2px;
  justify-content: center;
}

/* ==========================================================================
   複数選択・ポインターD&D並替・クリップボードバー・移動ポケット
   ========================================================================== */
.ui-ico {
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
}

.ui-dot-primary {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary);
  flex-shrink: 0;
}

.row-order-col {
  text-align: center;
  padding: 1px 2px !important;
}

.row-order-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

.row-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 20px;
  color: #94a3b8;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border-radius: 3px;
  flex-shrink: 0;
  transition: color 0.14s var(--ease-out-expo), background-color 0.14s var(--ease-out-expo);
}

.row-drag-handle:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

.row-drag-handle:active {
  cursor: grabbing;
  color: var(--primary-active);
}

.row-select-col {
  padding: 0 !important;
  text-align: center;
}

.th-select-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  padding: 2px 0;
  cursor: pointer;
  line-height: 1;
}

.th-select-text {
  font-size: 8.5px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0;
}

.row-select-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 24px;
  cursor: pointer;
}

.row-select-check {
  margin: 0;
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
  transition: transform 0.18s var(--ease-spring);
}

.row-select-check:checked {
  animation: yuiCheckPop 0.22s var(--ease-spring);
}

.row-index-num {
  min-width: 11px;
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.station-drag-cell {
  text-align: center;
  padding: 1px 2px !important;
}

.grid-table tbody tr.row-selected > td {
  background-color: var(--primary-light) !important;
}

.grid-table tbody tr.row-selected > td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

.grid-table tbody tr.row-clip-copy > td {
  background-color: #eff6ff !important;
}

.grid-table tbody tr.row-clip-copy > td:first-child {
  box-shadow: inset 3px 0 0 #2563eb;
}

.grid-table tbody tr.row-clip-cut > td {
  background-color: #fffbeb !important;
  color: #78350f;
}

.grid-table tbody tr.row-clip-cut > td:first-child {
  box-shadow: inset 3px 0 0 #d97706;
}

.grid-table tbody tr.is-dragging-source > td {
  opacity: 0.35;
  background-color: #f1f5f9 !important;
}

.grid-table tbody tr.drag-insert-before > td {
  box-shadow: inset 0 2px 0 var(--primary);
}

.grid-table tbody tr.drag-insert-after > td {
  box-shadow: inset 0 -2px 0 var(--primary);
}

.grid-table tbody tr.drag-roster-target > td {
  background-color: var(--primary-light) !important;
  box-shadow: inset 0 2px 0 var(--primary), inset 0 -2px 0 var(--primary);
}

.roster-active-badge {
  display: inline-block;
  margin-left: 3px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--primary-light);
  color: var(--primary-active);
  border: 1px solid rgba(47, 111, 115, 0.24);
  font-size: 9px;
  font-weight: 700;
}

/* 複数選択アクションバー */
.selection-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 9px;
  margin-bottom: 6px;
  border-radius: 6px;
  border: 1px solid rgba(47, 111, 115, 0.28);
  background-color: var(--primary-light);
  flex-shrink: 0;
}

.selection-action-bar.anim-enter {
  animation: yuiSelectionBarIn 0.24s var(--ease-out-expo) both;
}

.selection-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-active);
  white-space: nowrap;
}

.selection-actions-btns {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.selection-actions-btns .btn,
.clipboard-bar-actions .btn,
.pocket-card-actions .btn,
.empty-trains-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.empty-trains-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* 下部常設クリップボードステータスバー */
.editor-clipboard-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  flex-shrink: 0;
  min-height: 36px;
  transition: background-color 0.2s var(--ease-out-expo), border-color 0.2s var(--ease-out-expo);
}

.editor-clipboard-bar.is-copy {
  background-color: #f4f8fc;
  border-top-color: #bfdbfe;
}

.editor-clipboard-bar.is-cut {
  background-color: #fefaf0;
  border-top-color: #fde68a;
}

.editor-clipboard-bar.anim-clip-arm {
  animation: yuiClipArm 0.36s var(--ease-out-expo);
}

.clipboard-bar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.clipboard-kind-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.clipboard-kind-pill.is-copy {
  background-color: #dbeafe;
  color: #1e40af;
}

.clipboard-kind-pill.is-cut {
  background-color: #fef3c7;
  color: #92400e;
}

.clipboard-kind-pill.is-empty {
  background-color: #e2e8f0;
  color: #475569;
}

.clipboard-detail-text {
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}

.clipboard-bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-pocket-toggle.has-items {
  border-color: var(--primary);
  color: var(--primary-active);
  background-color: var(--primary-light);
  font-weight: 700;
}

.pocket-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 2px;
  border-radius: 999px;
  background-color: var(--primary);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 自由移動式「移動ポケット」フローティングパネル（背後画面操作可能） */
.floating-pocket {
  position: fixed;
  z-index: 1200;
  width: 348px;
  max-width: calc(100vw - 16px);
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 16px 36px -12px rgba(15, 23, 42, 0.24), 0 0 0 1px rgba(15, 23, 42, 0.05);
  overflow: hidden;
  transition: border-color 0.16s var(--ease-out-expo), box-shadow 0.16s var(--ease-out-expo);
}

.floating-pocket[hidden] {
  display: none !important;
}

.floating-pocket.anim-open {
  animation: yuiPocketEnter 0.24s var(--ease-out-expo) both;
}

.floating-pocket.is-minimized {
  width: auto;
  min-width: 204px;
  max-height: none;
}

.floating-pocket.is-drop-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.22), 0 16px 36px -12px rgba(15, 23, 42, 0.28);
}

.pocket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 10px;
  background-color: var(--primary);
  color: #ffffff;
  cursor: grab;
  user-select: none;
  touch-action: none;
  flex-shrink: 0;
}

.pocket-header:active {
  cursor: grabbing;
}

.pocket-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  min-width: 0;
}

.pocket-hdr-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pocket-header-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pocket-hdr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  transition: background-color 0.14s var(--ease-out-expo);
}

.pocket-hdr-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.pocket-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 10px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 10.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.pocket-mode-pills {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff;
}

.pocket-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  padding: 2px 8px;
  font-size: 10.5px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.14s var(--ease-out-expo), color 0.14s var(--ease-out-expo);
}

.pocket-mode-btn.active.is-cut {
  background-color: #fef3c7;
  color: #92400e;
}

.pocket-mode-btn.active.is-copy {
  background-color: #dbeafe;
  color: #1e40af;
}

.pocket-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 86px;
  background-color: #fcfdfd;
}

.pocket-empty-state {
  border: 1.5px dashed #cbd5e1;
  border-radius: 6px;
  padding: 14px 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.55;
  background-color: var(--bg-subtle);
  transition: border-color 0.16s var(--ease-out-expo), background-color 0.16s var(--ease-out-expo), color 0.16s var(--ease-out-expo);
}

.floating-pocket.is-drop-active .pocket-empty-state {
  border-color: var(--primary);
  background-color: var(--primary-light);
  color: var(--primary-active);
}

.pocket-item-card {
  position: relative;
  border: 1px solid var(--border-color);
  border-left-width: 3px;
  border-radius: 6px;
  padding: 6px 8px;
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.14s var(--ease-out-expo), border-color 0.14s var(--ease-out-expo);
}

.pocket-item-card.anim-card-in {
  animation: yuiPocketCardIn 0.24s var(--ease-spring) both;
}

.pocket-item-card.is-cut {
  border-left-color: #d97706;
  background-color: #fffdf7;
}

.pocket-item-card.is-copy {
  border-left-color: #2563eb;
  background-color: #f8fbff;
}

.pocket-item-card.is-dragging-source {
  opacity: 0.35;
}

.pocket-item-card.drag-insert-before {
  box-shadow: inset 0 2px 0 var(--primary);
}

.pocket-item-card.drag-insert-after {
  box-shadow: inset 0 -2px 0 var(--primary);
}

.pocket-card-top {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}

.pocket-card-drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 20px;
  color: #94a3b8;
  cursor: grab;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
}

.pocket-card-drag:hover {
  color: var(--primary);
}

.pocket-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.pocket-badge.is-cut {
  background-color: #fef3c7;
  color: #92400e;
}

.pocket-badge.is-copy {
  background-color: #dbeafe;
  color: #1e40af;
}

.pocket-card-origin {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.pocket-card-main {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  padding-left: 19px;
  margin-bottom: 5px;
  word-break: break-word;
}

.pocket-card-sub {
  font-weight: 500;
  font-size: 11px;
  color: var(--text-muted);
}

.pocket-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
}

.pocket-card-move-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: auto;
}

.btn-pocket-move {
  padding: 0 5px !important;
  min-width: 22px;
  height: 20px;
  justify-content: center;
}

.pocket-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 10px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
  flex-shrink: 0;
}

.pocket-footer-left,
.pocket-footer-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ドラッグ中のフローティングゴースト */
.drag-ghost-pill {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.3);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   モバイル・タブレット狭幅対応 (900px以下)
   ========================================================================== */
.mobile-workspace-nav {
  display: none;
}

@media (max-width: 900px) {
  .app-header {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 5px 8px;
    gap: 0;
  }

  .brand {
    justify-content: space-between;
    gap: 6px;
    min-height: 32px;
  }

  .brand-main {
    gap: 6px;
    min-width: 0;
    overflow: hidden;
  }

  .brand-title {
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-header-quick {
    display: flex;
  }

  .btn.mobile-only-btn,
  .mobile-only-btn {
    display: inline-flex;
  }

  .header-actions {
    display: none;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
    padding-top: 6px;
    margin-top: 5px;
    border-top: 1px solid var(--border-color);
  }

  body[data-mobile-menu="open"] .header-actions {
    display: flex;
  }

  .preset-select-control {
    flex: 1 1 100%;
    width: 100%;
  }

  .history-group {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
  }

  .mobile-workspace-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px 8px;
    background-color: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
  }

  .mobile-nav-btn {
    height: 27px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--bg-surface);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s ease;
  }

  .mobile-nav-btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
  }

  .main-workspace {
    min-height: 0;
  }

  .workspace-splitter {
    display: none;
  }

  body[data-mobile-view="preview"] .editor-pane {
    display: none;
  }

  body[data-mobile-view="preview"] .preview-pane {
    display: flex;
    width: 100%;
    min-width: 0;
  }

  body[data-mobile-view="editor"] .preview-pane {
    display: none;
  }

  body[data-mobile-view="editor"] .editor-pane {
    display: flex;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    border-right: none;
  }

  .preview-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 4px 8px;
    gap: 5px;
  }

  .preview-toolbar-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: nowrap;
    width: 100%;
  }

  .preview-toolbar-primary .preview-lbl-axis,
  .preview-toolbar-primary .preview-lbl-page {
    display: none;
  }

  .preview-toolbar-advanced {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 8px;
    padding-top: 5px;
    border-top: 1px dashed var(--border-color);
  }

  body[data-mobile-preview-tools="open"] .preview-toolbar-advanced {
    display: flex;
  }

  .preview-controls-group {
    flex-wrap: wrap;
    gap: 3px;
  }

  .welcome-sample-bar,
  .layout-suggestion-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    gap: 4px 8px;
    font-size: 11px;
  }

  .preview-scroll-viewport {
    padding: 10px 8px;
  }

  .editor-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .editor-body {
    padding: 8px;
  }

  .tab-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .table-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #trainsGridTable {
    table-layout: auto;
    min-width: 820px;
  }

  #trainsGridTable thead th,
  #trainsGridTable tbody td {
    padding: 3px 3px;
    overflow: visible;
  }

  #trainsGridTable .action-cell .btn-icon {
    width: 20px;
    height: 22px;
    font-size: 10.5px;
  }

  #trainsGridTable .action-cell .btn-icon.btn-icon-label {
    padding: 0 4px;
    font-size: 10px;
  }

  #rostersGridTable {
    min-width: 600px;
  }

  #notesGridTable {
    min-width: 620px;
  }

  .row-drag-handle {
    width: 20px;
    height: 28px;
  }

  .row-select-hit {
    height: 28px;
  }

  .row-select-check {
    width: 15px;
    height: 15px;
  }

  .editor-clipboard-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
    gap: 5px;
  }

  .clipboard-bar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  body.has-mobile-pocket-open .table-scroll-container {
    padding-bottom: 44vh;
  }

  .floating-pocket {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    border-radius: 14px 14px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.06);
  }

  .floating-pocket:not(.is-minimized) {
    max-height: 44vh;
  }

  .floating-pocket.anim-open:not(.is-minimized) {
    animation: yuiSheetUp 0.26s var(--ease-out-expo) both;
  }

  .floating-pocket.is-minimized {
    left: auto !important;
    right: 10px !important;
    bottom: 8px !important;
    width: auto !important;
    min-width: 184px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
  }

  .pocket-header {
    padding: 8px 12px;
    cursor: default;
  }

  .pocket-hdr-btn {
    min-width: 30px;
    height: 26px;
  }

  .pocket-card-actions .btn-pocket-move {
    min-width: 28px;
    height: 26px;
  }

  .form-row-grid {
    flex-direction: column;
    gap: 8px;
  }
}

/* ==========================================================================
   トグルスイッチ・基本設定カード・利用規約モーダル・トースト
   ========================================================================== */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.toggle-switch-sm {
  font-size: 11.5px;
  gap: 6px;
  white-space: nowrap;
}

.toggle-input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background-color: #cbd5e1;
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background-color 0.22s var(--ease-out-expo),
              border-color 0.22s var(--ease-out-expo),
              box-shadow 0.22s var(--ease-out-expo);
}

.toggle-input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.24);
  transition: transform 0.26s var(--ease-spring);
}

.toggle-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.toggle-input:checked::before {
  transform: translateX(16px);
}

.toggle-input.toggle-sm {
  width: 30px;
  height: 16px;
}

.toggle-input.toggle-sm::before {
  width: 10px;
  height: 10px;
  top: 2px;
  left: 2px;
}

.toggle-input.toggle-sm:checked::before {
  transform: translateX(14px);
}

.toggle-input:hover:not(:disabled) {
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.14);
}

.toggle-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.toggle-input:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.setting-toggles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.setting-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-subtle);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.18s var(--ease-out-expo),
              background-color 0.18s var(--ease-out-expo),
              transform 0.18s var(--ease-out-expo);
}

.setting-toggle-card:hover {
  border-color: var(--border-color);
  background-color: var(--bg-hover);
}

.setting-toggle-card:has(.toggle-input:checked) {
  border-color: rgba(47, 111, 115, 0.35);
  background-color: rgba(237, 245, 245, 0.65);
}

.setting-toggle-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.35;
}

.settings-subpanel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
}

.inline-input-with-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-input-with-btn > .form-control {
  flex: 1;
  min-width: 0;
}

.inline-input-with-btn > .btn {
  flex-shrink: 0;
}

/* 利用規約モーダル */
.terms-modal-dialog {
  width: min(720px, 100%);
}

.terms-modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-main);
}

.terms-section h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary-active);
  margin-bottom: 6px;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
}

.terms-credit-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  background-color: var(--primary-light);
  border: 1px solid rgba(47, 111, 115, 0.25);
  border-radius: 6px;
  font-size: 12px;
}

.terms-credit-examples {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.terms-credit-examples code {
  word-break: break-all;
}

/* トースト通知 */
.app-toast[hidden] {
  display: none !important;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 1200;
  background-color: #1e293b;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.22s var(--ease-out-expo),
              transform 0.26s var(--ease-out-expo);
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   モーション演出（yui540流の軽快で邪魔にならない transform / opacity 設計）
   ========================================================================== */
@keyframes yuiPanelEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes yuiBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes yuiDialogIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes yuiBannerIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes yuiRowFlash {
  0% {
    background-color: rgba(47, 111, 115, 0.28);
    box-shadow: inset 3px 0 0 var(--primary);
  }
  100% {
    background-color: transparent;
    box-shadow: inset 3px 0 0 transparent;
  }
}

@keyframes yuiSelectionBarIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes yuiCheckPop {
  0% {
    transform: scale(0.84);
  }
  60% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes yuiPocketEnter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes yuiSheetUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes yuiPocketCardIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes yuiClipArm {
  0% {
    box-shadow: inset 0 2px 0 var(--primary);
  }
  100% {
    box-shadow: inset 0 0 0 transparent;
  }
}

.editor-body.anim-panel-enter {
  animation: yuiPanelEnter 0.22s var(--ease-out-expo) both;
}

.modal-backdrop:not([hidden]) {
  animation: yuiBackdropIn 0.18s var(--ease-out-expo) both;
}

.modal-backdrop:not([hidden]) .modal-dialog {
  animation: yuiDialogIn 0.24s var(--ease-out-expo) both;
}

.welcome-sample-bar:not([hidden]),
.layout-suggestion-bar:not([hidden]) {
  animation: yuiBannerIn 0.22s var(--ease-out-expo) both;
}

tr.row-jump-flash > td {
  animation: yuiRowFlash 1.4s var(--ease-out-expo);
}

.btn,
.btn-seg,
.btn-icon,
.editor-tab-btn,
.roster-pill {
  transition-timing-function: var(--ease-out-expo);
}

.btn:active:not(:disabled),
.btn-seg:active:not(:disabled),
.btn-icon:active:not(:disabled) {
  transform: scale(0.97);
}

/* アプリ内ブラウザ印刷フォールバックバナー */
.inapp-print-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background-color: #1e293b;
  color: #f8fafc;
  font-size: 11.5px;
  line-height: 1.45;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.inapp-print-banner[hidden] {
  display: none !important;
}

.inapp-print-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .editor-body.anim-panel-enter,
  .modal-backdrop:not([hidden]),
  .modal-backdrop:not([hidden]) .modal-dialog,
  .welcome-sample-bar:not([hidden]),
  .layout-suggestion-bar:not([hidden]),
  tr.row-jump-flash > td,
  .selection-action-bar.anim-enter,
  .row-select-check:checked,
  .floating-pocket.anim-open,
  .pocket-item-card.anim-card-in,
  .editor-clipboard-bar.anim-clip-arm {
    animation: none !important;
  }
  .toggle-input,
  .toggle-input::before,
  .setting-toggle-card,
  .app-toast,
  .row-drag-handle,
  .row-select-check,
  .floating-pocket,
  .pocket-item-card,
  .editor-clipboard-bar {
    transition: none !important;
  }
}

@media (max-width: 720px) {
  .portal-back-link {
    display: none;
  }
  .help-steps,
  .help-columns,
  .oud-options-grid,
  .new-form-grid,
  .new-form-options-grid,
  .setting-toggles-grid {
    grid-template-columns: 1fr;
  }
  .new-station-row {
    grid-template-columns: 24px 1fr 64px 56px 26px;
  }
  .oud-summary-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .terms-credit-box,
  .inline-input-with-btn {
    flex-direction: column;
    align-items: stretch;
  }
  .roster-detail-row > td {
    padding: 6px !important;
  }
  .roster-detail-panel {
    grid-template-columns: 1fr;
    position: sticky;
    left: 6px;
    width: calc(100vw - 44px);
    max-width: calc(100vw - 44px);
    box-sizing: border-box;
  }
  .form-row-grid {
    flex-direction: column;
    gap: 8px;
  }
}

/* ==========================================================================
   印刷スタイル (@media print) - 1:1 ベクターPDF出力
   ========================================================================== */
@media print {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }

  html, body {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .app-header,
  .mobile-workspace-nav,
  .mobile-inapp-hint-bar,
  .export-menu-dropdown,
  body[data-mobile-view="preview"] .editor-pane,
  body[data-mobile-view="editor"] .editor-pane,
  .editor-pane,
  .workspace-splitter,
  .preview-toolbar,
  .welcome-sample-bar,
  .layout-suggestion-bar,
  .modal-backdrop,
  .app-toast,
  .inapp-print-banner,
  .selection-action-bar,
  .editor-clipboard-bar,
  .floating-pocket,
  .drag-ghost-pill {
    display: none !important;
  }

  .main-workspace,
  body[data-mobile-view="editor"] .preview-pane,
  body[data-mobile-view="preview"] .preview-pane,
  .preview-pane,
  .preview-scroll-viewport {
    display: block !important;
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  .preview-page-wrapper {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    overflow: hidden !important;
  }

  .preview-page-wrapper:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .preview-page-sheet {
    position: static !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    display: block !important;
  }

  .preview-page-sheet svg {
    width: 100% !important;
    height: auto !important;
    max-height: 99.6vh !important;
    display: block !important;
  }
}
