:root {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;
  --accent: #1e3a5f;
  --accent-hover: #162d4a;
  --accent-soft: #eff4f9;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* アプリ全体 */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ヘッダー */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 54px;
  padding: 0 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #ffffff;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

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

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

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 通知バナー */
.notice-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid var(--warn-border);
  font-size: 13px;
  flex-shrink: 0;
}

.notice-banner code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(180, 83, 9, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ボタン共通 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

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

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
  height: 38px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

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

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
}

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

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-sub);
  cursor: pointer;
}

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

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

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ワークスペース 3ペイン（スレッド一覧 / チャット / プレビュー） */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-toggle-btn {
  width: 32px;
  height: 32px;
  border-color: var(--border);
  border-radius: var(--radius-md);
}

.thread-sidebar {
  width: 224px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.thread-sidebar.collapsed {
  display: none;
}

.sidebar-top {
  padding: 10px 10px 8px;
  flex-shrink: 0;
}

.new-thread-btn {
  width: 100%;
  justify-content: flex-start;
  height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

.sidebar-section-label {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thread-list-empty {
  padding: 12px 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.thread-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 8px 66px 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.thread-group-label {
  padding: 8px 8px 3px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.thread-group-label:first-child {
  padding-top: 2px;
}

.thread-actions {
  position: absolute;
  top: 6px;
  right: 5px;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.thread-item:hover .thread-actions,
.thread-item.active .thread-actions,
.thread-item.pinned .thread-actions {
  opacity: 1;
}

.thread-action-btn {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.thread-action-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.thread-action-btn.pin-active {
  color: var(--accent);
}

.thread-action-btn.delete-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.thread-item.pinned:not(:hover):not(.active) .thread-action-btn:not(.pin-active) {
  opacity: 0;
  pointer-events: none;
}

.thread-rename-input {
  width: 100%;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  outline: none;
}

.thread-item:hover {
  background: var(--bg-subtle);
}

.thread-item.active {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.thread-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-item.active .thread-item-title {
  color: var(--accent);
}

.thread-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.thread-ver-tag {
  padding: 0 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

.thread-delete-btn {
  position: absolute;
  top: 7px;
  right: 6px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
}

.thread-item:hover .thread-delete-btn,
.thread-item.active .thread-delete-btn {
  opacity: 1;
}

.thread-delete-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 280px;
  min-height: 0;
  background: var(--bg-surface);
}

.pane-chat {
  position: relative;
  width: 36%;
  min-width: 320px;
  max-width: 58%;
  border-right: 1px solid var(--border);
}

/* D&Dオーバーレイ */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(239, 244, 249, 0.94);
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
}

.drop-overlay-box {
  width: 100%;
  height: 100%;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--accent);
  text-align: center;
  padding: 20px;
}

.drop-overlay-title {
  font-size: 15px;
  font-weight: 700;
}

.drop-overlay-sub {
  font-size: 12.5px;
  color: var(--text-sub);
}

.pane-preview {
  flex: 1;
  min-width: 380px;
  background: var(--bg-page);
}

.resizer {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  margin-left: -2px;
  margin-right: -3px;
  z-index: 10;
  position: relative;
}

.resizer:hover,
.resizer.dragging {
  background: rgba(30, 58, 95, 0.2);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pane-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.meta-pill {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

/* チャット領域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.welcome-guide {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-lead {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-sub);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.section-caption {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.starter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.starter-card {
  text-align: left;
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.starter-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.starter-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 3px;
}

.starter-desc {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.45;
}

/* メッセージバブル */
.msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-sub);
}

.msg-role-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.msg-error .msg-role,
.msg-error .msg-role-icon {
  color: var(--danger);
}

.msg-user {
  align-items: flex-end;
}

.msg-user .msg-role {
  flex-direction: row-reverse;
}

.msg-user .msg-body {
  background: #dce6f2;
  color: var(--text-main);
  border: 1px solid #bfd1e5;
  padding: 10px 13px;
  border-radius: 12px 4px 12px 12px;
  max-width: 75%;
  width: fit-content;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.msg-attach-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.msg-attach-chip.static {
  cursor: default;
}

.msg-attach-chip.static:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.msg-attach-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-assistant .msg-body {
  background: #fcfdff;
  color: var(--text-main);
  border: 1px solid #eef2f6;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
}

.msg-error .msg-body {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 10px 13px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

.version-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 8px 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.version-pill-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.version-pill-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.stream-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

/* 改造ヒントチップ（入力欄の上部・1行固定＋右側フェード横スクロール） */
.refinement-bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
  overflow: hidden;
}

.refinement-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.refinement-chips {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding-right: 18px;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  -webkit-mask-image: linear-gradient(to right, #000 86%, transparent 100%);
  mask-image: linear-gradient(to right, #000 86%, transparent 100%);
}

.refinement-chips.dragging {
  cursor: grabbing;
}

.refinement-chips.dragging .chip {
  cursor: grabbing;
}

.refinement-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 3px 9px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-sub);
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* 入力フォーム */
.chat-composer {
  padding: 10px 14px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.composer-box {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg-surface);
  padding: 10px 10px 8px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.1);
}

.prompt-input {
  width: 100%;
  resize: none;
  min-height: 52px;
  max-height: 180px;
  padding: 2px 4px 6px;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-main);
  background: transparent;
}

.prompt-input:focus {
  outline: none;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-select {
  height: 26px;
  padding: 0 22px 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background-color: var(--bg-page);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  color: var(--text-sub);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.model-select:hover,
.model-select:focus {
  outline: none;
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--accent-soft);
}

.circle-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
}

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

.circle-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.circle-icon-btn.recording {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.send-circle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.12s ease, opacity 0.12s ease;
  flex-shrink: 0;
}

.send-circle-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-circle-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stop-circle-btn {
  background: var(--danger);
}

.stop-circle-btn:hover:not(:disabled) {
  background: #991b1b;
}

/* 添付トレイ・入力ツール */
.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 7px;
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text-main);
}

.attach-chip-img {
  padding: 3px 6px 3px 3px;
}

.attach-thumb {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.attach-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.attach-remove:hover {
  color: var(--danger);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

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

.tool-btn.recording {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-thumb {
  max-width: 150px;
  max-height: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  object-fit: cover;
}

.input-methods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.method-item {
  padding: 11px 12px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.method-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 3px;
}

.method-desc {
  font-size: 11.5px;
  color: var(--text-sub);
  line-height: 1.45;
}

/* データ管理モーダル拡張 */
.data-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

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

.sample-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.paste-data-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}

.paste-panel-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-sm {
  height: 32px;
  font-size: 13px;
  flex: 1;
  min-width: 180px;
}

.select-input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-main);
}

.paste-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
}

.paste-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dataset-empty-notice {
  padding: 24px 18px;
  background: var(--bg-page);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-sub);
  font-size: 13px;
  text-align: center;
}

.dataset-viewer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.dataset-text-preview {
  flex: 1;
  min-height: 200px;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  gap: 8px;
}

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

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* プレビュー領域 */
.preview-toolbar {
  flex-wrap: wrap;
  height: auto;
  min-height: 44px;
  padding: 6px 14px;
}

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

.version-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.version-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
  text-align: center;
}

.segmented {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.seg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ファイルビュー */
.files-view {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-surface);
}

.files-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.files-paste-panel {
  margin: 12px 14px 0;
  flex-shrink: 0;
}

.files-empty-notice {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.files-split {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.files-list {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-page);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.file-row:hover {
  background: var(--bg-subtle);
}

.file-row.active {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.file-row-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.file-row-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.file-row-info {
  min-width: 0;
  flex: 1;
}

.file-row-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.files-detail {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  gap: 10px;
}

.files-detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.files-meta-text {
  font-size: 12px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.file-image-preview-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.file-image-preview {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  object-fit: contain;
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.preview-empty {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--bg-page);
  display: grid;
  place-items: center;
  padding: 28px;
}

.empty-app-icon {
  color: #cbd5e1;
  opacity: 0.7;
  user-select: none;
}

.empty-card {
  max-width: 580px;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.empty-kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.empty-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.empty-desc {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-sub);
}

.dataset-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dataset-mini-card {
  padding: 12px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

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

.dataset-mini-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.empty-actions {
  display: flex;
  gap: 10px;
}

.preview-frame-host {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #ffffff;
}

.preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.preview-loading {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.85);
  display: grid;
  place-items: center;
  z-index: 20;
  transition: background-color 0.2s ease;
}

.preview-loading.over-code {
  background: rgba(15, 23, 42, 0.35);
}

.loading-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px 28px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.loading-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 10px;
}

.loading-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.8s linear infinite;
}

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

/* コードビュー */
.code-view {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0f172a;
  color: #e2e8f0;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.code-stats {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #94a3b8;
}

.code-pre {
  flex: 1;
  margin: 0;
  padding: 16px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
  color: #d4d4d4;
  background: #1e1e1e;
  tab-size: 2;
}

/* スタンダードなエディタ配色（VS Code Dark+ 準拠） */
.hl-comment { color: #6a9955; }
.hl-punct { color: #808080; }
.hl-tag { color: #569cd6; }
.hl-attr { color: #9cdcfe; }
.hl-string { color: #ce9178; }
.hl-keyword { color: #c586c0; }
.hl-decl { color: #569cd6; }
.hl-number { color: #b5cea8; }
.hl-fn { color: #dcdcaa; }
.hl-prop { color: #9cdcfe; }
.hl-selector { color: #d7ba7d; }
.hl-patch-marker { color: #4fc1ff; font-weight: 700; }
.hl-patch-del { background: rgba(248, 81, 73, 0.14); display: inline-block; width: 100%; }
.hl-patch-add { background: rgba(63, 185, 80, 0.14); display: inline-block; width: 100%; }

.verify-btn {
  position: relative;
}

.verify-btn.running {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.error-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  flex-shrink: 0;
}

.verify-log {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-sub);
}

.verify-step-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.verify-step-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.verify-step-tag.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.verify-step-tag.err {
  color: var(--danger);
  background: var(--danger-bg);
}

.verify-shot-thumb {
  margin-top: 6px;
  max-width: 240px;
  max-height: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  object-fit: cover;
  display: block;
}

.verify-result-box {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 12.5px;
}

.verify-result-box.failed {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}

.verify-result-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.verify-issues-list {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--text-main);
  font-size: 12px;
}

.code-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #93c5fd;
  font-size: 12px;
  font-weight: 600;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* モーダル */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-large {
  max-width: 1040px;
  height: 82vh;
}

.modal-narrow {
  max-width: 400px;
}

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

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.data-modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dataset-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dataset-tab {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.dataset-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.data-upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-label {
  cursor: pointer;
}

.dataset-meta-bar {
  font-size: 12px;
  color: var(--text-sub);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-variant-numeric: tabular-nums;
}

.data-table-wrap {
  flex: 1;
  min-height: 200px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

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

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  color: var(--text-main);
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: var(--bg-page);
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.text-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.12);
}

.field-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
}

.modal-footer-actions {
  margin-top: 6px;
}

@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
  }
  .thread-sidebar {
    width: 100%;
    max-height: 150px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .pane-chat {
    width: 100%;
    max-width: none;
    height: 46%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .resizer {
    display: none;
  }
  .brand-sub {
    display: none;
  }
}
