:root {
	--bg-0: #0d1017;
	--bg-1: #121723;
	--bg-2: #1b2233;
	--panel: rgba(19, 24, 36, 0.84);
	--line: rgba(214, 171, 95, 0.48);
	--line-soft: rgba(214, 171, 95, 0.25);
	--accent: #d7ad64;
	--accent-cold: #5f86c3;
	--txt-main: #e8edf7;
	--txt-soft: #b9c3d8;
	--txt-dim: #8f9db6;
	--danger: #cf6f6f;
	--shadow: 0 12px 35px rgba(4, 6, 12, 0.5);
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	font-family: "Alegreya Sans", "Segoe UI", sans-serif;
	color: var(--txt-main);
	background:
		radial-gradient(circle at 7% 14%, rgba(95, 134, 195, 0.23), transparent 38%),
		radial-gradient(circle at 85% 3%, rgba(215, 173, 100, 0.17), transparent 30%),
		linear-gradient(175deg, #0b0f16 0%, #0f1320 50%, #0a0d15 100%);
	min-height: 100vh;
}

.ambient-glow {
	position: fixed;
	inset: 0;
	pointer-events: none;
	background-image:
		repeating-linear-gradient(
			45deg,
			transparent 0,
			transparent 24px,
			rgba(255, 255, 255, 0.012) 24px,
			rgba(255, 255, 255, 0.012) 25px
		);
	opacity: 0.65;
	z-index: -1;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.1rem 1.4rem;
	border-bottom: 1px solid var(--line-soft);
	background: rgba(9, 12, 18, 0.8);
	backdrop-filter: blur(7px);
	position: sticky;
	top: 0;
	z-index: 40;
}

.topbar h1 {
	margin: 0;
	letter-spacing: 0.05em;
	font-size: clamp(1.3rem, 2vw, 1.8rem);
	color: #f3e2ba;
	font-family: "Cormorant Garamond", Georgia, serif;
}

.topbar-actions {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
}

button,
.file-btn {
	border: 1px solid var(--line-soft);
	border-radius: 0.45rem;
	background: linear-gradient(180deg, #1a2438 0%, #131b2c 100%);
	color: var(--txt-main);
	font-family: inherit;
	font-size: 0.95rem;
	padding: 0.48rem 0.85rem;
	cursor: pointer;
	transition: 160ms ease;
}

button:hover,
.file-btn:hover {
	transform: translateY(-1px);
	border-color: var(--accent);
}

button.primary {
	background: linear-gradient(180deg, #8c5f2a 0%, #6b481f 100%);
	border-color: rgba(236, 196, 121, 0.65);
	color: #fff5df;
}

button.danger {
	background: linear-gradient(180deg, #45232a 0%, #3a1a20 100%);
	border-color: rgba(207, 111, 111, 0.5);
}

.sheet-layout {
	display: grid;
	grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
	gap: 1rem;
	padding: 1rem;
}

.sheet-side,
.sheet-main {
	display: grid;
	gap: 1rem;
	align-content: start;
}

.panel {
	background: var(--panel);
	border: 1px solid var(--line-soft);
	box-shadow: var(--shadow);
	border-radius: 0.6rem;
	padding: 1rem;
	position: relative;
	overflow: hidden;
}

.panel::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(130deg, rgba(215, 173, 100, 0.05), transparent 38%);
	pointer-events: none;
}

.panel-title {
	margin: 0 0 0.85rem;
	color: #99afdf;
	font-family: "Cormorant Garamond", Georgia, serif;
	letter-spacing: 0.03em;
	font-size: clamp(1.55rem, 2.6vw, 2rem);
	border-bottom: 1px solid var(--line-soft);
	padding-bottom: 0.4rem;
}

.small-heading {
	margin: 1rem 0 0.4rem;
	color: #9db4e7;
	letter-spacing: 0.04em;
	font-family: "Cormorant Garamond", Georgia, serif;
	font-size: 1.2rem;
}

.field {
	display: grid;
	gap: 0.38rem;
	margin-bottom: 0.66rem;
}

.is-hidden {
	display: none !important;
}

.field > span {
	color: var(--txt-soft);
	font-size: 0.95rem;
}

input,
select,
textarea {
	width: 100%;
	border: 1px solid rgba(215, 173, 100, 0.34);
	border-radius: 0.45rem;
	color: var(--txt-main);
	background: rgba(13, 18, 30, 0.9);
	padding: 0.48rem 0.58rem;
	font-size: 0.95rem;
	font-family: inherit;
}

textarea {
	min-height: 3.2rem;
	resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
	outline: 2px solid rgba(95, 134, 195, 0.5);
	border-color: var(--accent-cold);
}

.portrait-wrap {
	margin-top: 0.5rem;
	border-radius: 0.45rem;
	border: 1px solid rgba(95, 134, 195, 0.35);
	overflow: hidden;
	background: #0a0d13;
}

.portrait-wrap img {
	display: block;
	width: 100%;
	min-height: 220px;
	object-fit: cover;
	aspect-ratio: 4 / 5;
}

.idea-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.65rem;
}

.table-toolbar {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 0.5rem;
}

.fancy-table {
	width: 100%;
	border-collapse: collapse;
	border: 1px solid var(--line-soft);
	border-radius: 0.5rem;
	overflow: hidden;
	background: rgba(11, 16, 26, 0.9);
}

.fancy-table th,
.fancy-table td {
	border-bottom: 1px solid rgba(144, 163, 200, 0.22);
	padding: 0.48rem;
	vertical-align: top;
}

.fancy-table th {
	text-align: left;
	font-weight: 600;
	color: #f0c879;
	background: rgba(24, 32, 48, 0.85);
}

.fancy-table tr:last-child td {
	border-bottom: 0;
}

.note {
	margin-top: -0.25rem;
	margin-bottom: 0.8rem;
	color: var(--txt-dim);
}

.relation-guide-list {
	margin: 0.2rem 0 0.4rem 1rem;
	padding: 0;
	color: var(--txt-soft);
	display: grid;
	gap: 0.25rem;
}

.relationship-card {
	border: 1px solid var(--line-soft);
	border-radius: 0.55rem;
	padding: 0.75rem;
	background: rgba(14, 20, 32, 0.62);
	display: grid;
	gap: 0.75rem;
}

.relationships-root {
	display: grid;
	gap: 0.75rem;
}

.relationship-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.6rem;
}

.relationship-head .small-heading {
	margin: 0;
}

.status-tags {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.45rem;
}

.expr-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.75rem;
	align-items: start;
}

