:root {
	--paper: #f7f7f7;
	--ink: #151514;
	--muted: #666666;
	--line: #d7d7d7;
	--soft: #ededed;
	--accent: #c91f37;
	--accent-dark: #9d172a;
	--link: #0f766e;
	--surface: #ffffff;
	--media-bg: #111111;
	--shadow: rgba(0, 0, 0, 0.12);
}

:root[data-theme="dark"] {
	--paper: #101214;
	--ink: #f0f1ed;
	--muted: #a8adb3;
	--line: #3a3f45;
	--soft: #22262a;
	--accent: #e04b62;
	--accent-dark: #b82b42;
	--link: #55c3b4;
	--surface: #181b1f;
	--media-bg: #050505;
	--shadow: rgba(0, 0, 0, 0.38);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: Arial, "Malgun Gothic", sans-serif;
	font-size: 15px;
	line-height: 1.5;
	letter-spacing: 0;
}

a {
	color: inherit;
	text-decoration: none;
}

button,
input,
textarea {
	font: inherit;
	letter-spacing: 0;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 50px;
	padding: 0 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}

.brand,
.brand-link {
	font-weight: 800;
	color: var(--accent);
}

.topbar nav {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
}

.topbar form {
	margin: 0;
}

.current-user {
	color: var(--muted);
	font-weight: 700;
	white-space: nowrap;
}

.topbar button,
.topbar a,
.write-link,
.theme-toggle,
.form-actions a {
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	padding: 7px 10px;
	color: var(--ink);
}

.topbar button {
	cursor: pointer;
}

.board {
	width: min(920px, 100%);
	margin: 0 auto;
	padding: 16px;
}

.board.narrow {
	width: min(760px, 100%);
}

.board-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 0 14px;
	border-bottom: 2px solid var(--ink);
}

.board-head h1 {
	margin: 0;
	font-size: 24px;
	line-height: 1.15;
}

.board-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.eyebrow {
	margin: 0 0 3px;
	color: var(--muted);
	font-size: 12px;
	text-transform: uppercase;
}

.post-table {
	border-bottom: 1px solid var(--line);
	background: var(--surface);
}

.post-row-shell {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	align-items: center;
	border-top: 1px solid var(--line);
}

.post-row {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	min-width: 0;
	padding: 10px 8px;
}

.post-row:active,
.post-row:hover {
	background: var(--soft);
}

.notice-row {
	background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.post-delete-form {
	margin: 0;
	padding-right: 8px;
}

.post-delete-form button {
	background: var(--surface);
	border: 1px solid var(--line);
	color: var(--accent);
	padding: 7px 10px;
}

.post-delete-form button:hover {
	background: var(--soft);
}

.post-title {
	min-width: 0;
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.post-title b {
	color: var(--accent);
	font-weight: 800;
}

.notice-badge {
	display: inline-block;
	border: 1px solid var(--accent);
	border-radius: 4px;
	color: var(--accent);
	font-size: 12px;
	font-style: normal;
	font-weight: 900;
	line-height: 1.1;
	margin-right: 5px;
	padding: 2px 4px;
	vertical-align: 1px;
}

.post-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--muted);
	font-size: 12px;
	white-space: nowrap;
}

.pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	padding: 14px 8px 0;
}

.page-link {
	min-width: 34px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	color: var(--ink);
	padding: 7px 10px;
	text-align: center;
	font-weight: 800;
}

.page-link:hover,
.page-link.active {
	border-color: var(--accent);
	background: var(--accent);
	color: #ffffff;
}

.page-link.disabled {
	color: var(--muted);
	font-weight: 700;
	opacity: 0.55;
}

.page-link.disabled:hover {
	border-color: var(--line);
	background: var(--surface);
	color: var(--muted);
}

.post-detail,
.comments,
.comment-form,
.board-form {
	background: var(--surface);
	border-top: 1px solid var(--line);
	border-bottom: 1px solid var(--line);
}

.post-detail {
	padding: 16px 0 8px;
}

.post-detail-head {
	padding: 0 8px 12px;
	border-bottom: 1px solid var(--line);
}

