/* =============================================
   DentalAI — メインスタイルシート
   シンプル・フラット・Gemini系レイアウト
   ============================================= */

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

:root {
  /* ブランドカラー */
  --blue:        #1a73e8;
  --blue-hover:  #1557b0;
  --blue-light:  #e8f0fe;
  --blue-mid:    #aecbfa;

  /* ニュートラル */
  --gray-50:  #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-300: #dadce0;
  --gray-400: #bdc1c6;
  --gray-500: #9aa0a6;
  --gray-600: #80868b;
  --gray-700: #5f6368;
  --gray-800: #3c4043;
  --gray-900: #202124;

  /* テキスト */
  --text-main:    #202124;
  --text-sub:     #5f6368;
  --text-muted:   #9aa0a6;
  --text-link:    #1a73e8;

  /* 境界線 */
  --border:       #e8eaed;
  --border-focus: #1a73e8;

  /* ロールカラー */
  --role-hr:      #6366f1;
  --role-hr-bg:   #eef2ff;
  --role-fin:     #0ea5e9;
  --role-fin-bg:  #e0f2fe;
  --role-mgmt:    #10b981;
  --role-mgmt-bg: #d1fae5;
  --role-mkt:     #f59e0b;
  --role-mkt-bg:  #fef3c7;
  --role-gen:     #8b5cf6;
  --role-gen-bg:  #ede9fe;

  /* ステータス */
  --green:       #137333;
  --green-bg:    #e6f4ea;
  --red:         #d93025;
  --red-bg:      #fce8e6;

  /* レイアウト */
  --sidebar-w:   240px;
  --header-h:    64px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --shadow-1:    0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2:    0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --shadow-3:    0 4px 8px rgba(60,64,67,.3), 0 6px 12px rgba(60,64,67,.15);
  --trans:       0.18s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* =============================================
   APP SHELL
   ============================================= */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 0 0 16px;
}

.sidebar-logo-area {
  padding: 16px 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--blue);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-mark svg { width: 18px; height: 18px; color: #fff; }

.sidebar-app-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.sidebar-app-sub  { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.sidebar-section { padding: 16px 8px 4px; }

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 8px;
  margin-bottom: 4px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.sidebar-nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav-link:hover { background: var(--gray-100); color: var(--text-main); }
.sidebar-nav-link.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

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

.sidebar-assistant-list { display: flex; flex-direction: column; gap: 2px; }

.sidebar-asst-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  transition: background var(--trans);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-asst-btn:hover { background: var(--gray-100); }
.sidebar-asst-btn.active { background: var(--blue-light); color: var(--blue); }

.asst-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.asst-dot-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  transition: background var(--trans);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-top: 4px;
}
.sidebar-add-btn svg { width: 16px; height: 16px; }
.sidebar-add-btn:hover { background: var(--blue-light); }

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-main); }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.page-body { flex: 1; overflow-y: auto; padding: 28px; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px; height: 36px;
  border-radius: var(--radius-xl);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; outline: none;
  transition: background var(--trans), box-shadow var(--trans), opacity var(--trans);
  white-space: nowrap; text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }

.btn-filled  { background: var(--blue); color: #fff; }
.btn-filled:hover { background: var(--blue-hover); box-shadow: var(--shadow-1); }

.btn-tonal   { background: var(--blue-light); color: var(--blue); }
.btn-tonal:hover { background: #d2e3fc; }

.btn-outlined {
  background: #fff; color: var(--text-sub);
  border: 1px solid var(--border);
}
.btn-outlined:hover { background: var(--gray-100); border-color: var(--gray-400); }

.btn-text { background: transparent; color: var(--text-sub); }
.btn-text:hover { background: var(--gray-100); }

.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fad2cf; }

.btn-lg { height: 44px; padding: 0 24px; font-size: 14px; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn-icon svg { width: 18px; height: 18px; }

.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   DASHBOARD — ASSISTANT GRID
   ============================================= */
.page-hero {
  background: linear-gradient(135deg, #e8f0fe 0%, #fce8e6 100%);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.page-hero-text h1 { font-size: 20px; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.page-hero-text p  { font-size: 13px; color: var(--text-sub); max-width: 480px; line-height: 1.7; }
.page-hero-actions { margin-top: 16px; display: flex; gap: 10px; }

.page-hero-visual {
  width: 80px; height: 80px;
  background: #fff;
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-2);
  flex-shrink: 0;
}
.page-hero-visual svg { width: 40px; height: 40px; color: var(--blue); }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-main); }
.section-badge {
  background: var(--blue-light); color: var(--blue);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 99px;
  margin-left: 8px;
}

.asst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

/* アシスタントカード */
.asst-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow var(--trans), border-color var(--trans);
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
}
.asst-card:hover { box-shadow: var(--shadow-2); border-color: var(--gray-400); }