.expr-block {
	min-width: 0;
	display: grid;
	gap: 0.45rem;
}

.expr-block .small-heading {
	margin-top: 0.1rem;
}

.achievements-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.75rem;
	align-items: start;
}

.achievement-block {
	min-width: 0;
	display: grid;
	gap: 0.45rem;
}

.achievement-block .small-heading {
	margin-top: 0.1rem;
}

.goals-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.75rem;
	align-items: start;
}

.goal-block {
	min-width: 0;
	display: grid;
	gap: 0.45rem;
}

.goal-block .small-heading {
	margin-top: 0.1rem;
}

.reference-board-wrap {
	margin-bottom: 0.85rem;
}

.reference-board-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 0.6rem;
}

.reference-slot {
	position: relative;
	min-height: 120px;
	border: 1px dashed rgba(215, 173, 100, 0.55);
	border-radius: 0.45rem;
	background: rgba(11, 16, 26, 0.75);
	overflow: hidden;
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: border-color 150ms ease, transform 150ms ease;
}

.reference-slot:hover {
	border-color: var(--accent);
	transform: translateY(-1px);
}

.reference-slot.drag-over {
	border-color: #f0cf93;
	box-shadow: 0 0 0 2px rgba(240, 207, 147, 0.24) inset;
}

.reference-slot img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: none;
}

.reference-slot.has-image img {
	display: block;
}

.reference-slot-label {
	text-align: center;
	padding: 0.5rem;
	font-size: 0.82rem;
	color: var(--txt-soft);
	line-height: 1.25;
	max-width: 12ch;
}

.reference-slot.has-image .reference-slot-label {
	display: none;
}

.reference-slot-clear {
	position: absolute;
	top: 0.28rem;
	right: 0.28rem;
	border: 1px solid rgba(207, 111, 111, 0.6);
	background: rgba(40, 14, 18, 0.75);
	color: #f3dede;
	border-radius: 0.3rem;
	font-size: 0.75rem;
	padding: 0.12rem 0.35rem;
	display: none;
}

.reference-slot.has-image .reference-slot-clear {
	display: inline-block;
}

.alltag-hobby-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.75rem;
	align-items: start;
}

.alltag-hobby-block {
	min-width: 0;
	display: grid;
	gap: 0.45rem;
}

.alltag-hobby-block .small-heading {
	margin-top: 0.1rem;
}

.personality-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.85rem;
	align-items: start;
}

.personality-column {
	min-width: 0;
	display: grid;
	gap: 0.55rem;
}

.trait-item {
	border: 1px solid rgba(240, 207, 147, 0.18);
	border-radius: 0.55rem;
	padding: 0.45rem 0.5rem 0.5rem;
	background: rgba(11, 16, 26, 0.74);
	display: grid;
	gap: 0.28rem;
}

