/**
 * [kantanbond_reference] フロントエンドスタイル
 *
 * @package KantanBond
 */

.kantanbond-reference {
	box-sizing: border-box;
	isolation: isolate;
	margin: 1.5em 0;
	max-width: 76rem;
	min-width: 0;
	width: 100%;
}

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

.kantanbond-reference--align-center {
	margin-left: auto;
	margin-right: auto;
}

.kantanbond-reference--align-right {
	margin-left: auto;
	margin-right: 0;
}

.kantanbond-reference--notice {
	color: #646970;
}

/* アイコン実体（symbol）置き場。描画しない */
.kantanbond-reference__sprite {
	display: none;
}

/* 2 カラム（左サイドバー＋本文） */

.kantanbond-reference__layout {
	display: block;
}

@media (min-width: 1024px) {
	/*
	 * ビューポートが広くても、置かれた枠（ページビルダーの狭いカラム等）が狭いことはある。
	 * 2 カラムに足りない幅では折り返して縦積みになるよう、flex-wrap で組む。
	 */
	.kantanbond-reference__layout {
		align-items: flex-start;
		display: flex;
		flex-wrap: wrap;
		gap: 1.5rem;
	}

	.kantanbond-reference__sidebar {
		/* 2 カラムのときは本文（grow 999）に押されて 17rem 前後、縦積みのときは全幅 */
		flex: 1 1 17rem;
		position: sticky;
		top: 1.5rem;
	}

	.kantanbond-reference__main {
		/* 本文を優先して広げる（縦積みになったときは 100% 幅） */
		flex: 999 1 22rem;
	}

	.kantanbond-reference__layout--no-sidebar .kantanbond-reference__main {
		flex-basis: 100%;
	}
}

.kantanbond-reference__main {
	min-width: 0;
	width: 100%;
}

/* 目次（PC は常時展開・狭い画面は折りたたみ） */

.kantanbond-reference__toc {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 0.75rem;
	margin-bottom: 1.25rem;
	padding: 1rem 1.25rem;
}

.kantanbond-reference__toc-summary {
	cursor: pointer;
	font-size: 0.9375rem;
	font-weight: 700;
	list-style: none;
}

.kantanbond-reference__toc-summary::-webkit-details-marker {
	display: none;
}

.kantanbond-reference__toc-summary::before {
	color: #94a3b8;
	content: "\25b6";
	display: inline-block;
	font-size: 0.7rem;
	margin-right: 0.4rem;
	transition: transform 0.15s ease;
}

.kantanbond-reference__toc[open] > .kantanbond-reference__toc-summary::before {
	transform: rotate(90deg);
}

@media (min-width: 1024px) {
	.kantanbond-reference__toc {
		max-height: calc(100vh - 3rem);
		overflow-y: auto;
	}

	.kantanbond-reference__toc-summary {
		display: none;
	}
}

.kantanbond-reference__toc-nav {
	min-width: 0;
}

.kantanbond-reference__toc-head {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	justify-content: space-between;
	margin-bottom: 0.5rem;
}

.kantanbond-reference__toc-title {
	font-size: 1rem;
	font-weight: 700;
	margin: 0;
}

.kantanbond-reference__toggle-all {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 9999px;
	color: #334155;
	cursor: pointer;
	font-size: 0.8125rem;
	line-height: 1.4;
	padding: 0.3rem 0.9rem;
}

.kantanbond-reference__toggle-all:hover,
.kantanbond-reference__toggle-all:focus-visible {
	background: #eef2ff;
	border-color: #a5b4fc;
	color: #3730a3;
}

.kantanbond-reference__toc-list,
.kantanbond-reference__toc-sections {
	list-style: none;
	margin: 0;
	padding: 0;
}

.kantanbond-reference__toc-chapter + .kantanbond-reference__toc-chapter {
	margin-top: 0.75rem;
}

