/* ================================================================
   かんたん3Dモデラー スタイル

   落ち着いた紺の下地に、3Dの画面だけが浮かんで見えるようにしている。
   初めて開いた人が「どこを触ればいいか」で迷わないよう、押せるものは
   すべて枠線と背景を持たせ、説明文（.note）は一段暗くして下げてある。
   ================================================================ */

:root {
	--bg: #10141c;
	--panel: #182030;
	--panel-2: #1f293b;
	--stage: #161a22;
	--line: #2c384f;
	--line-soft: #232e42;
	--text: #eef2f8;
	--muted: #94a2ba;
	--accent: #58b0ff;
	--accent-deep: #2f7fd0;
	--on-accent: #04121f;
	--warn: #ffc46b;
	--danger: #ff7d92;
	--radius: 10px;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family:
		"Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui,
		sans-serif;
	line-height: 1.7;
	font-size: 15px;
}

.wrap {
	max-width: 1180px;
	margin: 0 auto;
	padding: 0 16px;
}

/* ---- 見出し ---- */

.site-head {
	border-bottom: 1px solid var(--line);
	background: linear-gradient(180deg, #1a2434, #10141c);
	padding: 18px 0 16px;
}

.site-head h1 {
	margin: 0;
	font-size: 22px;
	letter-spacing: 0.02em;
}

.tagline {
	margin: 4px 0 0;
	color: var(--muted);
	font-size: 13px;
}

.tagline b {
	color: var(--text);
}

/* ---- 全体の配置 ---- */

.layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	gap: 14px;
	max-width: 1180px;
	margin: 14px auto;
	padding: 0 16px;
	align-items: start;
}

@media (max-width: 900px) {
	.layout {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* ---- 3Dの画面 ---- */

.stage {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
}

.toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 14px;
	padding: 8px 10px;
	border-bottom: 1px solid var(--line);
	background: var(--panel-2);
}

.tb-group {
	display: flex;
	align-items: center;
	gap: 5px;
	flex-wrap: wrap;
}

.tb-label {
	color: var(--muted);
	font-size: 12px;
	margin-right: 2px;
}

.canvas-wrap {
	position: relative;
	background: var(--stage);
	height: min(62vh, 560px);
}

@media (max-width: 900px) {
	.canvas-wrap {
		height: 52vh;
		min-height: 300px;
	}
}

#view {
	display: block;
	width: 100%;
	height: 100%;
	/* ドラッグで視点を回すので、ブラウザ側のスクロールに取られないようにする */
	touch-action: none;
	cursor: grab;
}

#view:active {
	cursor: grabbing;
}

.overlay {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	margin: 0;
	padding: 7px 14px;
	border-radius: 999px;
	font-size: 12.5px;
	pointer-events: none;
	max-width: calc(100% - 24px);
	text-align: center;
}

.hint {
	bottom: 10px;
	background: rgba(16, 20, 28, 0.82);
	color: var(--muted);
	border: 1px solid var(--line);
}

.busy {
	top: 12px;
	background: rgba(16, 20, 28, 0.92);
	border: 1px solid var(--accent-deep);
	color: var(--text);
	display: flex;
	align-items: center;
	gap: 8px;
}

.toast {
	top: 12px;
	/* 読み終わったら押して消せるように（形の上に重なるため） */
	pointer-events: auto;
	cursor: pointer;
	background: rgba(31, 41, 59, 0.96);
	border: 1px solid var(--accent-deep);
	color: var(--text);
	line-height: 1.55;
	border-radius: 10px;
	text-align: left;
	width: min(560px, calc(100% - 24px));
}

.busy:not([hidden]) ~ .toast {
	top: 54px;
}

.spinner {
	width: 13px;
	height: 13px;
	border: 2px solid var(--accent-deep);
	border-top-color: transparent;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	flex: none;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner {
		animation-duration: 3s;
	}
}

.fail {
	top: 50%;
	transform: translate(-50%, -50%);
	width: min(440px, calc(100% - 32px));
	background: var(--panel-2);
	border: 1px solid var(--warn);
	border-radius: 10px;
	text-align: left;
	line-height: 1.6;
}

.statusbar {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 16px;
	padding: 7px 12px;
	border-top: 1px solid var(--line);
	background: var(--panel-2);
	font-size: 12.5px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.statusbar .warn {
	color: var(--warn);
}

/* ---- 右の操作パネル ---- */

.panel {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

.card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 12px 13px 14px;
}

.card h2 {
	margin: 0 0 9px;
	font-size: 14px;
	letter-spacing: 0.03em;
	color: var(--text);
	padding-bottom: 7px;
	border-bottom: 1px solid var(--line-soft);
}

.note {
	margin: 8px 0 0;
	color: var(--muted);
	font-size: 12.5px;
	line-height: 1.65;
}

.card h2 + .note {
	margin-top: 0;
}

kbd {
	font-family: inherit;
	font-size: 11.5px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 4px;
	padding: 0 4px;
	background: var(--panel-2);
	color: var(--text);
}

code {
	font-size: 12.5px;
	background: var(--panel-2);
	border-radius: 4px;
	padding: 1px 4px;
}

/* ---- ボタン ---- */

button {
	font: inherit;
	font-size: 13px;
	color: var(--text);
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: 7px;
	padding: 6px 11px;
	cursor: pointer;
	line-height: 1.4;
}

button:hover:not(:disabled) {
	background: #2a3750;
	border-color: #3d4d6b;
}

button:active:not(:disabled) {
	transform: translateY(1px);
}

button:disabled {
	opacity: 0.42;
	cursor: default;
}

button:focus-visible,
input:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--on-accent);
	font-weight: 700;
	width: 100%;
	margin-top: 9px;
	padding: 9px;
}

