:root {
  --c-ai: #b8820f;
  --c-staff: #5b8def;
  --c-open: #2fa58a;
  --danger: #f0585c;
}

.dash { padding: 32px 0 96px; min-height: calc(100vh - var(--header-h) - 120px); }
.dash h1 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); font-weight: 700; }
.dash h2 { font-size: 1.15rem; font-weight: 600; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); font-size: 0.88rem; }
[hidden] { display: none !important; }

.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 500; }
.user-chip img, .user-chip .ph { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); }
@media (max-width: 600px) { .user-chip .user-name { display: none; } }

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

.center-card { max-width: 480px; margin: 72px auto 0; text-align: center; padding: 44px 28px; }
.center-card img { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 22px; box-shadow: 0 0 0 1px var(--border-strong), 0 0 50px -8px var(--gold-glow); }
.center-card h1 { margin-bottom: 12px; }
.center-card p { color: var(--muted); margin-bottom: 26px; }
.spinner { width: 34px; height: 34px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 24px; }
.toolbar .spacer { flex: 1; }
.field-select, .field-input, .field-textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--bg); color: var(--text); font: inherit;
  border: 1px solid var(--border-strong); border-radius: 10px;
}
.field-select { appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b5ac9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.field-textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field-select:focus-visible, .field-input:focus-visible, .field-textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.guild-select { width: auto; min-width: 240px; max-width: 100%; font-weight: 600; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.seg button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 500; font-size: 0.92rem; cursor: pointer; transition: background 0.2s, color 0.2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: rgba(245, 184, 46, 0.14); color: var(--gold-light); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile-stat { padding: 20px 22px; }
.tile-stat .label { color: var(--muted); font-size: 0.88rem; }
.tile-stat .value { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; line-height: 1.15; margin-top: 6px; }
.tile-stat .hint { color: var(--subtle); font-size: 0.82rem; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.86rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 260px; overflow: visible; }
.chart .grid-line { stroke: rgba(255, 214, 140, 0.08); stroke-width: 1; }
.chart .axis-text { fill: var(--subtle); font-size: 11px; font-family: var(--font-body); }
.chart .hover-col { fill: transparent; }
.chart .hover-col.on { fill: rgba(255, 214, 140, 0.06); }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 12px; font-size: 0.84rem; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.8);
  opacity: 0; transition: opacity 0.12s;
}
.tooltip.on { opacity: 1; }
.tooltip b { display: block; margin-bottom: 6px; }
.tooltip div { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.tooltip div i { width: 8px; height: 8px; border-radius: 2px; }
.tooltip div span { margin-left: auto; color: var(--text); font-weight: 600; padding-left: 14px; }

.rating-big { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.rating-big .value { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.rating-rows { display: grid; gap: 8px; }
.rating-row { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--muted); }
.rating-row .bar { height: 10px; border-radius: 4px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.rating-row .bar i { display: block; height: 100%; border-radius: 4px; background: var(--c-ai); }
.rating-row .n { text-align: right; color: var(--text); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th { text-align: left; color: var(--subtle); font-weight: 500; font-size: 0.8rem; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data button.link { background: none; border: 0; padding: 0; color: var(--gold-light); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; }
table.data button.link:hover { text-decoration: underline; }
.guild-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: inline-grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); flex: none; object-fit: cover; }
details.table-toggle { margin-top: 14px; }
details.table-toggle summary { cursor: pointer; color: var(--subtle); font-size: 0.86rem; }

.k-list { display: grid; gap: 10px; }
.k-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; background: rgba(255, 255, 255, 0.015); }
.k-item .q { font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.k-item .a { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.k-item .actions, .form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.form-grid { display: grid; gap: 14px; }
.form-row label, .form-row .label { display: block; font-weight: 500; margin-bottom: 6px; }
.form-row .help { color: var(--subtle); font-size: 0.84rem; margin-top: 5px; }
.counter { float: right; color: var(--subtle); font-size: 0.8rem; font-weight: 400; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(240, 88, 92, 0.4); }
.btn-danger:hover { background: rgba(240, 88, 92, 0.1); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; width: 100%; height: 100%; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.12); transition: background 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch input:checked + span { background: var(--gold); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 3px; }
.role-list { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.role-list label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 400; margin: 0; }
.role-list label:hover { background: rgba(255, 255, 255, 0.04); }
.role-list input { width: 18px; height: 18px; accent-color: var(--gold); }
.role-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--subtle); flex: none; }
.save-bar { position: sticky; bottom: 16px; margin-top: 18px; display: flex; align-items: center; gap: 14px; justify-content: flex-end; }

.toast-box { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; }
.toast-msg { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px 18px; font-size: 0.92rem; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8); animation: toast-up 0.25s var(--ease); }
.toast-msg.error { border-color: rgba(240, 88, 92, 0.55); }
@keyframes toast-up { from { opacity: 0; transform: translateY(8px); } }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; }