.kantanbond-reference__toc-chapter-title {
	color: #4338ca;
	display: block;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.kantanbond-reference__toc-sections {
	margin-top: 0.25rem;
}

.kantanbond-reference__toc-section a {
	border-radius: 0.375rem;
	color: #334155;
	display: block;
	font-size: 0.875rem;
	line-height: 1.5;
	padding: 0.3rem 0.5rem;
	text-decoration: none;
}

.kantanbond-reference__toc-section a:hover,
.kantanbond-reference__toc-section a:focus-visible {
	background: #eef2ff;
	color: #3730a3;
}

/* 登場人物 */

.kantanbond-reference__characters {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 0.75rem;
	margin-bottom: 1.25rem;
	padding: 1rem 1.25rem;
}

.kantanbond-reference__characters-title {
	font-size: 0.875rem;
	font-weight: 700;
	margin: 0 0 0.75rem;
}

.kantanbond-reference__characters-list {
	display: grid;
	gap: 0.75rem;
	grid-template-columns: 1fr;
	list-style: none;
	margin: 0;
	padding: 0;
}

@media (min-width: 640px) and (max-width: 1023px) {
	.kantanbond-reference__characters-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.kantanbond-reference__character {
	align-items: flex-start;
	display: flex;
	gap: 0.75rem;
	margin: 0;
}

.kantanbond-reference__character-body {
	min-width: 0;
}

.kantanbond-reference__character-name {
	font-size: 0.9375rem;
	font-weight: 700;
	margin: 0;
}

.kantanbond-reference__character-role {
	color: #64748b;
	font-size: 0.75rem;
	font-weight: 400;
	margin-left: 0.4rem;
}

.kantanbond-reference__character-description {
	color: #475569;
	font-size: 0.8125rem;
	line-height: 1.7;
	margin: 0.2rem 0 0;
	overflow-wrap: anywhere;
}

/* 章（アコーディオン） */

.kantanbond-reference__chapter {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 0.75rem;
	margin-bottom: 0.75rem;
	overflow: hidden;
}

.kantanbond-reference__chapter-summary {
	align-items: baseline;
	cursor: pointer;
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.75rem;
	list-style: none;
	padding: 0.9rem 1.25rem;
}

.kantanbond-reference__chapter-summary::-webkit-details-marker {
	display: none;
}

.kantanbond-reference__chapter-summary::before {
	color: #94a3b8;
	content: "\25b6";
	font-size: 0.7rem;
	transition: transform 0.15s ease;
}

.kantanbond-reference__chapter[open] > .kantanbond-reference__chapter-summary::before {
	transform: rotate(90deg);
}

.kantanbond-reference__chapter-title {
	font-size: 1.0625rem;
	font-weight: 700;
}

.kantanbond-reference__chapter-subtitle {
	color: #64748b;
	font-size: 0.8125rem;
}

.kantanbond-reference__chapter-body {
	border-top: 1px solid #e2e8f0;
	padding: 0.5rem 1.25rem 1.25rem;
}

/* 節 */

.kantanbond-reference__section {
	padding-top: 1.25rem;
	scroll-margin-top: 5rem;
}

.kantanbond-reference__section + .kantanbond-reference__section {
	border-top: 1px dashed #e2e8f0;
}

.kantanbond-reference__section-title {
	font-size: 1rem;
	font-weight: 700;
	margin: 0;
}

.kantanbond-reference__section-lead {
	color: #64748b;
	font-size: 0.8125rem;
	line-height: 1.7;
	margin: 0.25rem 0 0;
}

.kantanbond-reference__lines {
	margin-top: 1rem;
}

/* 発言 */

.kantanbond-reference__line {
	align-items: flex-start;
	display: flex;
	gap: 0.75rem;
}

.kantanbond-reference__line + .kantanbond-reference__line,
.kantanbond-reference__line + .kantanbond-reference__tip,
.kantanbond-reference__tip + .kantanbond-reference__line,
.kantanbond-reference__tip + .kantanbond-reference__tip {
	margin-top: 1rem;
}

.kantanbond-reference__avatar {
	border-radius: 9999px;
	flex-shrink: 0;
	height: 2.75rem;
	width: 2.75rem;
}

.kantanbond-reference__avatar--hakase {
	box-shadow: 0 0 0 2px #bae6fd;
}

.kantanbond-reference__avatar--biz {
	box-shadow: 0 0 0 2px #fecdd3;
}

.kantanbond-reference__line-body {
	flex: 1 1 auto;
	min-width: 0;
}

.kantanbond-reference__speaker {
	font-size: 0.75rem;
	font-weight: 700;
	margin: 0 0 0.25rem;
}

.kantanbond-reference__line--hakase .kantanbond-reference__speaker {
	color: #0369a1;
}

.kantanbond-reference__line--biz .kantanbond-reference__speaker {
	color: #be123c;
}

.kantanbond-reference__bubble {
	border: 1px solid;
	border-radius: 1rem;
	border-top-left-radius: 0.25rem;
	padding: 0.6rem 0.9rem;
}

.kantanbond-reference__bubble p {
	line-height: 1.85;
	margin: 0;
	overflow-wrap: anywhere;
	white-space: pre-line;
}

.kantanbond-reference__line--hakase .kantanbond-reference__bubble {
	background: #f0f9ff;
	border-color: #bae6fd;
	color: #0c4a6e;
}

.kantanbond-reference__line--biz .kantanbond-reference__bubble {
	background: #fff1f2;
	border-color: #fecdd3;
	color: #881337;
}

/* ツールバー（文字サイズ・読み上げ） */

.kantanbond-reference__toolbar {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	margin-bottom: 0.75rem;
	padding: 0.75rem 1rem;
}

.kantanbond-reference__toolbar-label {
	color: #475569;
	font-size: 0.75rem;
	white-space: nowrap;
}

.kantanbond-reference__toolbar-label--tts {
	align-items: center;
	color: #3730a3;
	display: inline-flex;
	font-weight: 700;
	gap: 0.25rem;
}

.kantanbond-reference__toolbar-label--tts svg {
	height: 0.9rem;
	width: 0.9rem;
}

.kantanbond-reference__size {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.kantanbond-reference__size-group {
	border: 1px solid #cbd5e1;
	border-radius: 0.375rem;
	display: inline-flex;
	overflow: hidden;
}

.kantanbond-reference__size-button {
	background: #ffffff;
	border: 0;
	color: #334155;
	cursor: pointer;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.4;
	padding: 0.3rem 0.7rem;
}

.kantanbond-reference__size-button + .kantanbond-reference__size-button {
	border-left: 1px solid #cbd5e1;
}

.kantanbond-reference__size-button:hover {
	background: #f1f5f9;
}

.kantanbond-reference__size-button.is-active {
	background: #4f46e5;
	color: #ffffff;
}

.kantanbond-reference__tts {
	align-items: center;
	background: #eef2ff;
	border: 1px solid #c7d2fe;
	border-radius: 0.5rem;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 0.75rem;
	padding: 0.5rem 0.75rem;
}

.kantanbond-reference__tts[hidden] {
	display: none;
}

.kantanbond-reference__tts-buttons,
.kantanbond-reference__tts-rate {
	align-items: center;
	display: flex;
	gap: 0.4rem;
	/* 狭い画面でボタン列が縮まずに横スクロールを生まないようにする */
	min-width: 0;
}

.kantanbond-reference__tts-buttons {
	flex-wrap: wrap;
}

/* 「速さ」ラベルとプルダウンは必ず同じ行に並べる（折り返すと 2 行に割れて見える） */
.kantanbond-reference__tts-rate {
	flex-wrap: nowrap;
}

.kantanbond-reference__button {
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 0.375rem;
	color: #334155;
	cursor: pointer;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.4;
	min-height: 2rem;
	padding: 0.35rem 0.8rem;
}

.kantanbond-reference__button:hover:not(:disabled) {
	background: #f8fafc;
}

.kantanbond-reference__button:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.kantanbond-reference__button--primary {
	background: #4f46e5;
	border-color: #4338ca;
	color: #ffffff;
}

.kantanbond-reference__button--primary:hover:not(:disabled) {
	background: #4338ca;
}

.kantanbond-reference__button--autopilot {
	border-color: #a5b4fc;
	color: #3730a3;
}

.kantanbond-reference__button--autopilot.is-on {
	background: #4f46e5;
	border-color: #4338ca;
	color: #ffffff;
}

/*
 * テーマ側の `select { width: 100% }`（Cocoon 等で多い）を打ち消す。
 * 効かせないと速さのプルダウンが 1 行を占有し、ラベルと 2 行に割れて見える。
 */
.kantanbond-reference__select {
	background-color: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 0.375rem;
	box-sizing: border-box;
	display: inline-block;
	flex: 0 0 auto;
	font-size: 0.75rem;
	height: auto;
	margin: 0;
	max-width: 100%;
	min-height: 2rem;
	padding: 0.2rem 1.4rem 0.2rem 0.4rem;
	width: auto;
}

.kantanbond-reference__tts-status {
	color: #334155;
	font-size: 0.75rem;
}

.kantanbond-reference__tts-unsupported {
	background: #f8fafc;
	border: 1px solid #cbd5e1;
	border-radius: 0.375rem;
	color: #475569;
	font-size: 0.75rem;
	line-height: 1.7;
	margin: 0;
	padding: 0.5rem 0.75rem;
}

.kantanbond-reference__tts-unsupported[hidden] {
	display: none;
}

/* 行単位の再生ボタン */

.kantanbond-reference__play {
	align-items: center;
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 9999px;
	color: #64748b;
	cursor: pointer;
	display: inline-flex;
	height: 1.4rem;
	justify-content: center;
	margin-left: 0.4rem;
	opacity: 0.7;
	padding: 0;
	vertical-align: middle;
	width: 1.4rem;
}

.kantanbond-reference__play[hidden] {
	display: none;
}

.kantanbond-reference__play:hover,
.kantanbond-reference__play:focus-visible {
	background: #eef2ff;
	color: #3730a3;
	opacity: 1;
}

.kantanbond-reference__play svg {
	height: 0.75rem;
	width: 0.75rem;
}

/* 読み上げ中の行（色だけでなく太い枠でも示す） */

.kantanbond-reference__line--reading,
.kantanbond-reference__tip.kantanbond-reference__line--reading {
	border-radius: 0.875rem;
	outline: 3px solid #4f46e5;
	outline-offset: 5px;
}

/* 文字サイズ */

.kantanbond-reference__main--font-sm .kantanbond-reference__lines {
	font-size: 0.875rem;
}

.kantanbond-reference__main--font-md .kantanbond-reference__lines {
	font-size: 1rem;
}

.kantanbond-reference__main--font-lg .kantanbond-reference__lines {
	font-size: 1.125rem;
}

.kantanbond-reference__main--font-xl .kantanbond-reference__lines {
	font-size: 1.25rem;
}

.kantanbond-reference__main--font-lg .kantanbond-reference__tip-text,
.kantanbond-reference__main--font-xl .kantanbond-reference__tip-text {
	font-size: 1rem;
}

/* ヒント */

.kantanbond-reference__tip {
	background: #fffbeb;
	border: 1px solid #fcd34d;
	border-radius: 0.75rem;
	padding: 0.75rem 1rem;
}

.kantanbond-reference__tip-title {
	color: #78350f;
	font-size: 0.875rem;
	font-weight: 700;
	margin: 0;
}

.kantanbond-reference__tip-text {
	color: #92400e;
	font-size: 0.875rem;
	line-height: 1.8;
	margin: 0.35rem 0 0;
	white-space: pre-line;
}
