/* CLANE 標準デザイン: Noto Sans JP / メイン#461787・サブ#A057A2 / 角わずかに丸め / 絵文字なし(Material Icons) */
:root {
  --main: #461787;
  --sub: #A057A2;
  --grad: linear-gradient(135deg, #461787 0%, #A057A2 100%);
  --bg: #F3F3F3;
  --panel: #FFFFFF;
  --text: #000000;
  --muted: #6b6b73;
  --line: #e4e0ec;
  --radius: 8px;
  --ok: #1b873f;
  --warn: #b25e00;
  --err: #c0392b;
  --info: #461787;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--main); text-decoration: none; }
a:hover { text-decoration: underline; }
.material-icons { font-size: 20px; vertical-align: middle; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { display:flex; gap:8px; align-items:center; justify-content:center; min-height:100vh; color:var(--muted); }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--main); color: #fff; display: flex; flex-direction: column; }
.brand { padding: 20px 18px; font-weight: 700; font-size: 15px; line-height:1.3; border-bottom: 1px solid rgba(255,255,255,0.15); }
.brand .sub { display:block; font-weight:400; font-size:11px; color: #e9dcff; margin-top:2px; }
.nav { padding: 10px 8px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: #efe7fb; padding: 10px 12px;
  border-radius: 6px; margin-bottom: 2px; font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,0.20); color: #fff; font-weight: 500; }
.nav .material-icons { font-size: 19px; }
/* 子メニュー付きグループ（設定 など） */
.nav-grp-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer;
  background: none; border: none; color: #efe7fb; padding: 10px 12px; border-radius: 6px;
  font-size: 14px; font-family: inherit; text-align: left;
}
.nav-grp-btn:hover { background: rgba(255,255,255,0.12); }
/* ラベルは他メニューと同じ左寄せ。開閉キャレットだけ右端へ。 */
.nav-grp-btn .material-icons:last-child { margin-left: auto; font-size: 18px; transition: transform .18s ease; opacity: .8; }
.nav-group.open .nav-grp-btn .material-icons:last-child { transform: rotate(180deg); }
.nav-children { display: none; margin: 2px 0 2px 10px; padding-left: 12px; }
.nav-group.open .nav-children { display: block; }
.nav-children a.nav-child { font-size: 13px; padding: 8px 10px; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: #cdbce8; border-top: 1px solid rgba(255,255,255,0.15); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar .who { display:flex; align-items:center; gap:10px; font-size:13px; color: var(--muted); }
.content { padding: 24px; max-width: 1200px; width: 100%; }
.page-head { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; color: var(--main); margin: 0; }
.page-head .desc { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

/* ---- components ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--text); }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
/* ハンバーガー（モバイルのメニュー開閉）。デスクトップでは隠す。 */
.hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--main); padding: 4px; }
.hamburger .material-icons { font-size: 26px; }
.nav-backdrop { display: none; }

@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  /* サイドバーはオフキャンバスのドロワーに（display:none で消さない＝ナビを残す） */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 80;
  }
  .layout.nav-open .sidebar { transform: translateX(0); box-shadow: 2px 0 18px rgba(0,0,0,.35); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 75;
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .layout.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .hamburger { display: inline-flex; align-items: center; }
  .topbar { padding: 8px 12px; }
  .topbar .ws-text { display: none; } /* workspace の長いIDはモバイルでは隠す */
  .content { padding: 14px; }
  .page-head { flex-wrap: wrap; }
  .page-head h1 { font-size: 18px; }
  /* 横長テーブルはカード内で横スクロール（レイアウトを壊さない） */
  .card { overflow-x: auto; }
  .kv { grid-template-columns: 88px 1fr; }
  .modal-bg { padding: 8px; }
  .modal { max-height: 94vh; }
}

.tile { display:block; background: var(--panel); border:1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--text); }
.tile:hover { text-decoration:none; border-color: var(--sub); box-shadow: 0 2px 12px rgba(70,23,135,0.08); }
.tile .ic { width:40px; height:40px; border-radius:10px; background: var(--grad); color:#fff; display:flex; align-items:center; justify-content:center; margin-bottom: 12px; }
.tile .t { font-weight:700; color: var(--main); }
.tile .n { font-size: 26px; font-weight:700; margin-top: 4px; }
.tile .d { color: var(--muted); font-size: 12px; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--main); color: #fff;
  border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: #5a2199; }
.btn .material-icons { font-size: 17px; }
.btn.ghost { background: #fff; color: var(--main); border: 1px solid var(--main); }
.btn.ghost:hover { background: #f4eefb; }
.btn.sub { background: var(--sub); }
.btn.sub:hover { background: #b06ab3; }
.btn.danger { background: #fff; color: var(--err); border: 1px solid var(--err); }
.btn.danger:hover { background: #fdeeec; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { margin-bottom: 12px; }
.field label { display:block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; font-size: 13px; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }
.inline { display:flex; gap:8px; align-items:center; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #faf7fe; }

.badge { display:inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; border:1px solid transparent; }
.badge.ok { background:#e7f6ec; color: var(--ok); }
.badge.err { background:#fbecea; color: var(--err); }
.badge.warn { background:#fcf2e3; color: var(--warn); }
.badge.info { background:#efe7fb; color: var(--main); }
.badge.muted { background:#eee; color: var(--muted); }
.tag { display:inline-block; background:#efe7fb; color:var(--main); border-radius:10px; padding:1px 8px; font-size:11px; margin: 0 4px 4px 0; }

.note { background:#f6f1fd; border:1px solid #d7cee9; padding: 8px 12px; border-radius: 6px; font-size: 12px; color: var(--muted); }
.note.main { background:#f4f0fa; border-color:#d7cee9; }
.note.ok { background:#e7f6ec; border-color:#a9d8b8; }
.note.err { background:#fbecea; border-color:#e6b0aa; }
.note.warn { background:#fbf1e7; border-color:#e6cba6; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.pre { white-space: pre-wrap; word-break: break-word; background:#faf9fc; border:1px solid var(--line); border-radius:6px; padding:12px; font-size:13px; }
.meta { color: var(--muted); font-size: 12px; }
/* MCP連携の手順番号バッジ（CLANE One と統一） */
.mcp-n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; margin-top: 2px; }
.kv { display:grid; grid-template-columns: 120px 1fr; gap:6px 12px; font-size:13px; }
.kv .k { color: var(--muted); }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; display:flex; flex-direction:column; gap:8px; z-index: 50; }
.toast { background:#fff; border:1px solid var(--main); border-radius:6px; padding:10px 14px; font-size:13px; box-shadow:0 4px 16px rgba(0,0,0,0.12); max-width: 360px; }
.toast.err { border-color: var(--err); background:#fbecea; }
.toast.ok { border-color: var(--ok); background:#e7f6ec; }

.modal-bg { position: fixed; inset:0; background: rgba(0,0,0,0.4); display:flex; align-items:center; justify-content:center; z-index: 60; padding: 20px; }
.modal { background:#fff; border-radius: var(--radius); width: 100%; max-width: 560px; max-height: 90vh; overflow:auto; }
.modal .mhead { padding: 16px 18px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center; }
.modal .mhead h2 { margin:0; font-size: 15px; color: var(--main); }
.modal .mbody { padding: 18px; }
.modal .mfoot { padding: 14px 18px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px; }
.iconbtn { background:none; border:none; cursor:pointer; color: var(--muted); display:inline-flex; }
.center { min-height: 60vh; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:12px; text-align:center; color: var(--muted); }

/* STEP2: ナレッジ質問・出典チップ */
.cite-list { display:flex; flex-wrap:wrap; gap:8px; }
.cite-chip {
  display:inline-flex; align-items:center; gap:6px; max-width:100%;
  background:#f4f0fa; border:1px solid #d7cee9; color: var(--main);
  padding:5px 10px; border-radius: 999px; font-size:12px; line-height:1.3;
}
.cite-chip:hover { text-decoration:none; border-color: var(--sub); background:#ede6f6; }
.cite-chip .material-symbols-rounded, .cite-chip .material-icons { font-size:15px; }
.cite-chip span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.answer-body { color: var(--text); }
