/*
 * 読み器(本にして読む)と PDF 変換(PDFにする)の頁の見た目(2026-10 の作り直し。Java の頁のひな形
 * server/src/main/jte/pages/reader.jte・pdf.jte が使う)。site.css の後に読む。
 *
 * 中の機械は converter.js で、要素の id(cv-…)はその約束なので変えない。読み器そのもの(.rd-…)と
 * 注文の帯(.cv-order)の見た目は contents/webtools/html2pdf/styles/reader.css が持つ。
 * PHP の頁の converter.css は読まない(古い頁の並び .cv-modes などの指定が当たらないように)。
 */

/* reader.css が使う変数。PHP の頁では static/style.css が決めている名前を、新しい色に当てる */
:root {
	--surface: #FFFFFF;
	--surface-muted: var(--soft);
	--surface-sunken: #EDF1EE;
	--ink-muted: var(--muted);
	--ink-faint: #7C8A83;
	--accent-hover: var(--accent-dark);
	--accent-ink: #FFFFFF;
	--focus: var(--accent-light);
	--danger: #B3261E;
	--danger-soft: #FDF0EF;
	--r-sm: 6px;
	--r-md: 10px;
	--r-lg: 16px;
	--r-full: 999px;
	--reading: #232826;
}

[hidden] { display: none !important; }

/* ================================================================ 本にして読む(読み器) */

/* 画面いっぱいの道具。上に URL の行、下は本(と右の設定の引き出し) */
body.rp {
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background: var(--reading);
}
.rp .rp-app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---- 上の行: cti.li・URL・本にする・EPUB を開く・設定 ---- */
.rp-head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 10px 12px;
	padding: 10px 16px;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
}
.rp-mark {
	flex: 0 0 auto;
	padding: 4px 4px;
	font-family: 'Inter', var(--sans);
	font-style: italic;
	font-weight: 800;
	font-size: 22px;
	line-height: 1.2;
	letter-spacing: -0.03em;
	color: var(--ground);
	text-decoration: none;
}
.rp-mark:hover { color: var(--accent); }
.rp-head .cv-input { flex: 1 1 240px; min-width: 0; }
.rp-url input {
	display: block;
	width: 100%;
	min-height: 44px;
	padding: 9px 16px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	background: var(--soft);
	color: var(--ink);
	font: inherit;
	font-size: 15px;
}
.rp-url input:focus { background: var(--bg); }
.rp-file { display: flex; align-items: center; gap: 10px; }
#cv-file-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 700;
}
.rp-file-note {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 13px;
	color: var(--muted);
}

/* 釦。丸い札 */
.rp-btn {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 44px;
	padding: 8px 16px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	font-size: 14px;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
}
.rp-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.rp-btn:disabled { opacity: .5; cursor: default; }
.rp-btn:disabled:hover { border-color: var(--line-strong); color: var(--ink); }
.rp-go { border-color: var(--accent); background: var(--accent); color: #FFFFFF; font-weight: 700; padding: 8px 20px; }
.rp-go:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFFFFF; }
.rp-go:disabled:hover { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.rp-more[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.rp-file .rp-btn { min-height: 36px; padding: 6px 14px; font-size: 13px; }

/* かかった時間と頁数。釦の行の右に小さく。広い画面だけ */
#cv-stat {
	flex: 0 0 auto;
	font-size: 11px;
	line-height: 1.35;
	color: var(--muted);
	text-align: end;
	white-space: pre-line;
	font-variant-numeric: tabular-nums;
}
#cv-stat:empty { display: none; }

/* ---- 進み具合・誤り ---- */
.rp-progress {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 12px;
	padding: 6px 16px;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
}
.cv-track {
	flex: 1 1 200px;
	height: 4px;
	border-radius: 999px;
	background: var(--surface-sunken);
	overflow: hidden;
}
#cv-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
#cv-status { font-size: 12px; color: var(--muted); }
#cv-status:empty { display: none; }
.rp-abort { min-height: 32px; padding: 4px 14px; font-size: 13px; }
.rp-error {
	flex: 0 0 auto;
	margin: 0;
	padding: 10px 16px;
	background: var(--danger-soft);
	border-bottom: 1px solid var(--line);
	border-left: 4px solid var(--danger);
	color: var(--danger);
	font-size: 14px;
	line-height: 1.6;
}

/* ---- 本 ---- */
.rp-main { flex: 1 1 auto; min-height: 0; display: flex; }
.rp-stage { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.rp-view {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	background: var(--reading);
	overflow: hidden;
}
/* 読み器は枠の高さに合わせる(reader.css の既定は単独で置いたときの高さ) */
.rp-view .rd { height: 100%; min-height: 0; }
.rp-view #cv-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--reading); }

/* まだ何も開いていないとき。真ん中に案内と例、その下に広告 */
.rp-empty {
	height: 100%;
	overflow: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 28px;
	padding: 24px 16px;
	color: var(--ground-muted);
	text-align: center;
}
.rp-empty-in { max-width: 34em; display: flex; flex-direction: column; gap: 12px; }
.rp-empty-lead { margin: 0; font-size: 17px; line-height: 1.8; color: #FFFFFF; }
.rp-samples { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; font-size: 14px; }
.rp-samples span { color: var(--ground-faint); }
.rp-samples a { color: var(--accent-light); }
.rp-empty-note { margin: 0; font-size: 13px; color: var(--ground-faint); }
#cv-ad { max-width: 100%; overflow: hidden; }

/* 携帯で PDF を画面の中に描けないとき */
#cv-open {
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 24px 16px;
	text-align: center;
	color: var(--ground-muted);
}
#cv-open-lead { margin: 0; font-size: 14px; line-height: 1.8; }
#cv-open a {
	min-width: 220px;
	padding: 12px 24px;
	border-radius: 999px;
	background: var(--accent);
	color: #FFFFFF;
	font-weight: 700;
	text-decoration: none;
}
#cv-open a#cv-open-docs { background: transparent; border: 1px solid #56625B; color: var(--ground-muted); font-weight: 400; }

/* 落としたファイル */
#cv-drop-overlay {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(22, 122, 64, .92);
	color: #FFFFFF;
	font-size: 16px;
	font-weight: 700;
	text-align: center;
	pointer-events: none;
}

