:root {
  --forest: #14251f;
  --limestone: #f2eee5;
  --brass: #b49a6a;
  --brass-dark: #806b45;
  --graphite: #2c2f32;
  --line: #d9d3c6;
  --focus: #806b45;
  --shadow: 0 12px 28px rgba(20, 37, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: linear-gradient(180deg, #f8f5ee 0%, var(--limestone) 100%);
  color: var(--graphite);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

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

.wrapper {
  width: min(1120px, calc(100% - 2.5rem));
  margin: 0 auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}

.skip-link:focus-visible {
  left: 1rem;
  top: 1rem;
  z-index: 1000;
  background: var(--limestone);
  border: 2px solid var(--focus);
  padding: 0.5rem 0.75rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  flex: 0 1 auto;
}

.monogram {
  width: auto;
  height: 44px;
  flex: 0 0 auto;
}

.wordmark {
  width: clamp(190px, 14vw, 220px);
  height: auto;
  display: block;
  flex: 0 1 auto;
}

.link-login,
.text-link {
  color: var(--forest);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.link-login {
  font-size: 0.95rem;
}

.hero {
  position: relative;
  display: grid;
  min-height: clamp(360px, calc(100svh - 92px), 760px);
  overflow: visible;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.hero-media {
  grid-area: 1 / 1;
  z-index: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
  filter: saturate(85%);
}

.hero-overlay {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding-top: clamp(1rem, 3vh, 2rem);
  padding-bottom: clamp(1rem, 4vh, 2.5rem);
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--forest);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.hero-overlay h1 {
  max-width: 18ch;
  color: #f7f4ef;
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0;
}

.hero-overlay p {
  margin-top: 1rem;
  max-width: 64ch;
  font-size: 1rem;
  color: #f4efe3;
  background: rgba(20, 37, 31, 0.34);
  padding: 0.85rem 1rem;
  border-left: 2px solid var(--brass);
}

.link-login {
  white-space: nowrap;
}

.section {
  padding: 3rem 0 2rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.95rem;
}

.auth-main,
.dashboard-main,
.wiki-main {
  padding: 1.5rem 0 3rem;
}

.auth-card,
.storage-panel,
.wiki-article,
.tile {
  background: #fcfaf4;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(520px, 100%);
  margin: 2rem auto;
  padding: 1.5rem;
}

label {
  display: block;
  margin-top: 0.8rem;
  margin-bottom: 0.3rem;
}

input {
  width: 100%;
  border: 1px solid #c2b8a2;
  background: #fffdf8;
  padding: 0.65rem 0.7rem;
}

.btn-primary,
.btn-quiet {
  margin-top: 1rem;
  border: 1px solid var(--forest);
  background: var(--forest);
  color: #f8f6f1;
  padding: 0.65rem 1rem;
  cursor: pointer;
}

.btn-quiet {
  background: transparent;
  color: var(--forest);
  border-color: #38584d;
  margin-top: 0;
}

.inline-form {
  display: inline;
}

.inline-form input[type="hidden"] {
  display: none;
}

.header-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.95rem;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.storage-panel {
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.meter {
  height: 16px;
  background: #e8e2d5;
  border: 1px solid #cdbf9f;
  margin-top: 0.8rem;
}

.meter-bar {
  height: 100%;
  background: linear-gradient(90deg, #2f493f, #4f6c5f);
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.tile {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tile-description {
  margin: 0;
}

.metric-grid {
  display: grid;
  gap: 0.45rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  border-bottom: 1px solid #ece5d7;
  padding-bottom: 0.25rem;
}

.metric-row strong {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.env-chip {
  display: inline-block;
  margin-top: -0.2rem;
  margin-bottom: 0.8rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid #d5c4a1;
  color: var(--brass-dark);
  background: #faf5e8;
  font-size: 0.85rem;
}

.wiki-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.wiki-page-list,
.wiki-history-list {
  padding-left: 1.1rem;
}

.wiki-page-list li,
.wiki-history-list li {
  margin-bottom: 0.55rem;
}

.wiki-actions {
  margin-top: 0.85rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.wiki-editor textarea {
  width: 100%;
  border: 1px solid #c2b8a2;
  background: #fffdf8;
  padding: 0.7rem;
  min-height: 18rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  line-height: 1.5;
}

.wiki-editor-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
}

.wiki-format-help {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.wiki-preview {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.wiki-content {
  line-height: 1.62;
}

.wiki-content h1,
.wiki-content h2,
.wiki-content h3 {
  line-height: 1.22;
}

.wiki-content pre,
.wiki-content code {
  font-family: "Courier New", Courier, monospace;
}

.wiki-content pre {
  background: #f5f1e8;
  border: 1px solid #d7ccb7;
  padding: 0.8rem;
  overflow-x: auto;
}

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

.wiki-content th,
.wiki-content td {
  border: 1px solid #d7ccb7;
  padding: 0.45rem 0.55rem;
  text-align: left;
  white-space: nowrap;
}

.wiki-content blockquote {
  margin: 1rem 0;
  padding: 0.25rem 0.9rem;
  border-left: 4px solid #a99a7e;
  color: #4f5458;
}

.wiki-restore {
  margin-top: 0.8rem;
}

.wiki-delete form {
  margin-top: 1rem;
}

.wiki-trash-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.wiki-trash-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.wiki-trash-list li:first-child {
  border-top: 0;
}

.wiki-trash-list .btn-quiet {
  margin-top: 0;
}

.badge {
  display: inline-block;
  margin-right: 0.7rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--brass-dark);
  border: 1px solid #d5c4a1;
  padding: 0.1rem 0.5rem;
}

.hidden {
  display: none;
}

.muted,
.note {
  color: #585e61;
}

.error-text {
  margin-top: 0.8rem;
  margin-bottom: 0.8rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #b76d6d;
  background: #fff2f2;
  color: #6f2929;
}

.totp-qr-block {
  margin-top: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.totp-qr {
  width: 192px;
  height: 192px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.4rem;
}

.recovery-code-list {
  padding-left: 1.15rem;
}

.recovery-code-list code {
  letter-spacing: 0.06em;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (min-width: 700px) {
  .tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .tile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .wrapper {
    width: min(1120px, calc(100% - 1.3rem));
  }

  .site-header {
    gap: 0.6rem;
  }

  .brand {
    gap: 0.55rem;
    min-width: 0;
  }

  .monogram {
    height: 34px;
  }

  .wordmark {
    width: clamp(160px, 48vw, 208px);
  }

  .hero {
    min-height: max(420px, calc(100svh - 86px));
  }

  .hero-overlay {
    justify-content: flex-start;
    padding-top: clamp(1rem, 8vh, 3rem);
    padding-bottom: 1rem;
  }

  .hero-overlay h1 {
    font-size: clamp(1.75rem, 8vw, 2.25rem);
  }

  .site-footer {
    flex-direction: column;
    gap: 0.15rem;
  }

  .dashboard-head {
    flex-direction: column;
    align-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
