:root {
  color-scheme: light;
  --bg: #f2f6fc;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #69707a;
  --line: #e0e5ec;
  --accent: #dc392d;
  --accent-dark: #b02e24;
  --nav-accent: #212832;
  --danger: #e81500;
  --accent-rgb: 220, 57, 45;
  --accent-dark-rgb: 176, 46, 36;
  --nav-accent-rgb: 33, 40, 50;
  --page-bg: #f2f6fc;
  --menu-horizontal: #ffffff;
  --menu-vertical: #212832;
  --button-bg: #0061f2;
  --button-hover: #004ec2;
  --button-text: #ffffff;
  --button-font-size: 14px;
  --form-bg: #ffffff;
  --form-border: #e0e5ec;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
main { max-width: 1440px; margin: 0 auto; padding: 32px; }
.public-footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px 32px;
}
.public-footer .markdown {
  min-height: 0;
  padding-top: 22px;
  border-top: 1px solid var(--form-border);
  color: var(--muted);
}
.public-footer .markdown > :first-child { margin-top: 0; }
.public-footer .markdown > :last-child { margin-bottom: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 0 28px;
  background: var(--menu-horizontal);
  border-bottom: 1px solid var(--form-border);
  box-shadow: 0 10px 28px rgba(33, 40, 50, .06);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 800;
  color: #212832;
  letter-spacing: .01em;
}
/*.brand:hover { color: var(--button-bg); text-decoration: none; }*/
.brand:hover { text-decoration: none; }
.menu-toggle {
  display: none;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--form-border);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--button-bg) 0%, var(--button-hover) 100%);
  color: var(--button-text);
  font-weight: 800;
}
.topbar .main-menu {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}
.topbar .main-menu a,
.topbar .main-menu summary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #363d47;
  font-size: 14px;
  font-weight: 750;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.topbar .main-menu summary {
  list-style: none;
  cursor: pointer;
}
.topbar .main-menu summary::-webkit-details-marker { display: none; }
.topbar .main-menu summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .15s ease;
}
.topbar .main-menu a:hover,
.topbar .main-menu summary:hover,
.topbar .nav-dropdown[open] > summary {
  background: #f2f6fc;
  color: var(--button-bg);
  text-decoration: none;
}
.topbar .nav-dropdown[open] > summary::after {
  transform: rotate(225deg) translate(-2px, -1px);
}
.topbar .nav-dropdown {
  position: relative;
}
.topbar .nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 240px;
  max-width: min(340px, calc(100vw - 32px));
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--form-border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(33, 40, 50, .16);
}
.topbar .nav-dropdown:not([open]) .nav-dropdown-menu {
  display: none;
}
.topbar .nav-dropdown-menu a {
  justify-content: flex-start;
  width: 100%;
}
.topbar .main-menu a[href="/admin"] {
  margin-left: 6px;
  background: #212832;
  color: #ffffff;
}
.topbar .main-menu a[href="/admin"]:hover {
  background: #363d47;
  color: #ffffff;
}