.trait-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.45rem;
	font-size: 0.95rem;
	line-height: 1.2;
	font-family: "Cormorant Garamond", Georgia, serif;
}


.trait-label-left,
.trait-label-right {
	display: inline-flex;
	align-items: baseline;
	gap: 0.24rem;
	min-width: 0;
	word-break: break-word;
	color: var(--txt-soft);
}

.trait-label-right {
	justify-content: flex-end;
	text-align: right;
}

.trait-percent-left {
	font-size: 0.78rem;
	font-family: "Alegreya Sans", "Segoe UI", sans-serif;
	letter-spacing: 0.06em;
	color: #d1a15f;
}

.trait-percent-right {
	font-size: 0.78rem;
	font-family: "Alegreya Sans", "Segoe UI", sans-serif;
	letter-spacing: 0.06em;
	color: #a6afbe;
}

.trait-meter {
	position: relative;
	height: 2rem;
	display: grid;
	align-items: center;
}

.trait-meter-track {
	position: absolute;
	inset: 0.14rem 0;
	display: flex;
	overflow: hidden;
	border-radius: 0.45rem;
	border: 1px solid rgba(240, 207, 147, 0.18);
	background: rgba(9, 13, 20, 0.95);
	pointer-events: none;
}

.trait-meter-track::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 0.14rem;
	bottom: 0.14rem;
	width: 0.2rem;
	border-radius: 999px;
	background: rgba(8, 10, 15, 0.95);
	transform: translateX(-50%);
}

