:root {
	/* New Warm Muted Tone Palette */
	--bg: #f4f4f1;
	--bg-card: #fffefa;
	--text: #3f4650;
	--text-muted: #77818a;
	--border: #d7dbd7;
	--accent: #718493;
	--accent-hover: #5a6e7d;
	/* Primary Accent Colors for contrast */
	--primary: #2980b9;
	--primary-hover: #1f6391;
	--accent-gradient: linear-gradient(135deg, var(--accent), var(--primary));
	--impl-bg: #e9ebe8;
	--impl-border: #d7dbd7;
	--header-h: 60px;
	--radius: 0px;
	/* Typography */
	--font-sans: 'Noto Sans JP', var(--font-atkinson), -apple-system, BlinkMacSystemFont, sans-serif;
	--font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
	--bg: #24292d;
	--bg-card: #30373b;
	--text: #d9ddd9;
	--text-muted: #aab3b5;
	--border: #4a5358;
	--accent: #9aaeb7;
	--accent-hover: #b0c0c7;
	/* Primary Accent Colors for dark mode */
	--primary: #4582b5;
	--primary-hover: #366d9c;
	--accent-gradient: linear-gradient(135deg, #4b7899, #4582b5);
	--impl-bg: #1e2226;
	--impl-border: #4a5358;
}

* { box-sizing: border-box; }

/* Font size scaling */
html.font-sm { font-size: 14px; }
html.font-base { font-size: 16px; }
html.font-lg { font-size: 18px; }

html, body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	line-height: 1.6;
}
body { position: relative; overflow-x: hidden; }

/* bg-orb removed to keep flat design */
.bg-orb { display: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; position: relative; z-index: 1; }

/* 
 * UI Components 
 */
.sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; }
.brand-mark {
	width: 36px; height: 36px; display: grid; place-items: center;
	border-radius: var(--radius); color: var(--primary);
	background: rgba(41, 128, 185, 0.1); border: 1px solid rgba(41, 128, 185, 0.2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 800; }
.brand-sub { font-size: .72rem; color: var(--text-muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* Layout App */
.layout-app {
	margin: 0; padding: 0; height: 100vh; overflow: hidden;
	display: flex; flex-direction: column;
}

.global-header {
	height: 56px; width: 100%; flex-shrink: 0;
	background: var(--header-bg); backdrop-filter: blur(14px);
	border-bottom: 1px solid var(--border);
	z-index: 50; position: relative;
}

.global-header-inner {
	max-width: 1360px; margin: 0 auto; height: 100%;
	display: flex; align-items: center; justify-content: space-between;
}

.global-header-sidebar {
	width: 260px; height: 100%; display: flex; align-items: center;
	padding: 0 1.5rem; border-right: 1px solid var(--border);
	flex-shrink: 0; gap: 1rem;
}

.global-header-main {
	flex: 1; height: 100%; display: flex; align-items: center;
}

.header-main-inner {
	width: 100%; padding: 0 2.5rem;
}

.global-header-actions {
	display: flex; align-items: center; gap: 1rem;
}

.header-action-btn {
	display: flex; align-items: center; justify-content: center;
	width: 36px; height: 36px; border-radius: 50%;
	border: 1px solid transparent; background: transparent; color: var(--text-muted);
	cursor: pointer; transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.header-action-btn:hover {
	color: var(--primary); background: rgba(148, 163, 184, 0.08); border-color: var(--border);
}
.font-size-icon { font-family: ui-serif, Georgia, serif; font-size: 1.15rem; font-weight: 800; line-height: 1; }

#theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] #theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] #theme-toggle .icon-moon { display: block; }

.app-container {
	display: flex; flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; position: relative; z-index: 10;
	overflow: hidden;
}

.app-sidebar {
	width: 260px; height: 100%;
	background: var(--bg-card);
	border-right: 1px solid var(--border);
	display: flex; flex-direction: column; flex-shrink: 0;
	z-index: 40; transition: transform 0.3s ease;
}

.sidebar-header-mobile-only {
	display: none; padding: 1rem; justify-content: flex-end;
}

.sidebar-nav {
	padding: 1rem 0;
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.nav-group {
	display: flex;
	flex-direction: column;
}

.nav-group-title {
	font-size: 0.75rem; /* text-xs */
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em; /* tracking-widest */
	color: var(--text-muted);
	padding: 0.5rem 1rem;
	margin-bottom: 0.25rem;
}

.nav-group-title.bordered {
	border-top: 1px solid var(--border);
	padding-top: 1rem;
	margin-top: 0.5rem;
}

.nav-group a {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 1rem;
	color: var(--text);
	text-decoration: none;
	font-size: 0.875rem; /* text-sm */
	font-weight: 500;
	border-radius: 0; /* rounded-none */
	transition: background-color 0.2s, color 0.2s;
	border-left: 3px solid transparent;
}

.nav-group a:hover {
	background: var(--impl-bg);
}

.nav-group a svg {
	width: 20px;
	height: 20px;
	color: var(--text-muted);
	flex-shrink: 0;
	transition: color 0.2s;
}

.nav-group a:hover svg {
	color: var(--primary);
}

.nav-group a.is-active {
	background: var(--impl-bg);
	border-left-color: var(--primary);
	font-weight: 600;
}

.nav-group a.is-active svg {
	color: var(--primary);
}

.nav-external {
	font-size: 0.8rem;
	color: var(--accent) !important;
	background: var(--impl-bg) !important;
	border-left-color: var(--accent) !important;
	margin: 0.5rem 1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius) !important;
	justify-content: center;
} 

/* Moved to global-header */

.app-main {
	flex: 1; height: 100%; overflow-y: auto;
	display: flex; flex-direction: column; background: transparent;
}

.app-main .main { flex: 1; padding: 2.5rem 2.5rem 4rem; }

.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 0 2.5rem; color: var(--text-muted); font-size: .9rem; }
.footer-inner { display: flex; flex-direction: column; gap: .25rem; }

.mobile-menu-btn {
	display: none; /* Desktop hidden */
}

.mobile-close-btn {
	background: none; border: none; color: var(--text); cursor: pointer;
	padding: 0.25rem; display: flex; align-items: center; justify-content: center;
}

.mobile-close-btn { display: none; }
.mobile-brand-title { font-weight: 800; font-size: 1.1rem; }

.mobile-overlay {
	display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
	background: rgba(0, 0, 0, 0.5); z-index: 45; opacity: 0; transition: opacity 0.3s ease;
}
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

.hero, .page-head { margin-bottom: 1.5rem; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-size: .75rem; font-weight: 800; margin: 0 0 .4rem; }
h1 { font-size: clamp(1.7rem, 3vw, 2.4rem); margin: 0 0 .55rem; font-weight: 800; }
h2 { font-size: 1.15rem; margin: 0 0 .65rem; }

/* Decorative accent line for section headings */
.why-panel-title,
.compare-title,
.card-body h2,
.section-head h2 {
	position: relative;
	padding-bottom: 0.5rem;
	margin-bottom: 1rem;
}
.why-panel-title::after,
.compare-title::after,
.card-body h2::after,
.section-head h2::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 3.5rem;
	height: 4px;
	background: var(--accent-gradient);
	border-radius: var(--radius);
}
.lede { color: var(--text-muted); margin: 0 0 .75rem; }
.result-desc { color: var(--text-muted); margin: 0 0 1rem; }

.grid { display: grid; gap: 1rem; }
.pattern-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-grid .card { min-width: 0; }

.card {
	background: linear-gradient(180deg, rgba(255,255,255,.03), transparent 40%), var(--bg-card);
	border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-body { padding: 1.15rem 1.25rem 1.3rem; }
.pattern-card { color: inherit; text-decoration: none; transition: transform .15s ease, border-color .15s ease; }
.pattern-card:hover { transform: translateY(-3px); border-color: rgba(167,139,250,.5); text-decoration: none; color: inherit; }
.pattern-card h2 { font-size: 1.15rem; }
.pattern-card .takeaway {
	margin: 0.35rem 0 0.5rem;
	font-size: 0.98rem;
	font-weight: 700;
	color: var(--text);
	line-height: 1.45;
}
.pattern-card .card-summary { margin: 0 0 0.75rem; font-size: .9rem; }
.takeaway-inline {
	margin: 0 0 0.75rem;
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--text);
}
.card-link { font-size: .88rem; font-weight: 700; color: var(--accent); }

/* 操作 → クラスの軌跡 */
.call-trace {
	margin-top: 1rem;
	padding: 0.85rem 1rem;
	border-radius: var(--radius);
	background: var(--impl-bg);
	border: 1px dashed var(--border);
}
.call-trace-label {
	margin: 0 0 0.5rem;
	font-size: 0.75rem;
	font-weight: 800;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--accent);
}
.call-trace-list {
	margin: 0;
	padding-left: 1.15rem;
	font-size: 0.9rem;
	line-height: 1.55;
}
.call-trace-list li { margin: 0.25rem 0; }

/* パターンなし比較 */
.compare-panel { margin: 0 0 1.25rem; }
.compare-title { font-size: 1.05rem; margin: 0 0 0.35rem; }
.compare-lead { margin: 0 0 0.85rem; }
.compare-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.85rem;
}
.compare-col-label {
	margin: 0 0 0.4rem;
	font-size: 0.78rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.compare-bad .compare-col-label { color: #f87171; }
.compare-good .compare-col-label { color: #34d399; }
:root[data-theme="light"] .compare-bad .compare-col-label { color: #b91c1c; }
:root[data-theme="light"] .compare-good .compare-col-label { color: #047857; }
.compare-code {
	font-size: 0.78rem;
	min-height: 6rem;
	margin: 0;
}

/* ページ下部ナビ */
.pattern-footer-nav {
	margin-top: 2rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--border);
}
.pattern-footer-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}
.nav-placeholder { min-width: 6rem; }
.pattern-footer-links {
	margin: 0.9rem 0 0;
	font-size: 0.9rem;
	color: var(--text-muted);
	text-align: center;
}
.pattern-footer-links .sep { margin: 0 0.4rem; opacity: 0.6; }
.pattern-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	align-items: center;
	justify-content: center;
	margin-top: 1rem;
}
.pattern-chips-label {
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--text-muted);
	margin-right: 0.25rem;
}
.pattern-chip {
	display: inline-flex;
	padding: 0.35rem 0.7rem;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--text-muted);
	text-decoration: none;
	background: var(--bg-card);
}
.pattern-chip:hover {
	color: var(--text);
	border-color: var(--accent);
	text-decoration: none;
}
.pattern-chip.is-current {
	color: #fffefa;
	background: var(--primary);
	border-color: var(--primary);
}
.result-card .stat-value { font-size: 2rem; font-weight: 800; margin: .5rem 0; }
.result-card .stat-value-url {
	font-size: 1.15rem; font-weight: 700; margin: .5rem 0;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	overflow-wrap: anywhere; word-break: break-word;
}

