/* Page layout */

html {
	scroll-padding-top: 64px;
}

body {
	text-size-adjust: none;
	text-align: justify;
	text-autospace: ideograph-alpha ideograph-numeric replace;
	text-spacing-trim: trim-both;
	background-color: lightgray;
	margin: 0;
}

#page-container {
	overflow: auto;
	width: 100%;
	block-size: 100vw;
	height: 100%;
}

#page-header {
	background-color: #066;
	width: 100%;
	height: 48px;
	position: fixed;
	z-index: 100;
}

#header-container {
	width: 100%; height: 100%;
	max-width: 960px;
	margin: auto;
}

#page-header a {
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	color: white;
	position: relative;
	height: calc(100% - 3px);
	padding: 0 8px;
	margin: 0 2px 3px 2px;
	transition: background-color 0.1s;
}

#page-header #logo-container {
	background-color: #8cc;
	float: left;
	z-index: 20;
	width: 64px; height: 64px;
	padding: 0;
	border: solid 4px #066;
	border-radius: 68px;
}

#page-header a:hover {
	background-color: #4aa;
	transition: background-color 0.1s;
}

#header-flex {
	display: flex;
	justify-content: space-between;
	white-space: nowrap;
	height: 100%;
	writing-mode: horizontal-tb;
}

#header-flex > div {
	display: flex;
}

#header-flex > div:first-child {
	padding-inline-end: 16px;
	flex: 0 1 auto;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-mask-image: linear-gradient(to right, black 0, black calc(100% - 10px), transparent 100%);
	mask-image: linear-gradient(to right, black 0, black calc(100% - 10px), transparent 100%);
}

#header-flex > div:first-child::-webkit-scrollbar {
	display: none;
}

#header-flex > div:last-child {
	flex: 0 0 auto;
}

#account-name {
	writing-mode: horizontal-tb !important;
}

#page-body {
	padding-top: 48px;
}

#content-container {
	max-width: 900px;
	margin: auto;
	padding-block: 2px 42px;
	padding-inline: 36px 36px;
	background-color: #f0f8f8;
}

#page-content {
	padding: 0 2px;
}

.toolbar {
	float: right;
	margin-inline: 4px;
	margin-block-start: 8px;
}

.head-toolbar {
	margin-block-start: 28px;
}

.toolbar a {
	cursor: pointer;
	font-size: 24px;
	align-items: center;
	justify-content: center;
	color: black;
	text-decoration: none;
	display: flex;
	float: left;
	width: 32px; height: 32px;
	padding: 0;
	border: solid 1px gray;
}

.toolbar a:first-child {
	border-start-start-radius: 8px;
	border-end-start-radius: 8px;
}

.toolbar a:last-child {
	border-start-end-radius: 8px;
	border-end-end-radius: 8px;
}

#page-footer {
	color: gray;
	font-size: small;
	text-align: center;
	padding: 32px;
}

#page-footer > div {
	margin: 8px 0;
}

#footer-tools {
	display: flex;
	justify-content: center;
}

#footer-tools > div {
	display: flex;
	border-inline-start: solid 1px gray;
	padding-inline: 20px;
	align-items: center;
}

#footer-tools > div > * {
	margin-inline: 2px;
}

#footer-tools > div:first-of-type {
	border-inline-start: none;
}

#footer-tools a {
	color: gray;
	text-decoration: none;
}

#page-footer pre {
	text-align: left;
}

#lang-sel {
	inline-size: 8em;
}

/* Languages */

:lang(ipa), :lang(\*-fonipa) {
	font-family: "Times New Roman", "Arial", "Courier New", "Segoe UI";
}

#content-container, html {
	writing-mode: initial;
}

.wm-vertical-rl {
	writing-mode: vertical-rl !important;
}

.wm-vertical-rl #header-flex {
	direction: rtl;
}

.wm-vertical-rl #header-flex a {
	writing-mode: vertical-rl;
}

#content-container.wm-vertical-rl {
	max-width: none;
	max-height: 480px;
	margin-top: 0;
}

/* Form Layout */

form {
	margin-block-end: 12px;
	border: solid 1px gray;
	padding: 4px;
}

form td {
	border: none;
}

textarea {
	inline-size: 100%;
	block-size: 480px;
	resize: block;
}

#content {
	font-family: monospace;
}

.wide-form table {
	inline-size: calc(100% - 8px);
}

/* General elements */

error {
	color: red;
	font-weight: bold;
}

