/* マイキー（★）とカンペモード（kb-kanpe.js）。ソフトのページ [kb_app] だけで読み込む
 * - ページの中: ★ ボタン（.kba-star）・「★ カンペ」ボタン（.kba-kanpe-btn）。.kba.has-star は JS が ★ を差し込んだ印
 * - body の直下: カンペ（.kbk）・スマホの下の帯（.kbk-dock）・初めての案内（.kbk-toast）
 * 色は kb-app.css と同じ（琥珀 #E8A63F、文字 #1C2330、背景 #EEF1F4）
 */

/* ---------- ★ ボタン（44px 四方） ---------- */
.kba .kba-star,
.kbk .kbk-star {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	color: #8A929C;
	background: transparent;
	border: 0;
	border-radius: 10px;
	box-shadow: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.kba .kba-star:hover,
.kbk .kbk-star:hover {
	color: #505A68;
	background: #EEF1F4;
}

.kba .kba-star:focus-visible,
.kbk .kbk-star:focus-visible,
.kba .kba-kanpe-btn:focus-visible,
.kbk button:focus-visible,
.kbk-dock button:focus-visible,
.kbk-toast button:focus-visible {
	outline: 3px solid #E8A63F;
	outline-offset: 2px;
}

.kbk-star-icon path {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linejoin: round;
}

.kba .kba-star.is-on,
.kbk .kbk-star.is-on {
	color: #E8A63F;
}

.kba .kba-star.is-on:hover,
.kbk .kbk-star.is-on:hover {
	color: #E8A63F;
}

.kba-star.is-on .kbk-star-icon path,
.kbk-star.is-on .kbk-star-icon path {
	fill: #E8A63F;
	stroke: #B8812E;
}

/* 行: スマホは操作名の右上。行の高さが増えないよう、上下左右を少しはみ出させる */
.kba.has-star .kba-row {
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas:
		"name star"
		"keys act"
		"note note"
		"hint hint";
}

.kba.has-star .kba-row .kba-star {
	grid-area: star;
	align-self: start;
	margin: -11px -10px -11px 0;
}

/* まず覚えたいのカード: スマホは右下（「動きを見る」と同じ行）。操作名とキーの幅を減らさない */
.kba.has-star .kba-card {
	grid-template-areas:
		"name keys"
		"hint hint"
		"act star";
}

.kba.has-star .kba-card .kba-star {
	grid-area: star;
	justify-self: end;
	margin: -6px -10px -10px 0;
}

/* 「動きを見る」が無いカードは、右下の角に重ねて行を増やさない（:has() が使えないブラウザは上のまま） */
.kba.has-star .kba-card:not(:has(.kba-card-act)) {
	position: relative;
}

.kba.has-star .kba-card:not(:has(.kba-card-act)) .kba-card-hint {
	padding-right: 30px;
}

.kba.has-star .kba-card:not(:has(.kba-card-act)) .kba-star {
	position: absolute;
	right: 4px;
	bottom: 4px;
	margin: 0;
}

/* ---------- 「★ カンペ」ボタン（Windows/Mac の切り替えの隣） ---------- */
.kba .kba-kanpe-btn {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 4px;
	height: 46px;
	margin: 0;
	padding: 0 10px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	color: #1C2330;
	background: #FFFFFF;
	border: 2px solid #B9C2CD;
	border-radius: 12px;
	box-shadow: none;
	cursor: pointer;
}

.kba .kba-kanpe-btn:hover {
	border-color: #2A62A8;
}

.kba .kba-kanpe-btn .kbk-star-icon {
	width: 18px;
	height: 18px;
}

.kba .kba-kanpe-btn .kbk-star-icon path {
	fill: #E8A63F;
	stroke: #B8812E;
}

.kba .kba-kanpe-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	font-size: 12px;
	color: #FFFFFF;
	background: #1C2330;
	border-radius: 10px;
}