button.primary:hover:not(:disabled) {
	background: #74bcff;
	border-color: #74bcff;
}

button.danger {
	color: var(--danger);
	border-color: #4a2b36;
}

button.danger:hover:not(:disabled) {
	background: #3a2029;
	border-color: #6b3b49;
}

button.mini {
	font-size: 12px;
	padding: 4px 9px;
	margin-top: 7px;
}

.btn-row {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 10px;
}

/* ---- 部品のリスト ---- */

.obj-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-height: 260px;
	overflow-y: auto;
}

.obj {
	display: grid;
	grid-template-columns: auto auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 8px;
	padding: 5px 8px;
	border: 1px solid var(--line-soft);
	border-radius: 7px;
	background: var(--panel-2);
	cursor: pointer;
	font-size: 13px;
}

.obj:hover {
	border-color: #3d4d6b;
}

.obj.on {
	border-color: var(--accent);
	background: #1d3350;
}

.obj .pick {
	width: 24px;
	height: 24px;
	padding: 0;
	border-radius: 50%;
	font-size: 12px;
	line-height: 1;
	flex: none;
	color: var(--muted);
}

.obj.on .pick {
	color: var(--on-accent);
	background: var(--accent);
	border-color: var(--accent);
}

.swatch {
	width: 12px;
	height: 12px;
	border-radius: 3px;
	border: 1px solid rgba(255, 255, 255, 0.25);
	flex: none;
}

.obj-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.obj-sub {
	color: var(--muted);
	font-size: 11.5px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* ---- 入力欄 ---- */

fieldset {
	border: 1px solid var(--line-soft);
	border-radius: 8px;
	margin: 11px 0 0;
	padding: 6px 10px 10px;
	min-width: 0;
}

legend {
	font-size: 12px;
	color: var(--muted);
	padding: 0 5px;
}

.triple {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
	gap: 7px;
}

.triple label,
.field {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.field {
	margin-top: 10px;
}

.triple span,
.field span {
	font-size: 11.5px;
	color: var(--muted);
}

input[type="number"],
input[type="text"] {
	font: inherit;
	font-size: 13px;
	color: var(--text);
	background: #121824;
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 6px 8px;
	width: 100%;
	min-width: 0;
	font-variant-numeric: tabular-nums;
}

input[type="color"] {
	width: 52px;
	height: 30px;
	padding: 2px;
	background: #121824;
	border: 1px solid var(--line);
	border-radius: 6px;
	cursor: pointer;
}

.pick-desc {
	margin: 0;
	font-size: 13px;
	line-height: 1.6;
}

.pick-desc b {
	color: var(--accent);
}

/* ---- 下の説明 ---- */

.doc {
	margin: 26px auto 40px;
	max-width: 820px;
}

.doc h2 {
	font-size: 16px;
	margin: 28px 0 10px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--line);
}

.doc h2:first-child {
	margin-top: 0;
}

.doc p {
	margin: 10px 0;
	font-size: 14px;
}

.steps {
	margin: 10px 0;
	padding-left: 1.3em;
	font-size: 14px;
}

.steps li {
	margin: 8px 0;
}

.faq {
	margin: 10px 0;
	font-size: 14px;
}

.faq dt {
	font-weight: 700;
	margin-top: 14px;
	color: var(--accent);
}

.faq dd {
	margin: 4px 0 0;
	padding-left: 0;
	color: #d3dbe8;
}

.site-foot {
	border-top: 1px solid var(--line);
	padding: 14px 0 26px;
	font-size: 12.5px;
	color: var(--muted);
}

.site-foot a {
	color: var(--accent);
}

/* ---- モード切り替え（かんたん / PRO） ---- */

.head-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}

.mode-switch {
	display: flex;
	gap: 0;
	border: 1px solid var(--line);
	border-radius: 999px;
	overflow: hidden;
	background: var(--panel);
	flex: none;
}

.mode-switch button {
	border: 0;
	border-radius: 0;
	background: transparent;
	padding: 6px 16px;
	color: var(--muted);
}

.mode-switch button:hover:not(.on) {
	background: var(--panel-2);
	color: var(--text);
}

.mode-switch button.on {
	background: var(--accent);
	color: var(--on-accent);
	font-weight: 700;
}

/* かんたんモードでは、PRO専用の欄をまるごと出さない。
   「押せるのに使えない」ボタンを並べるより、無いほうが迷わない。 */
body:not([data-mode="pro"]) .pro-only {
	display: none !important;
}

/* ---- 断面の入力 ---- */

textarea {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12.5px;
	line-height: 1.6;
	color: var(--text);
	background: #121824;
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 7px 9px;
	width: 100%;
	resize: vertical;
	margin-top: 6px;
}

select {
	font: inherit;
	font-size: 13px;
	color: var(--text);
	background: #121824;
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 6px 8px;
	width: 100%;
	min-width: 0;
}

.note.err {
	color: var(--danger);
}

#f-path .field,
#f-path .triple {
	margin-top: 9px;
}

/* ---- 検査の結果 ---- */

.report {
	margin-top: 11px;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 10px 11px;
	background: #121824;
	font-size: 12.5px;
}

.report p {
	margin: 0 0 8px;
	font-weight: 700;
}

.report p.ok {
	color: #7fe0a0;
}

.report p.ng {
	color: var(--warn);
}

.report dl {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 3px 12px;
	margin: 0;
}

.report dt {
	color: var(--muted);
	white-space: nowrap;
}

.report dd {
	margin: 0;
	font-variant-numeric: tabular-nums;
}

.report p.msg {
	margin: 9px 0 0;
	font-weight: 400;
	color: var(--warn);
	line-height: 1.6;
}