/* 実装クラスを目立たせるパネル */
.impl-panel {
	margin-top: 1rem;
	padding: 1rem 1.1rem;
	border-radius: 14px;
	background: var(--impl-bg);
	border: 1px solid var(--impl-border);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.impl-panel-label {
	margin: 0 0 0.4rem;
	font-size: 0.78rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--accent);
}
.impl-panel-class {
	margin: 0 0 0.45rem;
	line-height: 1.4;
}
.impl-panel-class code {
	display: inline-block;
	font-family: var(--font-mono);
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--accent);
	padding: 0.35rem 0.85rem;
	margin: 0.2rem 0;
	border-radius: var(--radius);
	background: var(--bg-card);
	border: 1px solid var(--border);
}
.impl-panel-hint {
	margin: 0;
	font-size: 0.88rem;
	color: var(--text-muted);
}

/* このデモでパターンを使う理由（デモ操作より上に置く） */
.why-panel {
	margin: 0 0 1rem;
}
.page-head {
	margin-bottom: 1rem;
}
.why-panel-title {
	font-size: 1.05rem;
	margin: 0 0 0.75rem;
}
.why-panel-name {
	color: var(--accent);
}
.why-list {
	margin: 0 0 0.85rem;
	padding-left: 1.2rem;
	color: var(--text);
}
.why-list li {
	margin: 0.4rem 0;
	line-height: 1.55;
}
.why-panel-footer {
	margin: 0;
	padding-top: 0.65rem;
	border-top: 1px solid var(--border);
}

/* 記事リンクの注記（デモ ≠ 記事ソース） */
.article-note {
	margin: 0.75rem 0 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.55rem;
}
.article-note-text {
	align-self: stretch;
	margin: 0;
	padding: 0.7rem 0.9rem;
	border-radius: 12px;
	font-size: 0.9rem;
	line-height: 1.55;
	color: var(--note-text);
	background: var(--note-bg);
	border: 1px solid var(--note-border);
}
.article-note-text strong {
	font-weight: 800;
}

.chip {
	display: inline-flex; padding: .15rem .55rem; border-radius: var(--radius);
	font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
	color: var(--text-muted); background: var(--impl-bg); border: 1px solid var(--border);
}

.btn {
	display: inline-flex; align-items: center; justify-content: center;
	padding: .65rem 1.1rem; border-radius: var(--radius); border: none;
	background: var(--accent-gradient); color: #fff;
	font-weight: 600; cursor: pointer; text-decoration: none; font-size: .92rem;
	transition: background 0.2s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); box-shadow: none; padding: .35rem .6rem; }

