:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #5f6b62;
  --line: #d8ddd7;
  --paper: #fbfcf8;
  --surface: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --danger-bg: #fff1ee;
  --shadow: 0 18px 50px rgba(23, 33, 27, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 0 5vw;
  border-bottom: 1px solid rgba(216, 221, 215, 0.86);
  background: rgba(251, 252, 248, 0.92);
  backdrop-filter: blur(16px);
}

.brand,
.nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border: 6px solid var(--accent);
  border-left-color: #eab308;
  border-radius: 50%;
  flex: 0 0 auto;
}

.nav {
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.nav a,
.ghost-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
}

.nav a:hover,
.ghost-button:hover,
.admin-link {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.hero {
  --hero-image: url("https://images.unsplash.com/photo-1518005020951-eccb494ad742?auto=format&fit=crop&w=1800&q=80");
  min-height: 0;
  display: grid;
  align-items: center;
  padding: clamp(38px, 5vw, 64px) 5vw;
  background-image:
    linear-gradient(90deg, rgba(23, 33, 27, 0.82), rgba(23, 33, 27, 0.38) 54%, rgba(23, 33, 27, 0.08)),
    var(--hero-image);
  background-position: center;
  background-size: cover;
  color: #fff;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #facc15;
}

.hero h1 {
  margin: 0;
  font-size: clamp(44px, 8vw, 86px);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero p:not(.eyebrow) {
  max-width: 660px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 18px;
}

.section,
.admin-shell {
  width: min(1180px, 90vw);
  margin: 0 auto;
}

.section {
  padding: 64px 0;
}

.section + .section {
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px;
}

.image-card,
.form-panel,
.admin-image {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(23, 33, 27, 0.06);
}

.image-card {
  overflow: hidden;
  width: min(100%, var(--image-card-width, 320px));
}

.image-card img {
  width: 100%;
  height: var(--image-height, auto);
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  background: #e7ebe5;
}

.image-card div {
  padding: 16px;
}

.image-card h3,
.admin-image h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.image-card p,
.admin-image p {
  margin: 0;
  color: var(--muted);
}

.doc-layout,
.doc-editor-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.doc-tabs {
  display: grid;
  gap: 8px;
}

.doc-tabs button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
}

.doc-tabs button:hover,
.doc-tabs button.is-active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.markdown-body {
  min-height: 360px;
  padding: 4px 0;
  color: #1f2a24;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.15;
}

.markdown-body h1 {
  margin-top: 0;
  font-size: 34px;
}

.markdown-body a {
  color: var(--accent-strong);
  text-decoration: underline;
}

.markdown-body :not(pre) > code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #e8f1eb;
  color: #0f4f48;
  font-weight: 700;
}

.code-block {
  position: relative;
  overflow: hidden;
  margin: 18px 0;
  border: 1px solid #294238;
  border-radius: 8px;
  background: #101d17;
}

.markdown-body pre {
  margin: 0;
  overflow: auto;
  padding: 48px 18px 18px;
  background: transparent;
  color: #f4fff8;
  font-size: 14px;
  line-height: 1.65;
}

.markdown-body pre code {
  display: block;
  padding: 0;
  background: transparent;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.code-copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(244, 255, 248, 0.2);
  border-radius: 7px;
  background: #f4fff8;
  color: #101d17;
  font-size: 12px;
  font-weight: 800;
}

.code-copy-button:hover {
  background: #dff3e7;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.admin-shell {
  padding: 48px 0 72px;
}

.login-panel {
  display: grid;
  place-items: start center;
}

.form-panel {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 22px;
}

.form-panel h1,
.form-panel h2 {
  margin: 0;
}

.form-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.form-panel input,
.form-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

.form-panel textarea {
  resize: vertical;
}

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

.login-panel .form-panel {
  max-width: 440px;
  box-shadow: var(--shadow);
}

.home-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-editor .topbar {
  position: relative;
  top: auto;
  z-index: 1;
}

.admin-preview-topbar {
  align-items: stretch;
  min-height: auto;
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.95);
}

.admin-preview-nav {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-edit {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-edit input,
.inline-edit textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

.inline-edit textarea {
  resize: vertical;
}

.brand-edit {
  width: min(320px, 100%);
}

.editor-hero {
  min-height: 0;
  padding: clamp(38px, 5vw, 64px) 5vw;
}

.editor-hero-copy {
  display: grid;
  gap: 14px;
  width: min(760px, 100%);
}

.editor-hero .inline-edit {
  color: rgba(255, 255, 255, 0.82);
}

.editor-hero .inline-edit input,
.editor-hero .inline-edit textarea {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.hero-title-field input {
  min-height: 76px;
  font-size: clamp(32px, 6vw, 64px);
  font-weight: 900;
  line-height: 1.05;
}

.admin-edit-section {
  display: grid;
  gap: 18px;
  padding: 24px;
}

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

.home-editor .primary-button {
  justify-self: start;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 22px;
}

.manage-section {
  padding-top: 42px;
}

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

.admin-image {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
}

.admin-image img {
  width: 112px;
  height: 112px;
  border-radius: 8px;
  object-fit: cover;
  background: #e7ebe5;
}

.admin-image div {
  display: grid;
  align-content: start;
  gap: 8px;
}

.image-size-text {
  font-size: 12px;
}

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

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

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

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

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-button {
  border-color: #ffc9c2;
  background: var(--danger-bg);
  color: var(--danger);
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .doc-layout,
  .doc-editor-layout,
  .admin-grid,
  .copy-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .admin-preview-nav {
    justify-content: flex-start;
  }

  .doc-tabs {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

@media (max-width: 520px) {
  .section,
  .admin-shell {
    width: min(100% - 28px, 1180px);
  }

  .hero {
    padding-left: 14px;
    padding-right: 14px;
  }

  .admin-image {
    grid-template-columns: 1fr;
  }

  .admin-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
  }
}