.asst-card-top { display: flex; align-items: flex-start; gap: 14px; }

.asst-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.asst-icon svg { width: 22px; height: 22px; }

.asst-card-info { flex: 1; min-width: 0; }
.asst-card-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.asst-card-role { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.asst-card-more {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted);
  transition: background var(--trans);
  flex-shrink: 0;
}
.asst-card-more:hover { background: var(--gray-100); color: var(--text-main); }
.asst-card-more svg { width: 16px; height: 16px; }

.asst-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--gray-100);
  color: var(--text-sub);
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 99px;
}
.tag-blue { background: var(--blue-light); color: var(--blue); }
.tag-role { font-weight: 600; }

.asst-card-desc {
  font-size: 12px; color: var(--text-sub); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.asst-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.asst-card-date { font-size: 11px; color: var(--text-muted); }

.btn-chat {
  background: var(--blue); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 5px 14px; border-radius: 99px;
  border: none; cursor: pointer;
  transition: background var(--trans);
  display: flex; align-items: center; gap: 5px;
}
.btn-chat svg { width: 12px; height: 12px; }
.btn-chat:hover { background: var(--blue-hover); }

/* 追加カード */
.asst-card-add {
  border: 2px dashed var(--border);
  background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 160px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
}
.asst-card-add:hover { border-color: var(--blue); background: var(--blue-light); }
.asst-card-add:hover .asst-add-icon { background: #d2e3fc; }
.asst-add-icon {
  width: 48px; height: 48px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--trans);
}
.asst-add-icon svg { width: 24px; height: 24px; color: var(--gray-600); }
.asst-card-add:hover .asst-add-icon svg { color: var(--blue); }
.asst-add-label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.asst-card-add:hover .asst-add-label { color: var(--blue); }
.asst-add-sub { font-size: 11px; color: var(--text-muted); }

/* =============================================
   CREATE ASSISTANT MODAL
   ============================================= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 900;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.open { opacity: 1; pointer-events: all; }

.dialog {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 100%; max-width: 680px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-3);
  transform: translateY(16px) scale(.98);
  transition: transform .22s ease;
  overflow: hidden;
}
.overlay.open .dialog { transform: translateY(0) scale(1); }

/* ダイアログヘッダ */
.dialog-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.dialog-head-text h2 { font-size: 18px; font-weight: 700; color: var(--text-main); }
.dialog-head-text p  { font-size: 12px; color: var(--text-sub); margin-top: 3px; }

.dialog-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--text-sub);
  transition: background var(--trans);
  flex-shrink: 0;
}
.dialog-close:hover { background: var(--gray-100); color: var(--text-main); }
.dialog-close svg { width: 18px; height: 18px; }

/* モード切り替えタブ */
.mode-switch {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-xl);
  padding: 4px;
  margin: 0 24px 0;
  flex-shrink: 0;
}
.mode-tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; background: none; color: var(--text-sub);
  transition: background var(--trans), color var(--trans), box-shadow var(--trans);
}
.mode-tab svg { width: 15px; height: 15px; }
.mode-tab .tab-badge {
  font-size: 10px; font-weight: 700;
  background: var(--gray-200); color: var(--text-muted);
  padding: 1px 6px; border-radius: 99px;
}
.mode-tab.active {
  background: #fff; color: var(--blue);
  box-shadow: var(--shadow-1);
}
.mode-tab.active .tab-badge { background: var(--blue); color: #fff; }
.mode-tab:hover:not(.active) { background: var(--gray-200); }

/* ─────────────────────────────────────────────
   ダイアログ新レイアウト構造
   dialog (flex-col, max-height 90vh)
   └─ dialog-head  (flex-shrink:0)
   └─ successView  (flex-shrink:0, display:none 初期)
   └─ mainView     (flex:1, overflow:hidden, display:flex, flex-col)
      └─ dialog-tabs-wrap  (flex-shrink:0)
      └─ mode-panel        (flex:1, overflow:hidden, display:flex, flex-col)
         └─ dialog-steps-wrap (flex-shrink:0)
         └─ dialog-body       (flex:1, overflow-y:auto)
         └─ dialog-foot       (flex-shrink:0)
───────────────────────────────────────────── */
#mainView {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dialog-tabs-wrap {
  padding: 16px 24px 0;
  flex-shrink: 0;
}