.page-head { margin-bottom: 26px; }
.page-title { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-title .spacer, .page-nav .spacer { flex: 1; }
.page-title h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.15; overflow-wrap: anywhere; }
.guild-icon.big { width: 54px; height: 54px; border-radius: 16px; font-size: 1.4rem; border: 1px solid var(--border-strong); }
.page-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; min-height: 52px; }
.page-nav .seg { margin-bottom: 8px; }

.tabs-bar { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs-bar::-webkit-scrollbar { display: none; }
.tabs-bar button {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  min-height: 48px; padding: 0 16px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 500; cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
.tabs-bar button .ico { width: 18px; height: 18px; }
.tabs-bar button:hover { color: var(--text); }
.tabs-bar button[aria-selected="true"] { color: var(--gold-light); border-bottom-color: var(--gold); }
.count-badge {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; vertical-align: 2px;
  background: rgba(245, 184, 46, 0.12); color: var(--gold-light);
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 600;
}
.tabs-bar .count-badge { margin-left: 0; }

.notice {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px;
  padding: 12px 16px; border-radius: 12px;
  background: rgba(245, 184, 46, 0.07); border: 1px solid rgba(245, 184, 46, 0.28);
  color: var(--text); font-size: 0.92rem;
}
.notice .ico { color: var(--gold); width: 18px; height: 18px; margin-top: 2px; }
.notice.slim { margin: 0 0 8px; padding: 9px 14px; color: var(--muted); }

.section-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-bar h2 { font-size: 1.3rem; }
.section-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--subtle); pointer-events: none; }
.search-box .field-input { padding-left: 38px; min-height: 40px; width: 240px; max-width: 100%; }

.k-list { gap: 12px; }
.k-item { padding: 18px 20px; background: linear-gradient(180deg, var(--surface), var(--bg-elev)); transition: border-color 0.2s; }
article.k-item:hover { border-color: var(--border-strong); }
.k-top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.k-num { flex: none; font-family: var(--font-mono); font-size: 0.76rem; color: var(--gold-light); background: rgba(245, 184, 46, 0.1); border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 7px; }
.k-item .q { font-size: 1.02rem; margin: 0; }
.k-item .a { padding-left: 2px; }
.k-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.k-item .k-foot .actions { margin-top: 0; }
.k-form { border-color: rgba(245, 184, 46, 0.45); box-shadow: 0 0 0 3px rgba(245, 184, 46, 0.07); }
.k-form h3 { font-size: 1.05rem; }

.empty-state { text-align: center; padding: 48px 24px; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; }
.empty-state p { color: var(--muted); max-width: 460px; margin: 0 auto 24px; }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 16px; display: grid; place-items: center; background: rgba(245, 184, 46, 0.1); border: 1px solid var(--border-strong); color: var(--gold); }
.empty-icon .ico { width: 26px; height: 26px; }

.settings-grid { grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.set-head { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.set-icon { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; background: rgba(245, 184, 46, 0.1); border: 1px solid var(--border-strong); color: var(--gold); }
.switch-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.015); }
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 220px; overflow-y: auto; padding: 2px; }
.role-chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; cursor: pointer;
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.02);
  font-weight: 500; font-size: 0.9rem; color: var(--muted); transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.role-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.role-chip:hover { color: var(--text); }
.role-chip:has(input:checked) { background: rgba(245, 184, 46, 0.14); border-color: rgba(245, 184, 46, 0.55); color: var(--text); }
.role-chip:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

