* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #676f7a;
  --line: #dedbd2;
  --accent: #1f6f5b;
  --accent-strong: #154e41;
  --code-bg: #eff3f1;
  --shadow: 0 18px 45px rgba(30, 36, 31, 0.08);
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(31, 111, 91, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(31, 111, 91, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
}

.topbar {
  align-items: center;
  display: flex;
  height: 72px;
  justify-content: center;
  padding: 0 20px;
}

.brand {
  align-items: center;
  display: inline-flex;
  font-weight: 700;
  gap: 10px;
  text-decoration: none;
}

.brand__mark {
  align-items: center;
  background: var(--accent);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.layout {
  margin: 0 auto;
  max-width: 1120px;
  padding: 24px 20px 80px;
}

.intro {
  align-items: end;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.1) 45%, rgba(255, 255, 255, 0.84)),
    url("backgrounds/pnr-sfz-light.png") center / cover no-repeat;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 28px;
  grid-template-columns: 1fr;
  justify-items: end;
  margin: 20px 0 30px;
  min-height: 430px;
  padding: 34px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
  margin: 0;
  max-width: 640px;
}

.intro p:not(.eyebrow),
.article__header p:not(.eyebrow) {
  color: var(--muted);
  font-size: 18px;
  margin: 18px 0 0;
  max-width: 680px;
}

.stats {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  min-width: 150px;
  padding: 18px;
}

.stats strong {
  font-size: 42px;
  line-height: 1;
}

.stats span {
  color: var(--muted);
}

.home-content {
  align-items: start;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 260px;
}

.home-main {
  min-width: 0;
}

.engineer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 12px;
  position: sticky;
  top: 18px;
}

.engineer-card img {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  display: block;
  object-fit: cover;
  width: 100%;
}

.engineer-card p {
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
  margin: 0;
  text-align: center;
}

.manuals-locked,
.access-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.manuals-locked h2,
.access-card h1 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0;
}

.manuals-locked p:not(.eyebrow),
.access-card p:not(.eyebrow) {
  color: var(--muted);
  margin: 12px 0 0;
}

.access-page {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.access-card {
  justify-self: center;
  max-width: 520px;
}

.access-card .primary-button {
  margin-top: 20px;
  text-decoration: none;
}

.toolbar {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 12px 0 24px;
}

.toolbar--top {
  margin: 0 0 18px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.search {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  padding: 14px 16px;
}

.search span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input {
  border: 0;
  color: var(--ink);
  font: inherit;
  outline: 0;
  width: 100%;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  align-items: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 800;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.66;
}

.secondary-button {
  background: #e7eee9;
  color: var(--accent-strong);
}

.danger-button {
  background: #f8e6e6;
  color: #9f2424;
}

.compact-button {
  min-height: 38px;
  padding: 0 12px;
}

.icon-button {
  background: var(--code-bg);
  color: var(--ink);
  height: 42px;
  min-height: 42px;
  padding: 0;
  width: 42px;
}

.modal[hidden] {
  display: none;
}

.modal {
  inset: 0;
  position: fixed;
  z-index: 20;
}

.modal-open {
  overflow: hidden;
}

.modal__backdrop {
  background: rgba(24, 33, 30, 0.56);
  inset: 0;
  position: absolute;
}

.composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(24, 33, 30, 0.26);
  display: grid;
  gap: 20px;
  left: 50%;
  max-height: min(920px, calc(100vh - 32px));
  max-width: 920px;
  overflow: auto;
  padding: 24px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100vw - 32px);
}

.composer__header {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding-bottom: 16px;
}

.composer__header h2 {
  font-size: 30px;
  line-height: 1.1;
  margin: 0;
}

.composer__form,
.preview {
  display: grid;
  gap: 14px;
}

.composer label,
.preview {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
}

.composer input,
.composer select,
.composer textarea,
.preview textarea {
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  outline: 0;
  padding: 12px 14px;
  resize: vertical;
  width: 100%;
}

.composer textarea,
.preview textarea {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
}

.composer input:focus,
.composer select:focus,
.composer textarea:focus,
.preview textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.14);
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-section-title {
  background: #f4f6f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.form-section-title h3 {
  font-size: 20px;
  line-height: 1.2;
  margin: 0;
}

.form-section-title p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin: 6px 0 0;
}

.permission-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-grid label {
  align-items: center;
  background: #f4f6f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
}

.permission-grid input {
  width: auto;
}

.user-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.user-row {
  align-items: center;
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  color: var(--muted);
  font-size: 13px;
}

.small-modal {
  max-width: 520px;
}

.auth-label {
  align-items: center;
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  min-height: 48px;
  padding: 0 14px;
}

.image-picker {
  background: #f4f6f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.form-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

.form-status {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  min-height: 22px;
}

.composer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.post-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.post-card {
  min-height: 220px;
  position: relative;
}

.post-card__link {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 22px;
  padding-bottom: 76px;
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

.post-card__actions {
  bottom: 18px;
  display: flex;
  gap: 8px;
  left: 22px;
  position: absolute;
  right: 22px;
}

.post-card__link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.post-card__date {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.post-card h2 {
  font-size: 24px;
  line-height: 1.16;
  margin: 18px 0 10px;
}

.post-card p {
  color: var(--muted);
  margin: 0;
}

.post-card__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 22px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.tag {
  background: #e7eee9;
  border: 1px solid #d3dfd8;
  border-radius: 999px;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 8px 10px;
}

.article-shell {
  margin: 0 auto;
  max-width: 860px;
  padding: 24px 20px 90px;
}

.article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 56px);
}

.back-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.article__header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 34px;
  padding: 34px 0 30px;
}

.article__body {
  font-size: 18px;
}

.article__body h2 {
  font-size: 30px;
  line-height: 1.2;
  margin: 42px 0 12px;
}

.article__body h3 {
  font-size: 23px;
  line-height: 1.25;
  margin: 32px 0 10px;
}

.article__body p,
.article__body ul,
.article__body ol,
.article__body blockquote,
.article__body pre {
  margin: 0 0 20px;
}

.article__body a {
  color: var(--accent-strong);
  font-weight: 700;
}

.article__body img {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: auto;
  margin: 26px 0;
  max-width: 100%;
}

.article__body code {
  background: var(--code-bg);
  border-radius: 6px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  padding: 2px 6px;
}

.article__body pre {
  background: #18211e;
  border-radius: 8px;
  color: #f6faf8;
  overflow-x: auto;
  padding: 18px;
}

.article__body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.article__body blockquote {
  border-left: 4px solid var(--accent);
  color: var(--muted);
  padding-left: 18px;
}

.empty {
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar {
    height: 64px;
    justify-content: flex-start;
  }

  .intro {
    align-items: start;
    grid-template-columns: 1fr;
    padding-top: 22px;
  }

  .stats {
    min-width: 0;
    width: 100%;
  }

  .toolbar,
  .form-row {
    grid-template-columns: 1fr;
  }

  .home-content {
    grid-template-columns: 1fr;
  }

  .engineer-card {
    margin: 0 auto;
    max-width: 320px;
    position: static;
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .article {
    padding: 22px;
  }
}