.hero, .app-hero {
  height: 260px;
  box-sizing: border-box;
  display: flex;
  align-items: end;
  padding: 44px;
  margin-bottom: 28px;
  color: #212832;
  background:
    linear-gradient(90deg, rgba(237, 243, 253, .46) 0%, rgba(237, 243, 253, .28) 42%, rgba(237, 243, 253, .12) 100%),
    url("/assets/hero-code-calm.png") center/cover;
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(33, 40, 50, .08);
  overflow: hidden;
}
.hero.compact, .app-hero.compact { height: 260px; }
.hero h1, .app-hero h1 { margin: 0; font-size: 56px; letter-spacing: 0; line-height: 1.05; }
.hero p, .app-hero p { max-width: 720px; font-size: 18px; color: #4a515b; }
.eyebrow { margin: 0 0 10px; color: #0061f2; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; font-weight: 800; }
.section-title { margin: 0 0 18px; font-size: 30px; line-height: 1.15; }
.app-hero { align-items: center; gap: 24px; }
.app-icon { width: 112px; height: 112px; border-radius: 22px; object-fit: cover; box-shadow: 0 18px 42px rgba(0,0,0,.25); flex: 0 0 auto; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: start;
}
.bugs-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  align-items: start;
}
.contact-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.contact-form-panel { width: 100%; }
.app-detail {
  display: grid;
  gap: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}
.form-grid > .side-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.form-grid > .side-panel > .stack:last-child {
  margin-top: auto;
}
.markdown-panel, .side-panel, .admin-card {
  background: var(--form-bg);
  border: 1px solid var(--form-border);
  border-radius: var(--radius);
  padding: 22px;
}
.markdown { min-height: 160px; overflow-wrap: anywhere; }
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.15; }
.markdown pre {
  overflow: auto;
  background: linear-gradient(135deg, #eff6ff 0%, #ecfdf5 52%, #f3f4f6 100%);
  color: #1f2937;
  border: 1px solid #cbd5e1;
  padding: 14px;
  border-radius: var(--radius);
}
.markdown code { background: #eef2f6; padding: 2px 5px; border-radius: 4px; }
.markdown pre code { background: transparent; padding: 0; }

.app-list { display: grid; gap: 10px; }
.app-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.app-card img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.app-card small { display: block; color: var(--muted); }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--form-border);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: var(--form-bg);
}
textarea { min-height: 120px; resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--button-bg);
  color: var(--button-text);
  font-size: var(--button-font-size);
  font-weight: 700;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--button-hover); color: var(--button-text); text-decoration: none; }