.mode-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dialog-steps-wrap {
  padding: 16px 24px 0;
  flex-shrink: 0;
}

/* ダイアログボディ */
.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-height: 0;
}

/* ステップインジケータ */
.steps {
  display: flex; align-items: center;
  margin-bottom: 0;
  padding-bottom: 4px;
}
.step-node {
  display: flex; align-items: center; gap: 8px;
}
.step-node:not(:last-child) { flex: 1; }
.step-node:not(:last-child)::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border); margin: 0 8px;
  transition: background var(--trans);
}
.step-node.done:not(:last-child)::after { background: var(--blue); }

.step-circle {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 2px solid var(--border);
  color: var(--text-muted);
  background: #fff;
  transition: all var(--trans);
  flex-shrink: 0;
}
.step-node.active .step-circle {
  border-color: var(--blue); color: var(--blue); background: var(--blue-light);
}
.step-node.done .step-circle {
  border-color: var(--blue); background: var(--blue); color: #fff;
}
.step-node.done .step-circle svg { width: 13px; height: 13px; }
.step-text {
  font-size: 12px; font-weight: 500; color: var(--text-muted); white-space: nowrap;
}
.step-node.active .step-text { color: var(--blue); font-weight: 600; }
.step-node.done   .step-text { color: var(--text-sub); }

/* フォームステップ */
.form-step { display: none; }
.form-step.active {
  display: block;
  animation: stepIn .2s ease;
}
@keyframes stepIn { from { opacity:0; transform: translateX(10px); } to { opacity:1; transform:translateX(0); } }

.step-lead { font-size: 14px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.step-sub  { font-size: 12px; color: var(--text-sub); margin-bottom: 18px; }

/* ロールカードグリッド */
.role-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.role-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color var(--trans), background var(--trans), box-shadow var(--trans);
  background: #fff;
  position: relative;
}
.role-card:hover { border-color: var(--gray-400); box-shadow: var(--shadow-1); }
.role-card.selected {
  border-color: var(--sel-color, var(--blue));
  background: var(--sel-bg, var(--blue-light));
  box-shadow: 0 0 0 2px var(--sel-shadow, rgba(26,115,232,.2));
}

.role-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-card-icon svg { width: 20px; height: 20px; }

.role-card-body { flex: 1; min-width: 0; }
.role-card-name { font-size: 13px; font-weight: 700; color: var(--text-main); }
.role-card-desc { font-size: 11px; color: var(--text-sub); margin-top: 3px; line-height: 1.5; }

.role-check {
  position: absolute; top: 10px; right: 10px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--sel-color, var(--blue));
  display: none; align-items: center; justify-content: center;
}
.role-card.selected .role-check { display: flex; }
.role-check svg { width: 10px; height: 10px; color: #fff; }

/* タイプカードグリッド（カスタムモード） */
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.type-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: border-color var(--trans), background var(--trans), box-shadow var(--trans);
  background: #fff;
  position: relative;
}
.type-card:hover { border-color: var(--gray-400); box-shadow: var(--shadow-1); }
.type-card.selected {
  border-color: var(--blue);
  background: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(26,115,232,.2);
}

.type-card-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--trans);
}
.type-card-icon svg { width: 20px; height: 20px; color: var(--gray-600); }
.type-card.selected .type-card-icon { background: #d2e3fc; }
.type-card.selected .type-card-icon svg { color: var(--blue); }

.type-card-name { font-size: 12px; font-weight: 700; color: var(--text-main); line-height: 1.3; }
.type-card-desc { font-size: 11px; color: var(--text-sub); }

.type-check {
  position: absolute; top: 8px; right: 8px;
  width: 16px; height: 16px;
  border-radius: 50%; background: var(--blue);
  display: none; align-items: center; justify-content: center;
}
.type-card.selected .type-check { display: flex; }
.type-check svg { width: 9px; height: 9px; color: #fff; }

/* 設定フォーム共通 */
.settings-block { display: flex; flex-direction: column; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label {
  font-size: 13px; font-weight: 600; color: var(--text-main);
  display: flex; align-items: center; gap: 6px;
}
.form-label-opt { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px; color: var(--text-main);
  background: #fff; transition: border-color var(--trans);
  outline: none; font-family: inherit; width: 100%;
}
.form-input:hover { border-color: var(--gray-400); }
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(26,115,232,.15); }
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 110px; line-height: 1.7; }

/* ラジオオプション */
.radio-list { display: flex; flex-direction: column; gap: 8px; }

.radio-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
  background: #fff;
}
.radio-item:hover { border-color: var(--gray-400); background: var(--gray-50); }
.radio-item.selected { border-color: var(--blue); background: var(--blue-light); }