.notice {
	color: green;
}

.hidden-link a {
	color: inherit;
	text-decoration: inherit;
	cursor: inherit;
}

span[toggle] > span:not([on]) {
	display: none;
}

h2, h3, h4, h5, h6 {
	overflow: hidden;
}

h1 {
	text-align: left;
	font-size: 36px;
	padding-block: 4px;
	padding-inline: 1px;
	border-block-end: solid 2px gray;
	margin-block: 20px 12px;
}

h2 {
	font-size: 26px;
	border-block-end: dashed 1px gray;
	margin-block: 30px 8px;
}

table {
	border-collapse: collapse;
}

th, td {
	padding-block: 2px;
	padding-inline: 4px;
	border: solid 1px gray;
}

th {
	text-align: center;
}

ul {
	list-style-type: disc;
}

ul ul {
	list-style-type: circle;
}

ul ul ul {
	list-style-type: square;
}

ul ul ul ul {
	list-style-type: "\25ab  ";
}

ul ul ul ul ul {
	list-style-type: "- ";
}

:lang(lzh) ol {
	list-style-type: trad-chinese-formal;
}

/*dl {
	margin: 0;
}*/

dl dl {
	margin-inline-start: 2em;
}

/*#page-content dl + dl, #page-content div:has(dl:last-child) + div:has(dl:first-child) {
	margin-block-start: 1em;
}*/

dt {
	font-weight: bold;
	margin-block-start: 8px;
}

dd {
	margin-inline-start: 2em;
}

pre, code {
	white-space: pre-wrap;
	word-break: break-all;
}

pre {
	background-color: white;
	margin-block: 1em;
	margin-inline: 0;
	border: solid 1px gray;
	border-radius: 4px;
	padding: 6px;
	text-align: left;
	-moz-tab-size: 4;
	-o-tab-size: 4;
	tab-size: 4;
}

figure {
	margin: 6px 12px;
	border: solid 1px gray;
	padding: 4px;
}

.fig-bq {
	padding-block: 1em;
	padding-inline: 2em;
}

.fig-bq figcaption {
	text-align: right;
	margin-inline-end: 1.5em;
}

.fig-bq blockquote {
	margin-inline: 0;
	margin-block: 0.5em;
	text-indent: 1em;
}

.fig-bq blockquote > p:first-child {
	margin-block-start: 0;
}

.fig-bq blockquote > p:last-child {
	margin-block-end: 0;
}

.punc-fw .fig-bq blockquote {
	text-indent: 2em;
}

blockquote dl {
	text-indent: 0;
}

[restriction] {
	background-color: #0000ff22;
	margin: 0;
}

h1 small {
	font-variant: all-small-caps;
}

ruby:has(ruby) {
	ruby-position: under;
}

rt {
	user-select: none;
}

/* Ornament */
.color {
	display: inline-block;
	border: solid 1px gray;
	width: .8em; height: .8em;
}

.solid {
	word-break: break-all;
	background-color: gray;
}

/* Talk */
.talk-thread-list {
	list-style: none;
	padding: 0;
}
.talk-thread-list div:not(.toolbar) {
	margin: 16px 0;
	border: solid 1px gray;
	border-radius: 8px;
	padding: 4px 8px;
}

/* Mobile */
@media screen and (max-width: 980px) {
	#content-container {
		padding-block: 2px 42px;
		padding-inline: 16px;
	}
	#content-container.wm-vertical-rl {
		padding-inline: 32px;
	}
}

@media screen and (max-width: 490px) {
	body {
		text-align: initial;
	}
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
	html {
		color-scheme: dark;
	}
	
	body {
		background-color: black;
	}
	
	#content-container, textarea, input, select {
		background-color: #080c0c;
		color: #ddd;
	}
	
	#page-header {
		background-color: #033;
	}
	
	#page-header a:hover {
		background-color: #255;
	}
	
	#page-header #logo-container {
		background-color: #244;
		border-color: #033;
	}
	
	a {
		color: #88f;
	}
	
	a:visited {
		color: #c4f;
	}
	
	.toolbar a {
		color: white;
	}
	
	pre {
		background-color: black;
	}
	
	[restriction] {
		background-color: #ffff0022;
	}
}

/* Print */
@media print {
	body {
		background-color: initial;
	}
	
	#page-header, #page-footer, .toolbar {
		display: none;
	}
	
	#page-body {
		padding: 0;
	}
	
	#content-container {
		background-color: initial;
	}
}