/* 出力が PDF のとき、本の下に出す釦 */
.rp-actions {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 10px 16px;
	background: var(--bg);
	border-top: 1px solid var(--line);
}
.rp-actions a {
	padding: 8px 18px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	color: var(--ink);
	font-size: 14px;
	text-decoration: none;
}
.rp-actions a#cv-download { border-color: var(--accent); background: var(--accent); color: #FFFFFF; font-weight: 700; }

/* 紙の本の注文の見本(store=1&order=1)の帯。本の下に置く */
.rp .cv-order {
	flex: 0 0 auto;
	max-height: 45vh;
	overflow-y: auto;
	margin: 0;
	padding: 14px 16px;
	border-width: 1px 0 0;
	border-radius: 0;
}

/* ---- 設定の引き出し ---- */
.rp-drawer {
	flex: 0 0 340px;
	width: 340px;
	display: flex;
	flex-direction: column;
	gap: 22px;
	padding: 20px 22px 24px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--bg);
	border-left: 1px solid var(--line);
}
.rp-drawer-head { order: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rp-drawer-head h2 { margin: 0; font-size: 17px; line-height: 1.5; }
.rp-close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
}
.rp-close:hover { background: var(--soft); color: var(--ink); }
/* 欄は三つの箱(converter.js が出力・組版・PDF の指定を箱ごとに読む)に分かれているが、並べる順は欄ごとに決める */
#cv-output-options, #cv-book-options, #cv-pdf-options { display: contents; }
.rp-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rp-f-size { order: 1; }
.rp-f-dir { order: 2; }
.rp-f-cols { order: 3; }
.rp-f-format { order: 4; }
.rp-f-font { order: 5; }
.rp-f-em { order: 6; }
.rp-f-out { order: 7; }
.rp-group { order: 8; margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.rp-f-marks { order: 9; }
.rp-f-nup, .rp-f-pdfx { order: 10; }
.rp-note { order: 11; margin: 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.8; color: var(--muted); }
.rp-drawer-foot {
	order: 12;
	margin-top: auto;
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	padding-top: 16px;
	font-size: 13px;
}
.rp-drawer-foot a { color: var(--muted); }
.rp-version { flex-basis: 100%; font-family: var(--mono); font-size: 11px; color: var(--ink-faint); overflow-wrap: anywhere; }
.rp-label { font-size: 13px; line-height: 1.5; color: var(--muted); }
.rp-select, .pc-select {
	width: 100%;
	min-height: 44px;
	padding: 9px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 10px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	font-size: 15px;
}

/* 択一の札(tool.js が select[data-pills] から作る。値の持ち主は select のまま) */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill, .pill-more {
	min-height: 40px;
	padding: 7px 14px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
}
.pill:hover, .pill-more:hover { border-color: var(--accent); }
.pill[aria-pressed="true"], .pill-more.on {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent-dark);
	font-weight: 700;
}
.pill-more { max-width: 100%; padding-right: 10px; }

/* 狭い窓では、引き出しは本の上に重ねる(本の幅を削らない)。後ろを暗くし、押せば閉じる */
.rp-backdrop { display: none; }
@media (max-width: 899px) {
	.rp-drawer {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 95;
		width: min(360px, 100%);
		padding-bottom: calc(24px + env(safe-area-inset-bottom));
		border-left: 0;
		box-shadow: -12px 0 32px rgba(0, 0, 0, .35);
	}
	body.rp-drawer-open .rp-backdrop {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 94;
		background: rgba(10, 14, 12, .45);
	}
	#cv-stat { display: none; }
}