.post-detail-head h1 {
	margin: 0 0 8px;
	font-size: 22px;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.post-detail-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0;
	color: var(--muted);
	font-size: 12px;
}

.post-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin-top: 10px;
}

.post-actions a {
	color: var(--link);
	font-size: 16px;
	font-weight: 800;
	padding: 2px 4px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.inline-action-form,
.inline-delete-form {
	margin: 0;
}

.inline-action-form button,
.inline-delete-form button {
	border: 0;
	background: transparent;
	font-size: 16px;
	font-weight: 800;
	padding: 2px 4px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.inline-action-form button {
	color: var(--link);
}

.inline-delete-form button {
	color: var(--accent);
}

.post-body {
	padding: 16px 8px;
	margin: 0;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.post-body a {
	color: var(--link);
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.post-content {
	padding: 8px 0 16px;
}

.attachment-grid {
	display: grid;
	gap: 8px;
	padding: 12px 8px 0;
}

.inline-media {
	padding-top: 0;
	padding-bottom: 16px;
}

.youtube-embed {
	aspect-ratio: 16 / 9;
	margin: 12px 8px 16px;
	background: var(--media-bg);
	border: 1px solid var(--line);
}

.youtube-embed iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

.x-embed {
	margin: 12px 8px 16px;
}

.x-embed-target {
	display: flex;
	justify-content: center;
}

.x-embed-fallback {
	max-width: 550px;
	min-width: 220px;
	margin: 0 auto;
	padding: 14px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	overflow-wrap: anywhere;
}

.x-embed-fallback a {
	color: var(--link);
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.editor-toolbar {
	position: sticky;
	bottom: 0;
	z-index: 9;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: flex-end;
	padding: 10px 0 0;
	background: linear-gradient(to top, var(--surface) 75%, transparent);
}

.editor-toolbar [data-insert-media] {
	background: var(--surface);
	border: 1px solid var(--line);
	color: var(--link);
	padding: 10px 12px;
	box-shadow: 0 2px 8px var(--shadow);
}

.editor-toolbar .editor-actions {
	margin: 0;
}

.rich-editor {
	min-height: 420px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	padding: 14px;
	outline: none;
	white-space: pre-wrap;
	cursor: text;
}

.rich-editor:empty::before {
	content: attr(data-placeholder);
	color: var(--muted);
}

.editor-paragraph {
	margin: 0 0 16px;
	white-space: pre-wrap;
	cursor: text;
}

.editor-media {
	position: relative;
	margin: 18px 0;
	padding: 0;
	cursor: default;
}

.editor-media .editor-media-remove {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: grid;
	width: 30px;
	height: 30px;
	place-items: center;
	border: 1px solid var(--ink);
	border-radius: 0;
	background: var(--surface);
	color: var(--ink);
	font-size: 15px;
	font-weight: 900;
	line-height: 1;
	padding: 0;
}

.editor-media .editor-media-remove:hover {
	background: var(--accent);
	color: #ffffff;
}

.editor-media img,
.editor-media video {
	display: block;
	width: 100%;
	max-height: 560px;
	object-fit: contain;
	dynamic-range-limit: standard;
	background: var(--media-bg);
	border: 1px solid var(--line);
}

.editor-media figcaption {
	margin-top: 5px;
	color: var(--muted);
	font-size: 12px;
	overflow-wrap: anywhere;
}

.attachment img,
.attachment video {
	display: block;
	width: 100%;
	max-height: 620px;
	object-fit: contain;
	dynamic-range-limit: standard;
	background: var(--media-bg);
	border: 1px solid var(--line);
}

.comments {
	margin-top: 12px;
	padding: 12px 8px;
}

.comments h2 {
	margin: 0 0 8px;
	font-size: 15px;
}

.comment {
	padding: 9px 0;
	border-top: 1px solid var(--line);
}

.comment strong {
	font-size: 13px;
}

.comment span {
	margin-left: 6px;
	color: var(--muted);
	font-size: 12px;
}

.comment p {
	margin: 5px 0 0;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.comment-form {
	display: grid;
	gap: 8px;
	margin-top: 12px;
	padding: 12px 8px;
}

.comment-form textarea {
	min-height: 90px;
}

.admin-list {
	display: grid;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}

.admin-user {
	display: grid;
	grid-template-columns: 1fr minmax(280px, 380px);
	gap: 12px;
	align-items: end;
	padding: 12px 8px;
	border-top: 1px solid var(--line);
}

.admin-user-info {
	display: grid;
	gap: 3px;
}

.admin-user-info span,
.admin-user-info em {
	color: var(--muted);
	font-size: 12px;
	font-style: normal;
}

.admin-user-info em {
	color: var(--accent);
	font-weight: 800;
}

.admin-reset-form {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	align-items: end;
}

.admin-reset-form label {
	display: grid;
	gap: 5px;
}

.admin-reset-form label span {
	font-size: 12px;
	font-weight: 700;
}

.auth-page {
	display: grid;
	min-height: 100svh;
	place-items: center;
	padding: 20px;
}

.auth-shell {
	width: min(420px, 100%);
}

.auth-shell h1 {
	margin: 12px 0 4px;
	font-size: 26px;
	line-height: 1.2;
}

.quiet,
.helper,
small {
	color: var(--muted);
}

.helper a {
	color: var(--link);
	font-weight: 700;
}

.stack-form {
	display: grid;
	gap: 12px;
	margin-top: 18px;
}

.stack-form label {
	display: grid;
	gap: 6px;
}

.stack-form label span {
	font-weight: 700;
	font-size: 13px;
}

input,
textarea {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	padding: 11px 12px;
	color: var(--ink);
}

textarea {
	resize: vertical;
}

.password-field {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	align-items: stretch;
}

.password-field input {
	min-width: 0;
}

button,
.write-link,
.theme-toggle,
.stack-form button {
	border: 0;
	border-radius: 6px;
	background: var(--accent);
	color: #ffffff;
	font-weight: 800;
	padding: 11px 14px;
	cursor: pointer;
}

button:hover,
.write-link:hover,
.stack-form button:hover {
	background: var(--accent-dark);
}

.theme-toggle {
	border: 1px solid #111111;
	background: #ffffff;
	color: #111111;
}

.theme-toggle:hover {
	background: #ffffff;
	color: #111111;
}

:root[data-theme="dark"] .theme-toggle {
	border-color: #ffffff;
	background: #111111;
	color: #ffffff;
}

:root[data-theme="dark"] .theme-toggle:hover {
	background: #111111;
	color: #ffffff;
}

.stack-form .password-field button {
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--ink);
	padding: 0 12px;
}

.stack-form .password-field button:hover {
	background: var(--soft);
}

.form-actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 10px;
}

.notice,
.error,
.empty {
	margin: 12px 0;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
}

.notice {
	border-color: #9bd1c9;
	color: #0f766e;
}

.error,
small:not(:empty) {
	color: #c91f37;
}

@media (max-width: 640px) {
	body {
		font-size: 14px;
	}

	input,
	textarea,
	.rich-editor {
		font-size: 16px;
	}

	.topbar {
		padding: 0 10px;
	}

	.board {
		padding: 10px 0;
	}

	.board-head {
		padding: 10px 10px 12px;
	}

	.board-head h1 {
		font-size: 21px;
	}

	.post-row-shell {
		grid-template-columns: minmax(0, 1fr) auto;
		gap: 4px;
		align-items: start;
	}

	.post-row {
		grid-template-columns: 1fr;
		gap: 3px;
	}

	.post-row {
		padding: 9px 10px;
	}

	.post-delete-form {
		padding: 9px 10px 0 0;
	}

	.post-delete-form button {
		white-space: nowrap;
	}

	.post-meta {
		justify-content: flex-start;
	}

	.inline-media {
		margin: 12px 6px 16px;
		padding-bottom: 0;
	}

	.post-detail-head,
	.post-body,
	.attachment-grid,
	.comments,
	.comment-form,
	.board-form {
		padding-left: 10px;
		padding-right: 10px;
	}

	.admin-user,
	.admin-reset-form {
		grid-template-columns: 1fr;
	}
}