.save-bar {
  position: sticky; bottom: 16px; z-index: 20; margin: 20px auto 0; width: fit-content; max-width: 100%;
  justify-content: center; padding: 10px 12px 10px 20px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid rgba(245, 184, 46, 0.45);
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.85); font-size: 0.92rem; font-weight: 500;
  animation: toast-up 0.25s var(--ease);
}
.btn .ico { width: 16px; height: 16px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; flex: none; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
}
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); }
.status-pill.ai i { background: var(--c-ai); }
.status-pill.staff i { background: var(--c-staff); }
.status-pill.open i, .status-pill.ok i { background: var(--c-open); }
.k-top { flex-wrap: wrap; }
.stars-inline { color: var(--gold); letter-spacing: 1px; }
.stars-inline span { color: rgba(255, 255, 255, 0.14); }

.learn-list { display: grid; gap: 8px; }
.learn-item, .warn-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.015);
}
.learn-item .q { font-weight: 600; overflow-wrap: anywhere; }
.warn-list { display: grid; gap: 8px; margin-top: 10px; }
.warn-row > div:first-child { overflow-wrap: anywhere; min-width: 0; flex: 1; }

.pending-card { margin-bottom: 18px; border-color: rgba(245, 184, 46, 0.35); }
.pending-card .set-head { margin-bottom: 16px; }
.pending-card .k-item { background: rgba(255, 255, 255, 0.015); }
.pending-card .field-textarea { min-height: 84px; }
.count-badge.alert { background: var(--gold); color: var(--on-gold); }

.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.mini-stats > div { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.015); }
.mini-stats span { display: block; color: var(--muted); font-size: 0.82rem; }
.mini-stats b { font-family: var(--font-display); font-size: 1.3rem; }

.input-unit { display: flex; align-items: center; gap: 10px; }
.input-unit .field-input { width: 110px; }
.input-unit span { color: var(--muted); }
.inline-row { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-row .field-select { flex: 1; min-width: 180px; width: auto; }
.spinner.small { width: 18px; height: 18px; margin: 2px 0 0; border-width: 2px; flex: none; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pill.off i { background: var(--danger); }

.test-card { margin-bottom: 18px; }
.test-card .set-head { margin-bottom: 16px; }
.test-card .inline-row .field-input { flex: 1; min-width: 200px; width: auto; }
.test-result { margin-top: 16px; }
.test-notes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

.preview-box { position: relative; }
.preview-label { display: block; margin-bottom: 6px; color: var(--subtle); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.dc-preview {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px;
  background: #313338; color: #dbdee1; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 12px; padding: 14px 16px;
  font-size: 0.94rem; line-height: 1.4;
}
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; }
.dc-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; flex-wrap: wrap; }
.dc-name { font-weight: 600; color: var(--gold-light); }
.dc-tag { background: #5865f2; color: #fff; font-size: 0.64rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.dc-time { color: #949ba4; font-size: 0.75rem; }
.dc-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-mention { background: rgba(88, 101, 242, 0.3); color: #c9cdfb; border-radius: 4px; padding: 0 3px; font-weight: 500; }
.dc-embed { margin-top: 6px; background: #2b2d31; border-left: 4px solid #5865f2; border-radius: 4px; padding: 10px 14px 12px; max-width: 460px; }
.dc-embed-title { font-weight: 600; color: #f2f3f5; margin-bottom: 4px; }
.dc-button { display: inline-block; margin-top: 8px; background: #5865f2; color: #fff; font-size: 0.86rem; font-weight: 500; padding: 7px 14px; border-radius: 6px; }

.transcript { margin-top: 12px; }
.transcript-list { display: grid; gap: 8px; margin-top: 12px; max-height: 480px; overflow-y: auto; padding: 12px; background: #313338; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 12px; color: #dbdee1; }
.transcript-msg { padding: 6px 4px; font-size: 0.93rem; }
.transcript-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.transcript-meta b { color: #f2f3f5; font-weight: 600; }
.transcript-meta b.bot { color: var(--gold-light); }
.transcript-meta .subtle { font-size: 0.75rem; color: #949ba4; }
.transcript-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript-embed { margin-top: 4px; padding: 6px 10px; border-left: 3px solid #4e5058; background: #2b2d31; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: #c9cdd3; }
.transcript-list .subtle { color: #949ba4; }
