:root {
	--pine: #2f4a3a;
	--pine-deep: #1f3328;
	--berry: #8e2b4a;
	--cream: #f7f2e8;
	--paper: #fffdf8;
	--ink: #26302a;
	--muted: #5e6b62;
	--rule: #e3dccd;
	--font-display: "Fraunces", Georgia, "Times New Roman", serif;
	--font-body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

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

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--cream);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: 1.0625rem;
	line-height: 1.65;
}

.wrap {
	width: 100%;
	max-width: 46rem;
	margin: 0 auto;
	padding: 0 1rem;
}

/* Header */

.site-header {
	background: var(--pine);
	color: var(--cream);
	padding: 1.25rem 0;
}

.site-header .wrap {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.25rem 1.5rem;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	color: inherit;
	text-decoration: none;
}

.brand-mark {
	background: var(--cream);
	border-radius: 50%;
	padding: 4px;
	align-self: center;
}

.brand-name {
	font-family: var(--font-display);
	font-weight: 600;
	font-size: 1.9rem;
	letter-spacing: 0.01em;
}

.brand-tagline {
	margin: 0;
	font-family: var(--font-display);
	font-style: italic;
	opacity: 0.85;
}

/* Article */

main {
	flex: 1;
	padding-top: 2rem;
	padding-bottom: 3rem;
}

.article {
	background: var(--paper);
	border: 1px solid var(--rule);
	border-radius: 6px;
	padding: 1.5rem 1.25rem;
}

@media (min-width: 40rem) {
	.article {
		padding: 2.5rem 3rem;
	}
}

.article h1,
.article h2,
.article h3 {
	font-family: var(--font-display);
	font-weight: 600;
	line-height: 1.2;
	color: var(--pine-deep);
}

.article h1 {
	font-size: 2.2rem;
	margin: 0 0 1rem;
}

.article h2 {
	font-size: 1.5rem;
	margin: 2rem 0 0.5rem;
}

.article a {
	color: var(--berry);
}

.article img {
	max-width: 100%;
	height: auto;
}

.article blockquote {
	margin: 2rem 0 0;
	padding: 0.25rem 0 0.25rem 1rem;
	border-left: 3px solid var(--berry);
	font-family: var(--font-display);
	font-style: italic;
	font-size: 1.2rem;
	color: var(--muted);
}

.article blockquote p {
	margin: 0;
}

.article table {
	border-collapse: collapse;
	width: 100%;
	overflow-x: auto;
	display: block;
}

.article th,
.article td {
	border: 1px solid var(--rule);
	padding: 0.4rem 0.6rem;
	text-align: left;
}

/* Navigation */

.site-nav {
	margin-top: 0.9rem;
	border-top: 1px solid rgba(247, 242, 232, 0.2);
}

.site-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1.5rem;
	list-style: none;
	margin-top: 0;
	margin-bottom: 0;
	padding-top: 0.6rem;
}

.site-nav a {
	display: inline-block;
	padding: 0.25rem 0;
	color: var(--cream);
	font-weight: 500;
	text-decoration: none;
	border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a:focus-visible {
	border-bottom-color: rgba(247, 242, 232, 0.6);
}

.site-nav a[aria-current="page"] {
	border-bottom-color: var(--cream);
}

/* Admin toolbar */

.admin-bar {
	background: var(--pine-deep);
	color: var(--cream);
	font-size: 0.9rem;
}

.admin-bar .wrap {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.25rem 1rem;
	padding-top: 0.4rem;
	padding-bottom: 0.4rem;
}

.admin-status {
	margin: 0;
}

.admin-dot {
	display: inline-block;
	width: 0.55rem;
	height: 0.55rem;
	margin-right: 0.5rem;
	border-radius: 50%;
	background: #e0a03a;
}

.admin-actions {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.admin-bar form {
	margin: 0;
}

.admin-edit,
.admin-new {
	padding: 0.2rem 0.8rem;
	border-radius: 4px;
	background: var(--cream);
	color: var(--pine-deep);
	font-weight: 500;
	text-decoration: none;
}

.admin-edit:hover,
.admin-new:hover,
.admin-edit:focus-visible,
.admin-new:focus-visible {
	background: #fff;
}

.admin-bar button {
	padding: 0.2rem 0.8rem;
	border: 1px solid rgba(247, 242, 232, 0.5);
	border-radius: 4px;
	background: transparent;
	color: var(--cream);
	font: inherit;
	cursor: pointer;
}

.admin-bar button:hover,
.admin-bar button:focus-visible {
	background: rgba(247, 242, 232, 0.12);
}

/* Login */

.login-form {
	display: grid;
	gap: 0.4rem;
	max-width: 22rem;
}

.login-form input {
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--rule);
	border-radius: 4px;
	background: var(--paper);
	color: var(--ink);
	font: inherit;
}

.login-form label:not(:first-of-type) {
	margin-top: 0.5rem;
}

.login-form button {
	justify-self: start;
	margin-top: 1rem;
	padding: 0.5rem 1.4rem;
	border: 0;
	border-radius: 4px;
	background: var(--pine);
	color: var(--cream);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.login-form button:hover,
.login-form button:focus-visible {
	background: var(--pine-deep);
}

.login-error {
	padding: 0.6rem 0.8rem;
}

/* Error boxes: login, form and upload errors. */
.login-error,
.form-errors,
.md-upload-error {
	border-left: 3px solid var(--berry);
	background: #f6e6ea;
	color: var(--berry);
}

/* Editor */

.edit-form {
	display: grid;
	gap: 0.4rem;
}

.edit-form > label:not(:first-child) {
	margin-top: 0.6rem;
}

.edit-form input[type="text"],
.md-editor textarea {
	width: 100%;
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--rule);
	border-radius: 4px;
	background: var(--paper);
	color: var(--ink);
	font: inherit;
}

.slug-field {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	color: var(--muted);
}

.field-hint {
	margin: 0;
	color: var(--muted);
	font-size: 0.85rem;
}

.edit-form .check {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.8rem;
}

.md-editor {
	margin-top: 1rem;
	border: 1px solid var(--rule);
	border-radius: 6px;
	overflow: hidden;
}

.md-tabs {
	display: flex;
	gap: 0.25rem;
	padding: 0.4rem 0.5rem 0;
	background: var(--cream);
	border-bottom: 1px solid var(--rule);
}

.md-tabs [role="tab"] {
	margin-bottom: -1px;
	padding: 0.4rem 1rem;
	border: 1px solid transparent;
	border-radius: 6px 6px 0 0;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 0.95rem;
	cursor: pointer;
}

.md-tabs [role="tab"][aria-selected="true"] {
	border-color: var(--rule);
	border-bottom-color: var(--paper);
	background: var(--paper);
	color: var(--ink);
	font-weight: 500;
}

.md-pane {
	padding: 0.75rem;
	background: var(--paper);
}

.md-pane[hidden] {
	display: none;
}

.md-editor textarea {
	display: block;
	min-height: 20rem;
	resize: vertical;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
	line-height: 1.5;
}

/* Files dragged over the textarea: drop to upload. */
.md-editor textarea.md-drop-target {
	outline: 2px dashed var(--pine);
	outline-offset: -4px;
	background: var(--cream);
}

.md-format {
	display: flex;
	flex-wrap: wrap;
	gap: 0.15rem;
	margin-bottom: 0.5rem;
}

.md-format[hidden] {
	display: none;
}

.md-format button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2rem;
	height: 2rem;
	padding: 0 0.4rem;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 0.95rem;
	cursor: pointer;
}