.demo-form { display: flex; flex-direction: column; gap: .75rem; margin-top: .5rem; }
.demo-form label, label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--text-muted); font-weight: 600; }
.demo-form label.check { flex-direction: row; align-items: center; color: var(--text); }
input:not([type="checkbox"]):not([type="radio"]), select {
	width: 100%; padding: .65rem .75rem; border-radius: var(--radius);
	border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font: inherit;
}
input[type="checkbox"], input[type="radio"] {
	width: 1.1rem; height: 1.1rem; flex: none;
}
.inline-form { display: inline-flex; margin: .25rem .35rem .25rem 0; }

/* #demo はデモ結果へのジャンプ先。sticky header の下に隠れないよう余白を確保する。
   ヘッダーの実高さは app.js が --header-h に反映する（パターン数増でナビが折り返み高さが変わるため）。 */
#demo { scroll-margin-top: calc(var(--header-h, 220px) + 16px); }

.flash { padding: .85rem 1rem; border-radius: 14px; margin-bottom: 1rem; border: 1px solid var(--border); }
.flash-success { background: rgba(52,211,153,.12); color: #047857; }
:root:not([data-theme="light"]) .flash-success { color: #a7f3d0; }
.flash-error { background: rgba(248,113,113,.12); color: #b91c1c; }
:root:not([data-theme="light"]) .flash-error { color: #fecaca; }

.breadcrumb { color: var(--text-muted); font-size: .9rem; margin: 0 0 1rem; }
.block { margin: 1rem 0; }
.section-head.tight { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.section-head.tight h2 { margin: 0; }
.code-block {
	background: var(--impl-bg); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 1rem; overflow: auto; font-size: .84rem; color: var(--text); white-space: pre-wrap;
}
.simple-table { width: 100%; border-collapse: collapse; }
.simple-table th, .simple-table td { text-align: left; padding: .65rem .4rem; border-bottom: 1px solid var(--border); }
.simple-table th { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; }
.plain-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border); }
hr.soft { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .88em; background: rgba(148,163,184,.12); padding: .1rem .35rem; border-radius: 6px; }

@media (max-width: 800px) {
	.detail-grid { grid-template-columns: 1fr; }
	.compare-grid { grid-template-columns: 1fr; }
	.pattern-footer-row { justify-content: center; }
	
	.mobile-menu-btn { display: flex; }
	.app-sidebar {
		position: fixed; top: 0; left: 0; transform: translateX(-100%);
		width: 280px; z-index: 60;
	}
	.app-sidebar.is-open { transform: translateX(0); }
	.sidebar-header-mobile-only { display: flex; }
	.mobile-overlay.is-open { display: block; opacity: 1; z-index: 55; }
	.app-main { overflow-y: auto; height: 100%; }
	.app-main .main { padding: 1.5rem 1rem 3rem; }

	.global-header-sidebar { width: auto; padding: 0 1rem; border-right: none; }
	.header-main-inner { padding: 0 1rem; }
}

/* About Page Specific Styles */
.about-hero { text-align: center; margin-bottom: 3rem; }
.about-hero h1 { font-size: 2.2rem; font-weight: 800; margin: 0.5rem 0 1rem; letter-spacing: -0.02em; }
.about-hero .lede { font-size: 1.1rem; max-width: 600px; margin: 0 auto; line-height: 1.7; }

.about-section { margin-bottom: 3rem; }
.about-section-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 1.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

.about-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.about-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }

.about-feature { display: flex; flex-direction: column; gap: 0.75rem; }
.about-feature-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: rgba(41, 128, 185, 0.1); border: 1px solid rgba(41, 128, 185, 0.2); color: var(--primary); border-radius: var(--radius); }
.about-feature h3 { font-size: 1.1rem; font-weight: 800; margin: 0; color: var(--text); }
.about-feature p { font-size: 0.9rem; color: var(--text-muted); margin: 0; line-height: 1.6; }

.about-step { display: flex; flex-direction: column; gap: 0.75rem; position: relative; }
.about-step-header { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 0.95rem; }
.about-step-badge { font-size: 0.7rem; font-weight: 800; padding: 0.15rem 0.4rem; background: var(--impl-bg); border: 1px solid var(--border); color: var(--text-muted); letter-spacing: 0.05em; }
.about-step p { font-size: 0.85rem; color: var(--text-muted); margin: 0; line-height: 1.6; }

@media (min-width: 800px) {
    .about-grid-4 { grid-template-columns: repeat(4, 1fr); }
    .about-step:not(:last-child)::after {
        content: ''; position: absolute; top: 10px; right: -15px; width: 15px; border-top: 2px dashed var(--border);
    }
}