/* 販売所から開いた本(store=1)。本と、読書窓の札(めくる・文字の大きさなど)だけを残す。
   入力の行・設定・案内は出さない(隠すのは見た目だけで、できることは変わらない) */
body.store-reader .rp-head,
body.store-reader #cv-settings,
body.store-reader .rp-backdrop { display: none !important; }

/* 携帯。上の行は 2 段(cti.li と URL / 本にする・EPUB を開く・設定) */
@media (max-width: 640px) {
	.rp-head { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
	.rp-mark { font-size: 20px; }
	.rp-head .cv-input { flex: 1 1 calc(100% - 80px); }
	/* iOS は 16px より小さい欄に触れると画面を拡大する */
	.rp-url input { font-size: 16px; padding: 8px 14px; }
	.rp-go { flex: 1 1 auto; }
	.rp-btn { padding: 8px 14px; }
	.rp-file-note { display: none; }
	.rp-progress { padding: 6px 12px; }
}

/* ---- 「PDF で保存」の知らせ(converter.js の .cv-pdf-note)。画面の下の真ん中に浮かべる ---- */
.cv-pdf-note {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 100;
	width: min(440px, calc(100% - 32px));
	transform: translateX(-50%);
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 48px 14px 18px;
	border-radius: 14px;
	background: var(--bg);
	color: var(--ink);
	box-shadow: 0 10px 32px rgba(0, 0, 0, .35);
	font-size: 14px;
	line-height: 1.6;
}
.cv-pdf-note-msg { margin: 0; font-weight: 700; }
.cv-pdf-note-busy .cv-pdf-note-msg::before {
	content: "";
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-right: 8px;
	vertical-align: -1px;
	border: 2px solid var(--line-strong);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: cv-spin .8s linear infinite;
}
@keyframes cv-spin { to { transform: rotate(360deg); } }
.cv-pdf-note-fail .cv-pdf-note-msg { color: var(--danger); font-weight: 400; }
.cv-pdf-note-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.cv-pdf-note-acts a {
	flex: 1 1 auto;
	padding: 9px 16px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	color: var(--ink);
	text-align: center;
	text-decoration: none;
}
.cv-pdf-note-acts a.cv-pdf-note-dl { border-color: var(--accent); background: var(--accent); color: #FFFFFF; font-weight: 700; }
.cv-pdf-note-fine { margin: 0; font-size: 12px; color: var(--muted); }
.cv-pdf-note-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}
.cv-pdf-note-close:hover { background: var(--soft); color: var(--ink); }
@media (max-width: 640px) {
	.cv-pdf-note { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

.rp-noscript { margin: 0; padding: 12px 16px; background: var(--bg); color: var(--danger); }

/* ================================================================ PDFにする */

body.pc-page { background: var(--bg); }
body.pc-page main.pc { background: var(--soft); }
.pc {
	display: block;
	padding: 40px max(24px, calc((100% - var(--wide)) / 2 + 24px)) 64px;
}
.pc-head h1 { margin: 0 0 8px; font-family: var(--mincho); font-weight: 800; font-size: 34px; line-height: 1.4; }
.pc-head p { margin: 0; font-size: 16px; color: var(--muted); }
.pc-grid { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.pc-card {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 22px;
	padding: 28px;
	border: 1px solid var(--line);
	border-radius: 20px;
	background: var(--bg);
}
.pc-in { flex: 3 1 520px; }
.pc-out { flex: 2 1 340px; }
.pc-out h2 { margin: 0; font-size: 17px; line-height: 1.5; }

/* 変換するもの(ウェブページ・ファイル)。札で切り替える */
.pc-tabs {
	align-self: flex-start;
	max-width: 100%;
	display: flex;
	gap: 4px;
	padding: 4px;
	border-radius: 12px;
	background: var(--surface-sunken);
}
.pc-tabs .cv-mode {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 22px;
	border-radius: 9px;
	color: var(--muted);
	font-size: 15px;
	line-height: 1.4;
	text-decoration: none;
	white-space: nowrap;
}
.pc-tabs .cv-mode:hover { color: var(--ink); }
.pc-tabs .cv-mode[aria-selected="true"] {
	background: var(--bg);
	color: var(--ink);
	font-weight: 700;
	box-shadow: 0 1px 3px rgba(15, 26, 21, .15);
}

.pc-url { display: flex; flex-direction: column; gap: 6px; }
.pc-label { font-size: 13px; line-height: 1.5; color: var(--muted); }
.pc-url input {
	width: 100%;
	min-height: 48px;
	padding: 11px 14px;
	border: 1px solid var(--line-strong);
	border-radius: 12px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	font-size: 16px;
}

#cv-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 36px 24px;
	border: 2px dashed #B8C6BD;
	border-radius: 16px;
	background: #FAFCFA;
	color: var(--accent);
	text-align: center;
}
.pc-drop-title { margin: 0; font-size: 17px; font-weight: 700; color: var(--ink); }
.pc-drop-types { margin: 0; font-size: 13px; color: var(--muted); }
#cv-drop #cv-file-name { max-width: 100%; color: var(--ink); }

.pc-settings { display: flex; flex-direction: column; gap: 16px; }
.pc-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pc-print { border-top: 1px solid var(--line); padding-top: 8px; }
.pc-print summary { cursor: pointer; padding: 8px 0; font-size: 15px; font-weight: 700; }
.pc-print .pc-fields { padding-top: 8px; }

.pc-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 22px;
	border: 1px solid var(--line-strong);
	border-radius: 12px;
	background: var(--bg);
	color: var(--ink);
	font: inherit;
	font-size: 15px;
	line-height: 1.4;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}
.pc-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.pc-quiet { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.pc-primary { border-color: var(--accent); background: var(--accent); color: #FFFFFF; font-weight: 700; }
.pc-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFFFFF; }
.pc-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pc-go #cv-go { min-height: 52px; padding: 14px 36px; font-size: 17px; }
.pc-go #cv-go:disabled { opacity: .55; cursor: default; }
/* 中止は変換している間だけ出す */
.pc-go #cv-abort:disabled { display: none; }
.pc-progress { display: flex; flex-direction: column; gap: 6px; }
.pc-progress .cv-track { flex: 0 0 auto; height: 6px; }
.pc-error {
	margin: 0;
	padding: 10px 14px;
	border-left: 4px solid var(--danger);
	border-radius: 8px;
	background: var(--danger-soft);
	color: var(--danger);
	font-size: 14px;
	line-height: 1.6;
	overflow-wrap: anywhere;
}

/* できた PDF */
.pc-view {
	position: relative;
	flex: 1 1 auto;
	min-height: 300px;
	display: flex;
	flex-direction: column;
	border-radius: 12px;
	background: var(--surface-sunken);
	overflow: hidden;
}
.pc-empty {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	padding: 24px;
	text-align: center;
	color: var(--muted);
	font-size: 14px;
}
.pc-empty p { margin: 0; }
/* 白紙の見本(飾り) */
.pc-sheet {
	width: 150px;
	height: 212px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px 16px;
	background: var(--bg);
	box-shadow: 0 6px 18px rgba(15, 26, 21, .18);
}
.pc-sheet i { display: block; height: 6px; border-radius: 2px; background: var(--line-strong); }
.pc-sheet i:first-child { width: 70%; height: 10px; margin-bottom: 6px; background: var(--ink); }
.pc-sheet i:nth-child(3) { width: 92%; }
.pc-sheet i:nth-child(4) { width: 60%; }
.pc-sheet i.pc-sheet-fig { height: 46px; background: var(--line); }
.pc-view #cv-frame { display: block; width: 100%; height: min(70vh, 760px); min-height: 360px; border: 0; background: var(--surface-sunken); }
.pc-view .rd { height: min(70vh, 760px); min-height: 360px; }
.pc-view #cv-open { color: var(--ink); }
.pc-view #cv-open a#cv-open-docs { border-color: var(--line-strong); color: var(--ink); }
.pc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 14px; }
.pc-meta:has(#cv-result-name:empty):has(#cv-stat:empty) { display: none; }
#cv-result-name { font-weight: 700; overflow-wrap: anywhere; }
.pc-meta #cv-stat { font-size: 13px; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pc-actions .pc-btn { flex: 1 1 auto; }
.pc-fine { margin: 0; font-size: 13px; line-height: 1.8; color: var(--muted); }
.pc-noscript { margin: 16px 0 0; color: var(--danger); }

@media (max-width: 720px) {
	.pc { padding: 28px 16px 48px; }
	.pc-head h1 { font-size: 28px; }
	.pc-head p { font-size: 15px; }
	.pc-grid { margin-top: 20px; gap: 16px; }
	.pc-card { padding: 20px 16px; gap: 18px; border-radius: 16px; }
	.pc-in, .pc-out { flex-basis: 100%; }
	.pc-tabs { align-self: stretch; }
	.pc-tabs .cv-mode { flex: 1 1 0; padding: 10px 12px; }
	.pc-fields { grid-template-columns: minmax(0, 1fr); }
	#cv-drop { padding: 28px 16px; }
	.pc-go #cv-go { flex: 1 1 auto; }
	.pc-view #cv-frame, .pc-view .rd { height: 60vh; min-height: 300px; }
}