/* スマホは入力欄を狭くしすぎないよう、文字を隠して ★ と数だけにする（読み上げは aria-label） */
@media (max-width: 767px) {
	.kba .kba-kanpe-text {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
}

@media (min-width: 768px) {
	.kba .kba-kanpe-btn {
		order: -1;
		height: 48px;
		padding: 0 14px;
		font-size: 14px;
	}

	/* 行: 操作名 ／ キー ／ 動きを見る ／ ★ */
	.kba.has-star .kba-row {
		grid-template-columns: minmax(0, 1fr) 260px 130px 44px;
		grid-template-areas:
			"name keys act star"
			"note keys act star"
			"hint keys act star";
		column-gap: 16px;
		padding-right: 12px;
	}

	.kba.has-star .kba-row .kba-star {
		align-self: center;
		margin: 0;
	}

	/* カード: 右上 */
	.kba.has-star .kba-card {
		position: relative;
	}

	.kba.has-star .kba-card .kba-star {
		position: absolute;
		top: 8px;
		right: 8px;
		margin: 0;
	}

	.kba.has-star .kba-card .kba-card-keys {
		padding-right: 40px;
	}
}

/* ---------- スマホの下の帯 ---------- */
.kbk-dock {
	--kbk-ad: 0px;
	position: fixed;
	right: 12px;
	bottom: calc(12px + var(--kbk-ad) + env(safe-area-inset-bottom, 0px));
	left: 12px;
	z-index: 9990;
	display: flex;
	align-items: center;
	height: 48px;
	padding: 0 4px 0 0;
	font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
	color: #FFFFFF;
	background: #1C2330;
	border-radius: 12px;
	box-shadow: 0 6px 20px rgba(28, 35, 48, 0.28);
}

.kbk-dock[hidden] {
	display: none;
}

.kbk-dock button {
	margin: 0;
	padding: 0;
	font-family: inherit;
	color: inherit;
	background: none;
	border: 0;
	box-shadow: none;
	cursor: pointer;
}

.kbk-dock .kbk-dock-open {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: 8px;
	height: 48px;
	padding: 0 14px;
	font-size: 15px;
	font-weight: 700;
	text-align: left;
}

.kbk-dock .kbk-star-icon path,
.kbk-head .kbk-star-icon path {
	fill: #E8A63F;
	stroke: #E8A63F;
}

/* 「★ カンペ（3）｜毎日5問」の2つ（毎日5問が公開されているとき） */
.kbk-dock--two .kbk-dock-open {
	flex: 1 1 50%;
	padding-right: 8px;
}

.kbk-dock .kbk-dock-daily {
	position: relative;
	display: flex;
	flex: 1 1 50%;
	align-items: center;
	height: 48px;
	padding: 0 14px;
	font-size: 15px;
	font-weight: 700;
	color: #FFFFFF;
	text-decoration: none;
	border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.kbk-dock .kbk-dock-daily:hover,
.kbk-dock .kbk-dock-daily:visited {
	color: #FFFFFF;
}

.kbk-dock .kbk-dock-daily:focus-visible {
	outline: 3px solid #E8A63F;
	outline-offset: -3px;
}

.kbk-dock .kbk-dock-dot {
	width: 8px;
	height: 8px;
	margin: -10px 0 0 3px;
	background: #E8A63F;
	border-radius: 50%;
}

.kbk-dock .kbk-dock-dot[hidden] {
	display: none;
}

.kbk-dock .kbk-dock-todo {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.kbk-dock .kbk-dock-close {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	color: #B9C2CD;
	border-radius: 10px;
}

/* ---------- 初めて ★ を付けたときの案内 ---------- */
.kbk-toast {
	position: fixed;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	left: 50%;
	z-index: 9991;
	display: flex;
	align-items: center;
	gap: 4px;
	width: max-content;
	max-width: calc(100vw - 24px);
	padding: 6px 4px 6px 16px;
	font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
	color: #FFFFFF;
	background: #1C2330;
	border-radius: 12px;
	box-shadow: 0 6px 20px rgba(28, 35, 48, 0.28);
	transform: translateX(-50%);
}

html.kbk-has-dock .kbk-toast {
	bottom: calc(72px + var(--kbk-ad, 0px) + env(safe-area-inset-bottom, 0px));
}

.kbk-toast[hidden] {
	display: none;
}

html body .kbk-toast .kbk-toast-text {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.6;
}

.kbk-toast .kbk-toast-close {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	color: #B9C2CD;
	background: none;
	border: 0;
	cursor: pointer;
}

/* ---------- カンペ（全画面） ---------- */
html.kbk-lock,
html.kbk-lock body {
	overflow: hidden;
}

.kbk {
	position: fixed;
	inset: 0;
	z-index: 2147483647;
	display: flex;
	flex-direction: column;
	font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
	font-size: 16px;
	line-height: 1.5;
	color: #1C2330;
	background: #EEF1F4;
}

.kbk[hidden] {
	display: none;
}

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

/* テーマの見出し・段落・リストの装飾を打ち消す */
html body .kbk h2,
html body .kbk p,
html body .kbk ul,
html body .kbk li {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
	list-style: none;
}

html body .kbk h2::before,
html body .kbk h2::after,
html body .kbk li::before {
	content: none;
}

.kbk button {
	margin: 0;
	font-family: inherit;
	line-height: 1;
	box-shadow: none;
	cursor: pointer;
}

/* 上部（固定） */
.kbk .kbk-head {
	flex: 0 0 auto;
	padding: 10px 16px 12px;
	padding-top: calc(10px + env(safe-area-inset-top, 0px));
	background: #FFFFFF;
	border-bottom: 1px solid #D3D9E0;
}

.kbk .kbk-head-in,
.kbk .kbk-body-in {
	max-width: 1120px;
	margin: 0 auto;
}

.kbk .kbk-head-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

html body .kbk .kbk-title {
	min-width: 0;
	font-size: 18px;
	font-weight: 900;
	line-height: 1.4;
}

.kbk .kbk-title-sub {
	font-size: 14px;
	font-weight: 700;
	color: #505A68;
}

.kbk .kbk-close {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 4px;
	height: 44px;
	padding: 0 12px 0 8px;
	font-size: 14px;
	font-weight: 700;
	color: #1C2330;
	background: #EEF1F4;
	border: 0;
	border-radius: 10px;
}

.kbk .kbk-ctrls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 8px;
}

.kbk .kbk-seg {
	display: flex;
	padding: 3px;
	background: #EEF1F4;
	border-radius: 12px;
}

/* kb-shortcuts.css の .kbs-os-btn（青いボタン）より強くする */
.kbk .kbk-seg .kbk-seg-btn {
	height: 38px;
	min-width: 44px;
	padding: 0 10px;
	font-size: 13px;
	font-weight: 700;
	color: #1C2330;
	background: transparent;
	border: 0;
	border-radius: 9px;
}

.kbk .kbk-seg .kbk-seg-btn[aria-pressed="true"] {
	color: #FFFFFF;
	background: #1C2330;
}

.kbk .kbk-wake {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 44px;
	padding: 0 10px;
	font-size: 12px;
	font-weight: 700;
	color: #1C2330;
	background: #FFFFFF;
	border: 2px solid #B9C2CD;
	border-radius: 12px;
}

.kbk .kbk-wake-dot {
	width: 10px;
	height: 10px;
	background: #B9C2CD;
	border-radius: 50%;
}

.kbk .kbk-wake.is-on {
	border-color: #1E7A4A;
}

.kbk .kbk-wake.is-on .kbk-wake-dot {
	background: #1E7A4A;
}

/* 本体 */
.kbk .kbk-body {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}

html body .kbk .kbk-note {
	margin-bottom: 12px;
	padding: 10px 14px;
	font-size: 14px;
	font-weight: 700;
	color: #8A5A12;
	background: #FDF3E1;
	border-radius: 10px;
}

.kbk .kbk-list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 10px;
}

.kbk .kbk-item {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 52px 16px 16px;
	background: #FFFFFF;
	border-radius: 14px;
	transition: opacity 0.2s ease;
}

/* カンペの中で ★ を外した項目（閉じるまで薄く残す） */
.kbk .kbk-item.is-off {
	opacity: 0.45;
}

.kbk .kbk-item .kbk-star {
	position: absolute;
	top: 6px;
	right: 6px;
}

html body .kbk .kbk-item-name {
	font-size: 18px;
	font-weight: 700;
	line-height: 1.45;
}

/* 大きなキーキャップ（kb-app.css の .kba-key を拡大） */
.kbk .kba-keys {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
}

.kbk .kba-combo {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.kbk .kba-key {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	margin: 0;
	padding: 0 10px;
	font-family: inherit;
	font-size: 17px;
	font-weight: 700;
	line-height: 1;
	color: #1C2330;
	white-space: nowrap;
	background: #FFFFFF;
	border: 1px solid #B9C2CD;
	border-bottom-width: 4px;
	border-radius: 7px;
	box-shadow: none;
}

.kbk .kba-plus {
	font-size: 15px;
	color: #8A929C;
}

.kbk .kba-or {
	font-size: 13px;
	color: #8A929C;
}

.kbk .kba-na {
	font-size: 15px;
	color: #8A929C;
}

/* Windows / Mac（ページと同じ html[data-kbs-os]） */
.kbk .kba-keys--mac {
	display: none;
}

html[data-kbs-os="mac"] .kbk .kba-keys--mac {
	display: flex;
}

html[data-kbs-os="mac"] .kbk .kba-keys--win {
	display: none;
}

/* 文字サイズ: 大 */
html body .kbk[data-size="l"] .kbk-item-name {
	font-size: 22px;
}

.kbk[data-size="l"] .kba-key {
	min-width: 56px;
	height: 56px;
	padding: 0 14px;
	font-size: 24px;
	border-bottom-width: 5px;
	border-radius: 9px;
}

.kbk[data-size="l"] .kba-plus {
	font-size: 20px;
}

/* スマホは Windows を「Win」に縮める（ページの切り替えと同じ） */
.kbk .kbk-pc-only {
	display: none;
}

@media (min-width: 768px) {
	.kbk .kbk-pc-only {
		display: inline;
	}
}

/* 横向き・幅 720px 以上は2列 */
@media (orientation: landscape), (min-width: 720px) {
	.kbk .kbk-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 12px;
	}
}

@media (min-width: 768px) {
	.kbk .kbk-head {
		padding: 14px 24px;
	}

	.kbk .kbk-head-in {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 12px 20px;
	}

	.kbk .kbk-head-top {
		display: contents;
	}

	html body .kbk .kbk-title {
		flex: 1 1 auto;
		font-size: 22px;
	}

	.kbk .kbk-ctrls {
		order: 1;
		margin-top: 0;
	}

	.kbk .kbk-close {
		order: 2;
	}

	.kbk .kbk-seg .kbk-seg-btn {
		padding: 0 12px;
	}

	.kbk .kbk-wake {
		gap: 8px;
		padding: 0 14px;
		font-size: 13px;
	}

	.kbk .kbk-body {
		padding: 24px 24px 48px;
	}

	.kbk .kbk-item {
		padding: 18px 56px 20px 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.kbk .kbk-item {
		transition: none;
	}
}
