:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel2: #313338;
  --line: #3f4147;
  --text: #dbdee1;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent2: #4752c4;
  --danger: #da373c;
  --ok: #23a55a;
  --warn: #f0b232;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
a { color: #00a8fc; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: #fa777c; }

/* ログイン */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--panel); padding: 40px; border-radius: 12px; text-align: center; max-width: 420px; }

/* レイアウト */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); display: flex; flex-direction: column; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.brand img { width: 40px; height: 40px; border-radius: 50%; background: var(--panel2); }
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }
nav { flex: 1; padding: 8px; overflow-y: auto; }
nav a { display: block; padding: 9px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; margin-bottom: 2px; }
nav a:hover { background: var(--panel2); color: var(--text); }
nav a.active { background: #404249; color: #fff; }
.me { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.me img { width: 28px; height: 28px; border-radius: 50%; }
.me span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view { padding: 28px 32px 80px; max-width: 1100px; width: 100%; }
.page-head { margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* カード */
.card { background: var(--panel); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; border: 1px solid var(--line); }
.card.sub { background: var(--panel2); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 20px; align-items: start; }
.stat { background: var(--panel2); border-radius: 8px; padding: 14px; }
.stat b { display: block; font-size: 22px; margin-top: 4px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .split, .grid2, .grid3 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
}

/* フォーム */
.field { margin-bottom: 12px; }
.field > label, .label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; text-transform: none; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="number"], input[type="time"], input[type="search"], textarea, select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days label { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 34px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); cursor: pointer; }
.days input { display: none; }
.days label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { padding: 7px 14px; cursor: pointer; background: var(--bg); }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: #fff; }
input[type="color"] { width: 34px; height: 28px; border: none; background: none; padding: 0; cursor: pointer; }

/* ボタン */
.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 6px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; background: #4e5058; color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.primary { background: var(--accent); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.big { padding: 12px 28px; font-size: 16px; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 4px; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

/* 一覧 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--panel2); border-radius: 8px; padding: 10px 14px; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #4e5058; color: #fff; margin-left: 6px; vertical-align: middle; }
.badge.ok { background: var(--ok); }
.badge.warn { background: var(--warn); color: #000; }
.badge.danger { background: var(--danger); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bg); flex: none; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.alert { background: rgba(240, 178, 50, 0.12); border: 1px solid rgba(240, 178, 50, 0.4); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.alert.danger { background: rgba(218, 55, 60, 0.12); border-color: rgba(218, 55, 60, 0.5); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 3px 4px 3px 10px; }
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; }

/* 種類・ロール編集のブロック */
.block { background: var(--panel2); border-radius: 8px; padding: 14px; margin-bottom: 10px; border-left: 4px solid var(--accent); }
.block-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.block-head .title { flex: 1; font-weight: 700; }
.q-row { display: grid; grid-template-columns: 1fr 120px 70px 1fr 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.role-row { display: grid; grid-template-columns: 1.4fr 1fr 70px 1.4fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.th-row { display: grid; grid-template-columns: 90px 1fr 120px 30px; gap: 8px; align-items: center; margin-bottom: 6px; }
@media (max-width: 900px) { .q-row, .role-row { grid-template-columns: 1fr 1fr; } }

/* Discord風プレビュー */
.preview { background: #313338; border-radius: 8px; padding: 14px; border: 1px solid var(--line); position: sticky; top: 16px; }
.preview-label { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.msg { display: flex; gap: 12px; }
.msg img.bot-avatar { width: 40px; height: 40px; border-radius: 50%; }
.msg-body { flex: 1; min-width: 0; }
.msg-author { font-weight: 600; color: #fff; }
.msg-author .bot-tag { background: var(--accent); color: #fff; font-size: 10px; padding: 1px 4px; border-radius: 3px; margin-left: 4px; vertical-align: middle; }
.msg-text { white-space: pre-wrap; word-break: break-word; margin-top: 2px; line-height: 1.45; }
.mention { background: rgba(88, 101, 242, 0.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }
.embed { margin-top: 6px; background: #2b2d31; border-left: 4px solid var(--accent); border-radius: 4px; padding: 10px 14px; max-width: 520px; }
.embed-title { font-weight: 700; color: #fff; margin-bottom: 4px; }
.embed-desc { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.embed-field { margin-top: 8px; }
.embed-field b { display: block; color: #fff; font-size: 13px; }
.embed-img { max-width: 100%; border-radius: 4px; margin-top: 10px; display: block; }
.embed-footer { font-size: 12px; color: var(--muted); margin-top: 8px; }
.dbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dbtn { padding: 6px 14px; border-radius: 4px; font-size: 13px; color: #fff; background: #4e5058; }
.dbtn.Primary { background: var(--accent); }
.dbtn.Success { background: #248046; }
.dbtn.Danger { background: var(--danger); }
.dselect { margin-top: 8px; background: #1e1f22; border-radius: 4px; padding: 9px 12px; color: var(--muted); }

/* トースト */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #111214; border-left: 4px solid var(--ok); padding: 12px 16px; border-radius: 6px; max-width: 380px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); animation: slidein 0.2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* モーダル */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 10px; padding: 20px; width: min(980px, 100%); max-height: 92vh; overflow-y: auto; }