.md-format button:hover,
.md-format button:focus-visible {
	border-color: var(--rule);
	background: var(--cream);
	color: var(--ink);
}

.md-format-sep {
	align-self: stretch;
	width: 1px;
	margin: 0.3rem;
	background: var(--rule);
}

.md-format code {
	font-size: 0.8rem;
}

.md-upload-error {
	margin: 0 0 0.5rem;
	padding: 0.4rem 0.8rem;
}

/* Välj bild: a modal list of uploaded images. */
.md-picker {
	width: min(44rem, calc(100vw - 2rem));
	max-height: calc(100vh - 4rem);
	padding: 1rem 1.25rem 1.25rem;
	border: 1px solid var(--rule);
	border-radius: 6px;
	background: var(--paper);
	color: var(--ink);
}

.md-picker::backdrop {
	background: rgba(31, 51, 40, 0.45);
}

.md-picker-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 0.75rem;
}

.md-picker-head h2 {
	margin: 0;
	font-size: 1.3rem;
}

.md-picker-close {
	padding: 0.3rem 0.8rem;
	border: 1px solid var(--rule);
	border-radius: 4px;
	background: transparent;
	color: var(--ink);
	font: inherit;
	cursor: pointer;
}

.md-picker-status:empty {
	display: none;
}

.md-picker-status,
.md-picker-empty {
	margin: 0.5rem 0;
	color: var(--muted);
}

.md-picker-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
	gap: 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.md-picker-item {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	width: 100%;
	padding: 0.4rem;
	border: 1px solid var(--rule);
	border-radius: 4px;
	background: var(--cream);
	color: var(--ink);
	font: inherit;
	font-size: 0.85rem;
	text-align: left;
	cursor: pointer;
}

.md-picker-item img {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	background: var(--paper);
}

/* A grid item shrinks below its content only with min-width 0, and a
   button's flex children aren't held to its width, so the caption gets
   max-width: the long-filename ellipsis needs both. */
.md-picker-list li {
	min-width: 0;
}

.md-picker-item span {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.md-picker-close:hover,
.md-picker-close:focus-visible,
.md-picker-item:hover,
.md-picker-item:focus-visible {
	border-color: var(--pine);
	outline: 2px solid var(--pine);
	outline-offset: 1px;
}

.md-editor .field-hint {
	margin-top: 0.5rem;
}

.md-preview {
	min-height: 20rem;
	padding: 1rem 1.25rem;
}

.md-preview-note {
	color: var(--muted);
	font-style: italic;
}

.form-actions {
	display: flex;
	align-items: center;
	gap: 1.25rem;
	margin-top: 1rem;
}

.form-actions button {
	padding: 0.5rem 1.6rem;
	border: 0;
	border-radius: 4px;
	background: var(--pine);
	color: var(--cream);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.form-actions button:hover,
.form-actions button:focus-visible {
	background: var(--pine-deep);
}

.form-actions a {
	color: var(--muted);
}

.form-errors {
	margin: 0 0 1rem;
	padding: 0.6rem 0.8rem 0.6rem 2rem;
}

/* Not found */

.not-found {
	text-align: center;
}

.not-found-code {
	margin: 0;
	font-family: var(--font-display);
	font-size: 3.5rem;
	font-weight: 600;
	line-height: 1;
	color: var(--berry);
}

/* Footer */

.site-footer {
	border-top: 1px solid var(--rule);
	color: var(--muted);
	font-size: 0.9rem;
}

.site-footer p {
	margin: 1.25rem 0;
}

/* A quiet way in for the admin: looks like the rest of the footer. */
.footer-login {
	color: inherit;
	text-decoration: none;
}

.footer-login:hover {
	text-decoration: underline dotted;
}

.footer-login:focus-visible {
	outline: 2px solid var(--pine);
	outline-offset: 2px;
}

.app-version {
	font-size: 0.8rem;
	opacity: 0.85;
}