.radio-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
  background: #fff;
  transition: border-color var(--trans), background var(--trans);
}
.radio-dot::after {
  content: ''; width: 7px; height: 7px;
  border-radius: 50%; background: #fff;
  opacity: 0; transition: opacity var(--trans);
}
.radio-item.selected .radio-dot {
  border-color: var(--blue); background: var(--blue);
}
.radio-item.selected .radio-dot::after { opacity: 1; }

.radio-text {}
.radio-label { font-size: 13px; font-weight: 600; color: var(--text-main); }
.radio-desc  { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

/* 動的追加セクション */
.dynamic-area {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 6px;
}
.dynamic-area-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.dynamic-area-badge {
  font-size: 10px; font-weight: 600;
  background: var(--blue-light); color: var(--blue);
  padding: 2px 7px; border-radius: 99px;
  letter-spacing: 0; text-transform: none;
}

/* チェックボックス選択リスト（複数選択用） */
.check-list { display: flex; flex-direction: column; gap: 7px; }

.check-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
  background: #fff;
}
.check-item:hover { border-color: var(--gray-400); background: var(--gray-50); }
.check-item.selected { border-color: var(--blue); background: var(--blue-light); }

/* 全部選択オプションは少し目立たせる */
.check-item-all {
  border-style: dashed;
  background: var(--gray-50);
}
.check-item-all.selected { border-style: solid; }

.check-box {
  width: 18px; height: 18px; min-width: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--trans), background var(--trans);
  margin-top: 1px;
}
.check-box svg { width: 10px; height: 10px; color: #fff; opacity: 0; transition: opacity var(--trans); }
.check-box.checked {
  border-color: var(--blue); background: var(--blue);
}
.check-box.checked svg { opacity: 1; }

/* プロンプトプレビュー */
.prompt-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); letter-spacing: .04em;
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 6px;
}
.prompt-label svg { width: 12px; height: 12px; }
.prompt-box {
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 11.5px; color: var(--text-sub);
  font-family: 'Courier New', monospace;
  line-height: 1.8; max-height: 110px;
  overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* プレビューバナー */
.preview-banner {
  background: linear-gradient(120deg, var(--blue-light) 0%, #e0f2fe 100%);
  border: 1px solid var(--blue-mid);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
}
.preview-banner-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: var(--shadow-1);
}
.preview-banner-icon svg { width: 24px; height: 24px; }
.preview-banner-name { font-size: 16px; font-weight: 700; color: var(--text-main); }
.preview-banner-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.preview-tag {
  background: rgba(26,115,232,.12); color: var(--blue);
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
}

/* ダイアログフッタ */
.dialog-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; flex-shrink: 0;
}
.foot-hint { font-size: 11px; color: var(--text-muted); }
.foot-actions { display: flex; align-items: center; gap: 8px; }

/* 成功画面 */
.success-view {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; gap: 16px; text-align: center;
}
.success-ring {
  width: 64px; height: 64px;
  background: var(--green-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  animation: popIn .5s cubic-bezier(.175,.885,.32,1.275);
}
.success-ring svg { width: 32px; height: 32px; color: var(--green); }
@keyframes popIn { from { transform:scale(0);opacity:0; } to { transform:scale(1);opacity:1; } }
.success-title { font-size: 20px; font-weight: 700; color: var(--text-main); }
.success-desc  { font-size: 13px; color: var(--text-sub); line-height: 1.7; max-width: 320px; }
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}

/* =============================================
   CHAT SCREEN
   ============================================= */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--header-h));
  max-width: 760px; margin: 0 auto; width: 100%;
}

.chat-topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  background: #fff; flex-shrink: 0;
}
.chat-asst-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-asst-icon svg { width: 20px; height: 20px; }
.chat-asst-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.chat-asst-status {
  font-size: 11px; color: var(--green);
  display: flex; align-items: center; gap: 4px;
}
.live-dot {
  width: 6px; height: 6px; background: var(--green);
  border-radius: 50%; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }

.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* ウェルカム */
.chat-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 24px;
  text-align: center; gap: 14px;
}
.welcome-icon {
  width: 64px; height: 64px;
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-2);
}
.welcome-icon svg { width: 32px; height: 32px; }
.welcome-title { font-size: 18px; font-weight: 700; color: var(--text-main); }
.welcome-desc  { font-size: 13px; color: var(--text-sub); max-width: 400px; line-height: 1.7; }
.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 480px; }
.chip {
  padding: 7px 14px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px; color: var(--text-sub);
  cursor: pointer; transition: border-color var(--trans), color var(--trans), background var(--trans);
}
.chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* メッセージ */
.msg { display: flex; gap: 12px; max-width: 80%; animation: msgIn .2s ease; }
.msg.no-anim { animation: none; }
@keyframes msgIn { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:translateY(0);} }

.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  background: var(--gray-100); border: 1px solid var(--border);
}
.msg-user .msg-avatar { background: var(--blue); color: #fff; border-color: var(--blue); }
.msg-avatar svg { width: 16px; height: 16px; }

.msg-bubble {
  background: #fff; border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 14px;
  font-size: 14px; line-height: 1.7; color: var(--text-main);
}
.msg-user .msg-bubble {
  background: var(--blue); color: #fff;
  border-color: var(--blue);
  border-radius: 12px 4px 12px 12px;
}
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: left; }
.msg-user .msg-time { text-align: right; }

/* タイピング */
.typing-wrap { display: flex; gap: 12px; }
.typing-bubble {
  background: #fff; border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 4px;
}
.t-dot {
  width: 7px; height: 7px;
  background: var(--gray-400); border-radius: 50%;
  animation: td 1.4s infinite;
}
.t-dot:nth-child(2){animation-delay:.2s;}
.t-dot:nth-child(3){animation-delay:.4s;}
@keyframes td { 0%,80%,100%{transform:scale(1);opacity:.5;} 40%{transform:scale(1.3);opacity:1;} }

/* チャット入力 */
.chat-input-area {
  padding: 12px 24px 20px;
  background: #fff; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-box {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 14px;
  transition: border-color var(--trans), box-shadow var(--trans);
}
.input-box:focus-within {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(26,115,232,.12);
}
.chat-textarea {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 14px; color: var(--text-main); line-height: 1.6;
  resize: none; max-height: 120px; min-height: 24px;
  font-family: inherit; padding: 0;
}
.chat-textarea::placeholder { color: var(--text-muted); }
.send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: background var(--trans);
  flex-shrink: 0;
}
.send-btn:hover { background: var(--blue-hover); }
.send-btn:disabled { background: var(--gray-300); cursor: not-allowed; }
.send-btn svg { width: 15px; height: 15px; }
.input-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* =============================================
   TOAST
   ============================================= */
.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--gray-900); color: #fff;
  padding: 12px 18px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-3);
  display: flex; align-items: center; gap: 10px;
  max-width: 340px; animation: tIn .3s ease;
}
.toast svg { width: 17px; height: 17px; flex-shrink: 0; }
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
@keyframes tIn { from{opacity:0;transform:translateY(16px);} to{opacity:1;transform:translateY(0);} }
@keyframes tOut{ from{opacity:1;} to{opacity:0;transform:translateY(-8px);} }

/* =============================================
   EMPTY / ERROR
   ============================================= */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px; text-align: center; gap: 14px;
}
.empty-icon {
  width: 72px; height: 72px;
  background: var(--gray-100);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
}
.empty-icon svg { width: 32px; height: 32px; color: var(--text-muted); }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text-main); }
.empty-desc  { font-size: 13px; color: var(--text-sub); max-width: 320px; line-height: 1.7; }

/* =============================================
   PROMPT MODAL
   ============================================= */
.prompt-dialog .dialog-body { padding: 20px 24px; }