.trait-meter-left {
	background: linear-gradient(180deg, #6f3c17 0%, #552b12 100%);
	transition: width 140ms ease;
}

.trait-meter-right {
	background: linear-gradient(180deg, #555a63 0%, #434952 100%);
	transition: width 140ms ease;
}

.trait-slider {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 2rem;
	padding: 0;
	background: transparent;
	border: none;
	position: relative;
	z-index: 2;
}

.trait-slider::-webkit-slider-runnable-track {
	height: 2rem;
	background: transparent;
}

.trait-slider::-moz-range-track {
	height: 2rem;
	background: transparent;
	border: none;
}

.trait-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	margin-top: 0.18rem;
	width: 0.35rem;
	height: 1.64rem;
	border-radius: 999px;
	border: 1px solid rgba(245, 233, 210, 0.9);
	background: linear-gradient(180deg, #f2ede3 0%, #d5c6a2 100%);
	box-shadow: 0 0 0 2px rgba(8, 12, 19, 0.6);
	cursor: pointer;
}

.trait-slider::-moz-range-thumb {
	width: 0.35rem;
	height: 1.64rem;
	border-radius: 999px;
	border: 1px solid rgba(245, 233, 210, 0.9);
	background: linear-gradient(180deg, #f2ede3 0%, #d5c6a2 100%);
	box-shadow: 0 0 0 2px rgba(8, 12, 19, 0.6);
	cursor: pointer;
}

.trait-footer {
	display: flex;
	justify-content: center;
	align-items: center;
}

.trait-value {
	font-size: 0.78rem;
	letter-spacing: 0.05em;
	color: #9db4e7;
}

@media (max-width: 1450px) {
	.personality-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 1180px) {
	.personality-grid {
		grid-template-columns: 1fr;
	}
}

.skills-root {
	display: grid;
	gap: 0.9rem;
}

.skill-group {
	border: 1px solid var(--line-soft);
	border-radius: 0.55rem;
	background: rgba(13, 20, 32, 0.8);
	overflow: hidden;
}

.skill-header {
	margin: 0;
	padding: 0.55rem 0.7rem;
	color: #f2d39a;
	border-bottom: 1px solid var(--line-soft);
	background: rgba(30, 24, 15, 0.6);
	font-family: "Cormorant Garamond", Georgia, serif;
	letter-spacing: 0.02em;
	font-size: 1.22rem;
}

.skill-table {
	width: 100%;
	border-collapse: collapse;
}

.skill-table th,
.skill-table td {
	border-bottom: 1px solid rgba(143, 159, 194, 0.2);
	padding: 0.45rem;
	text-align: left;
}

.skill-table th {
	color: var(--txt-soft);
	font-size: 0.86rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.skill-table tr:last-child td {
	border-bottom: none;
}

.skill-control {
	display: grid;
	gap: 0.3rem;
}

.rating-dots {
	display: grid;
	grid-template-columns: repeat(10, minmax(22px, 1fr));
	gap: 0.2rem;
}

.rating-dots button {
	min-width: 0;
	padding: 0.2rem 0;
	border-radius: 0.25rem;
	font-size: 1rem;
	line-height: 1;
	background: rgba(21, 26, 38, 0.55);
	border-color: rgba(96, 123, 168, 0.25);
	color: #5e6f93;
}

.rating-dots button.active {
	background: linear-gradient(180deg, #8e6e35 0%, #705629 100%);
	color: #ffe5a6;
	border-color: rgba(255, 222, 143, 0.75);
}

.lvl-label {
	color: #9cb5e7;
	font-size: 0.84rem;
}

.qa-list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 0.7rem;
	margin-top: 0.8rem;
}

.history-stages {
	display: grid;
	gap: 0.85rem;
}

.history-stage {
	border: 1px solid var(--line-soft);
	border-radius: 0.55rem;
	background: rgba(13, 19, 31, 0.82);
	overflow: hidden;
}

.history-stage-head {
	display: grid;
	grid-template-columns: 2fr 1fr auto;
	gap: 0.5rem;
	padding: 0.6rem;
	border-bottom: 1px solid rgba(144, 163, 200, 0.25);
	background: rgba(25, 33, 48, 0.72);
}

.history-stage-body {
	padding: 0.65rem;
	display: grid;
	gap: 0.65rem;
}

.history-guidance,
.history-education,
.history-conflicts {
	border: 1px solid rgba(215, 173, 100, 0.28);
	border-radius: 0.45rem;
	padding: 0.55rem;
	background: rgba(12, 18, 29, 0.78);
}

.history-guidance strong,
.history-education strong,
.history-conflicts strong {
	display: block;
	margin-bottom: 0.45rem;
	color: #f0cf93;
	font-weight: 700;
}

.history-conflicts-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.history-conflict-table {
	font-size: 0.9rem;
}

.history-conflict-table th,
.history-conflict-table td {
	min-width: 140px;
}

.history-conflict-table th:last-child,
.history-conflict-table td:last-child {
	min-width: 100px;
}

.history-subparts {
	display: grid;
	gap: 0.55rem;
}

.history-part {
	border: 1px solid rgba(95, 134, 195, 0.35);
	border-radius: 0.4rem;
	padding: 0.55rem;
	background: rgba(10, 16, 28, 0.84);
}

.history-part-head {
	display: flex;
	justify-content: space-between;
	gap: 0.5rem;
	align-items: center;
	margin-bottom: 0.45rem;
}

.history-part-head strong {
	color: #f2d39a;
	font-weight: 600;
}

.history-inline {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.55rem;
}

.history-stage-actions {
	display: flex;
	gap: 0.45rem;
	flex-wrap: wrap;
}

.qa-item {
	border: 1px solid var(--line-soft);
	border-radius: 0.4rem;
	padding: 0.5rem;
	background: rgba(11, 17, 29, 0.75);
}

.qa-item strong {
	color: #f0cf93;
	display: block;
	margin-bottom: 0.35rem;
}

.no-break {
	break-inside: avoid;
	page-break-inside: avoid;
}

@media (max-width: 980px) {
	.sheet-layout {
		grid-template-columns: 1fr;
	}

	.topbar {
		position: static;
	}

	.idea-grid {
		grid-template-columns: 1fr;
	}

	.history-stage-head,
	.history-inline {
		grid-template-columns: 1fr;
	}

	.expr-grid {
		grid-template-columns: 1fr;
	}

	.achievements-grid {
		grid-template-columns: 1fr;
	}

	.goals-grid {
		grid-template-columns: 1fr;
	}

	.alltag-hobby-grid {
		grid-template-columns: 1fr;
	}

	.reference-board-grid {
		grid-template-columns: 1fr;
	}

	.personality-grid {
		grid-template-columns: 1fr;
	}

	.trait-head {
		font-size: 0.9rem;
	}

	.trait-percent-left,
	.trait-percent-right {
		font-size: 0.72rem;
	}

	.qa-list {
		grid-template-columns: 1fr;
	}
}

@media print {
	body {
		background: #ffffff;
		color: #111111;
	}

	.ambient-glow,
	.no-print,
	.topbar {
		display: none !important;
	}

	.sheet-layout {
		display: block;
		padding: 0;
	}

	.sheet-side,
	.sheet-main {
		display: block;
	}

	.panel {
		box-shadow: none;
		border: 1px solid #b0b0b0;
		background: #ffffff;
		margin-bottom: 0.6rem;
	}

	.panel::before {
		display: none;
	}

	.panel-title,
	.small-heading,
	.field > span,
	.note,
	.lvl-label,
	.qa-item strong,
	.skill-header,
	.fancy-table th,
	.skill-table th {
		color: #111111 !important;
	}

	input,
	textarea,
	select {
		background: #ffffff;
		color: #111111;
		border: 1px solid #bcbcbc;
	}

	.fancy-table,
	.skill-group {
		border-color: #bcbcbc;
		background: #ffffff;
	}
}