.small-button { min-height: 32px; padding: 6px 10px; }
.secondary-button { background: #e0e5ec; color: #363d47; }
.secondary-button:hover { background: #c5ccd6; color: #363d47; }
.success-button { background: var(--accent); color: #ffffff; }
.success-button:hover { background: var(--accent-dark); color: #ffffff; }
.danger-button { background: var(--danger); }
.danger-button:hover { background: #b02e24; }
.button-row, .file-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
td.button-row { flex-wrap: nowrap; white-space: nowrap; }
.file-form { flex-wrap: nowrap; width: 100%; }
.file-form input[type="file"] { flex: 1 1 auto; }
.file-form button { flex: 0 0 auto; }
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--form-border);
  border-radius: 6px;
  background: var(--form-bg);
  color: var(--button-bg);
  font-weight: 800;
}
.pagination a:hover,
.pagination a.active {
  background: var(--button-bg);
  border-color: var(--button-bg);
  color: var(--button-text);
  text-decoration: none;
}
.stack { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.notice {
  border: 1px solid #99d9d1;
  background: #ecfdf8;
  color: #134e4a;
  border-radius: var(--radius);
  padding: 10px 12px;
}
.notice.error { border-color: #f5b5ae; background: #fff0ee; color: var(--danger); }
.form-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.captcha-image { display: block; width: 220px; max-width: 100%; height: 74px; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; }
.muted { color: var(--muted); }

.bug-list { display: grid; gap: 10px; margin-bottom: 18px; }
.bug-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.bug-row span { display: block; color: var(--muted); font-size: 13px; }
.bug-row p { margin: 6px 0; }

.admin-body { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.admin-login-body {
  display: block;
  min-height: 100vh;
}
.admin-login-body .admin-main {
  display: grid;
  min-height: 100vh;
  align-items: center;
}
.admin-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px;
  height: 100vh;
  background:
    linear-gradient(155deg, rgba(237, 243, 253, .96) 0%, rgba(237, 243, 253, .82) 52%, rgba(237, 243, 253, .62) 100%),
    url("/assets/hero-code-calm.png") 38% center/cover;
  border-right: 1px solid rgba(37, 99, 235, .14);
  color: #212832;
}
.admin-nav-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-menu { display: flex; flex: 1 1 auto; flex-direction: column; gap: 4px; }
.admin-menu-toggle {
  display: none;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(37, 99, 235, .18);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--button-text);
  font-weight: 800;
}
.admin-nav a { color: #363d47; padding: 10px; border-radius: 6px; font-weight: 700; }
.admin-nav a:hover { background: rgba(255, 255, 255, .72); color: #004ec2; text-decoration: none; }
.admin-nav .brand { color: #212832; font-size: 20px; margin-bottom: 14px; }
.admin-nav .brand:hover { color: #004ec2; }
.admin-menu .logout-link { margin-top: auto; }
.admin-main { width: 100%; max-width: none; margin: 0; padding: 28px; }
.admin-card.narrow { max-width: 420px; margin: 10vh auto; }
.login-card { width: min(100%, 640px); margin: 0 auto; }
.login-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}
.login-actions button { flex: 0 0 auto; width: auto; }
.admin-split { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.pages-editor-grid { grid-template-columns: minmax(520px, 1fr) minmax(520px, 1fr); margin-top: 20px; }
.admin-form-below { margin-top: 20px; width: 100%; }
.editor-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.markdown-editor {
  display: grid;
  gap: 7px;
}
.markdown-editor > label {
  color: #475467;
  font-weight: 700;
}
.markdown-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--form-border);
  border-radius: 6px;
  background: #f8fafc;
}
.markdown-toolbar button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--form-border);
  background: var(--form-bg);
  color: #344054;
  font-size: 13px;
  line-height: 1;
}
.markdown-toolbar button:hover,
.markdown-toolbar button:focus {
  border-color: var(--button-bg);
  background: var(--button-bg);
  color: var(--button-text);
}
.markdown-preview { min-height: 300px; border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; overflow-wrap: anywhere; }
.current-image-preview { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafc; }
.current-image-preview img { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; box-shadow: 0 8px 18px rgba(33, 40, 50, .16); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats div { background: var(--form-bg); border: 1px solid var(--form-border); border-radius: var(--radius); padding: 20px; }
.stats strong { display: block; font-size: 34px; }
.stats span { color: var(--muted); }
.dashboard-stats { width: 100%; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 24px; }
.dashboard-stats div { padding: 28px; }
.quick-actions-panel { width: 100%; }
.quick-actions-panel .button-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}
.quick-actions-panel .button { width: 100%; }
.profile-panel { width: 100%; max-width: none; }
.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.profile-preview {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.profile-image-preview { display: grid; gap: 10px; justify-items: start; }
.align-right { justify-self: end; width: auto; }
.site-settings-panel { width: 100%; }
.site-settings-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 16px;
  align-items: end;
}
.site-settings-grid label { display: grid; gap: 6px; color: #475467; font-weight: 700; }
.site-settings-grid input[type="color"] {
  min-height: 44px;
  padding: 4px;
}
.footer-settings-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 16px;
  align-items: stretch;
}
.footer-settings-grid label {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  color: #475467;
  font-weight: 700;
}
.footer-preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
}
.footer-field-title {
  min-height: 24px;
  margin: 0;
  color: #475467;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 700;
}
.footer-markdown-source,
.footer-markdown-preview {
  min-height: 260px;
  height: 100%;
}
.footer-settings-panel {
  width: 100%;
  max-width: none;
  margin-top: 20px;
}
.site-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: #475467; font-size: 12px; text-transform: uppercase; }
.bugs-admin-list table { table-layout: fixed; }
.bugs-admin-list th:nth-child(1), .bugs-admin-list td:nth-child(1) { width: 180px; }
.bugs-admin-list th:nth-child(2), .bugs-admin-list td:nth-child(2) { width: 220px; }
.bugs-admin-list th:nth-child(4), .bugs-admin-list td:nth-child(4) { width: 180px; }
.bugs-admin-list th:nth-child(5), .bugs-admin-list td:nth-child(5) { width: 170px; }
.pages-admin-list table { table-layout: fixed; }
.pages-admin-list th:nth-child(2), .pages-admin-list td:nth-child(2) { width: 140px; }
.pages-admin-list th:nth-child(3), .pages-admin-list td:nth-child(3) { width: 150px; }
.pages-admin-list th:nth-child(5), .pages-admin-list td:nth-child(5) { width: 180px; }
.files-admin-panel table { table-layout: fixed; margin-top: 16px; }
.files-admin-panel th:nth-child(1), .files-admin-panel td:nth-child(1) { width: 26%; }
.files-admin-panel th:nth-child(2), .files-admin-panel td:nth-child(2) { width: 120px; }
.files-admin-panel th:nth-child(4), .files-admin-panel td:nth-child(4) { width: 180px; }
.files-admin-panel th:nth-child(5), .files-admin-panel td:nth-child(5) { width: 180px; }
.files-admin-panel input[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.messages-admin-panel { overflow-x: hidden; }
.messages-admin-panel table { width: 100%; table-layout: fixed; }
.messages-admin-panel th,
.messages-admin-panel td { overflow-wrap: anywhere; }
.messages-admin-panel th:nth-child(1), .messages-admin-panel td:nth-child(1) { width: 10%; }
.messages-admin-panel th:nth-child(2), .messages-admin-panel td:nth-child(2) { width: 11%; }
.messages-admin-panel th:nth-child(3), .messages-admin-panel td:nth-child(3) { width: 14%; }
.messages-admin-panel th:nth-child(4), .messages-admin-panel td:nth-child(4) { width: 12%; }
.messages-admin-panel th:nth-child(5), .messages-admin-panel td:nth-child(5) { width: 22%; }
.messages-admin-panel th:nth-child(6), .messages-admin-panel td:nth-child(6) { width: 23%; }
.messages-admin-panel th:nth-child(7), .messages-admin-panel td:nth-child(7) { width: 8%; }
.messages-admin-panel textarea { min-height: 110px; }
.messages-admin-panel .small-button { padding: 6px 8px; }
.sent-reply { margin-top: 12px; padding: 10px; border-left: 3px solid var(--accent); background: #f8fafc; border-radius: 0 var(--radius) var(--radius) 0; }
.site-settings-panel + .mail-config-panel,
.footer-settings-panel + .mail-config-panel { margin-top: 32px; }
.mail-config-panel { width: 100%; max-width: none; }
.mail-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 20px;
}
.mail-config-column { display: grid; gap: 14px; align-content: start; }
.mail-config-column h3 { margin: 0; font-size: 18px; }
.mail-config-grid label { display: grid; gap: 6px; color: #475467; font-weight: 700; }
.mail-from-field { grid-column: 1 / -1; }
.mail-test-panel { margin-top: 20px; width: 100%; max-width: none; }
.mail-test-panel + .mail-inbox-panel { margin-top: 24px; }
.mail-test-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.mail-inbox-panel table { table-layout: fixed; margin-top: 16px; }
.mail-inbox-panel th:nth-child(1), .mail-inbox-panel td:nth-child(1) { width: 230px; }
.mail-inbox-panel th:nth-child(2), .mail-inbox-panel td:nth-child(2) { width: 340px; }
.actions { white-space: nowrap; }
.compact-form textarea { min-height: 80px; }

@media (max-width: 900px) {
  main, .admin-main { padding: 18px; }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 14px 18px;
  }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar .main-menu {
    grid-column: 1 / -1;
    display: none;
    width: 100%;
    gap: 10px;
    padding-top: 12px;
  }
  .topbar.menu-open .main-menu { display: grid; grid-template-columns: 1fr; }
  .topbar .main-menu a,
  .topbar .main-menu summary {
    width: 100%;
    justify-content: flex-start;
    padding: 11px 12px;
  }
  .topbar .nav-dropdown {
    width: 100%;
  }
  .topbar .nav-dropdown-menu {
    position: static;
    max-width: none;
    margin-top: 6px;
    box-shadow: none;
    background: #f8fafc;
  }
  .topbar .main-menu a[href="/admin"] { margin-left: 0; }
  .content-grid, .bugs-page-grid, .contact-page-grid, .form-grid, .admin-split, .admin-body, .mail-config-grid, .mail-test-row, .profile-grid, .site-settings-grid, .footer-settings-grid { grid-template-columns: 1fr; }
  .admin-nav { position: static; height: auto; flex-direction: column; }
  .admin-nav-head { width: 100%; }
  .admin-nav .brand { margin-bottom: 0; }
  .admin-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .admin-menu { display: none; width: 100%; padding-top: 10px; }
  .admin-nav.admin-menu-open .admin-menu { display: grid; grid-template-columns: 1fr; }
  .admin-menu .logout-link { margin-top: 0; }
  .admin-nav a { text-align: center; }
  .hero, .app-hero { height: 380px; padding: 28px 20px; }
  .hero.compact, .app-hero.compact { height: 380px; }
  .hero h1, .app-hero h1 { font-size: 38px; }
  .app-hero { align-items: start; flex-direction: column; }
  .stats, .quick-actions-panel .button-row { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
}