/* 担当サマリー */
.prompt-asst-summary {
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.prompt-asst-info { flex: 1; min-width: 0; }
.prompt-asst-name { font-size: 16px; font-weight: 700; color: var(--text-main); }
.prompt-asst-role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.prompt-full-box {
  background: var(--gray-100); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  font-size: 12.5px; color: var(--text-sub);
  font-family: 'Courier New', monospace;
  line-height: 1.9; white-space: pre-wrap; word-break: break-all;
  max-height: 50vh; overflow-y: auto;
}

/* =============================================
   UTILITIES
   ============================================= */
.hidden { display: none !important; }
.sr-only { position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-body { padding: 16px; }
  .page-hero { flex-direction: column; padding: 20px; }
  .page-hero-visual { display: none; }
  .overlay { padding: 0; align-items: flex-end; }
  .dialog { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 95vh; }
  .role-grid { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: 1fr; }
  .asst-grid { grid-template-columns: 1fr; }
  .steps .step-text { display: none; }
}

@media (max-width: 480px) {
  .topbar-subtitle { display: none; }
  .mode-tab span:first-child { display: none; }
}

/* =============================================
   SIDEBAR — 新レイアウト
   担当セクション（上部固定） + スレッドセクション（スクロール）
   ============================================= */

/* サイドバー全体を flex-col にして上下分割 */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* 全体はスクロールしない */
}

/* 上部：担当セクション（高さ固定） */
.sidebar-top {
  flex-shrink: 0;
  padding-bottom: 4px;
}

/* 下部：スレッドセクション（余った高さを使いスクロール） */
.sidebar-threads {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
  min-height: 0;
}
.sidebar-threads::-webkit-scrollbar { width: 4px; }
.sidebar-threads::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

.sidebar-thread-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase;
  padding: 10px 8px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-thread-label span { flex: 1; }

/* スレッド行 */
.thread-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--trans);
  position: relative;
  group: 'thread';
}
.thread-item:hover { background: var(--gray-100); }
.thread-item.active { background: var(--blue-light); }
.thread-item.active .thread-title { color: var(--blue); font-weight: 600; }
.thread-item.active .thread-asst  { color: var(--blue); opacity: .75; }

.thread-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
  font-size: 9px; font-weight: 700; color: #fff;
}
.thread-body { flex: 1; min-width: 0; }
.thread-title {
  font-size: 12px; font-weight: 500; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4;
}
.thread-asst {
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.thread-del {
  width: 20px; height: 20px; border-radius: 4px;
  display: none; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; color: var(--text-muted);
  flex-shrink: 0; padding: 0;
  transition: background var(--trans), color var(--trans);
}
.thread-item:hover .thread-del { display: flex; }
.thread-del:hover { background: var(--red-bg); color: var(--red); }
.thread-del svg { width: 13px; height: 13px; }

.thread-empty {
  font-size: 11px; color: var(--text-muted);
  padding: 8px 10px; text-align: center; line-height: 1.6;
}

/* =============================================
   編集モーダル（担当の名前・プロンプト編集）
   ============================================= */
.edit-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 950;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.edit-overlay.open { opacity: 1; pointer-events: all; }

.edit-dialog {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-3);
  transform: translateY(14px) scale(.98);
  transition: transform .2s ease;
  overflow: hidden;
}
.edit-overlay.open .edit-dialog { transform: translateY(0) scale(1); }

.edit-dialog .dialog-head { flex-shrink: 0; }
.edit-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 20px; min-height: 0;
}
.edit-foot {
  flex-shrink: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  background: #fff;
}

/* プロンプト textarea */
.prompt-textarea {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-main);
  background: var(--gray-50);
  transition: border-color var(--trans);
  outline: none; font-family: 'Courier New', monospace;
  width: 100%; resize: vertical;
  min-height: 220px; line-height: 1.75;
}
.prompt-textarea:hover  { border-color: var(--gray-400); }
.prompt-textarea:focus  { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.12); }

/* アシスタントカードの編集ボタン（既存 .asst-card-more を流用） */
.asst-card-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}
.asst-card-action {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted);
  transition: background var(--trans), color var(--trans);
}
.asst-card-action:hover { background: var(--gray-100); color: var(--text-main); }
.asst-card-action.danger:hover { background: var(--red-bg); color: var(--red); }
.asst-card-action svg { width: 15px; height: 15px; }

/* =============================================
   チャット画面 — スレッド関連 UI
   ============================================= */
.chat-topbar-right { display: flex; align-items: center; gap: 8px; }

/* 新スレッドボタン */
.btn-new-thread {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 32px;
  border-radius: var(--radius-xl);
  font-size: 12px; font-weight: 600;
  background: var(--blue-light); color: var(--blue);
  border: none; cursor: pointer;
  transition: background var(--trans);
  white-space: nowrap;
}
.btn-new-thread svg { width: 14px; height: 14px; }
.btn-new-thread:hover { background: #d2e3fc; }

/* スレッドタイトル（チャットヘッダ内） */
.chat-thread-title {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
  margin-top: 1px;
}
.chat-thread-title svg { width: 11px; height: 11px; }
