:root {
  --bg: #f5f7f5;
  --surface: #ffffff;
  --surface-soft: #f0f4f1;
  --line: #dce7e1;
  --line-strong: #c6d6cd;
  --ink: #21332c;
  --ink-soft: #496159;
  --muted: #71877e;
  --accent: #1d6b53;
  --accent-dark: #14503e;
  --accent-soft: #e0efe7;
  --signal: #d96044;
  --signal-soft: #fbe7e1;
  --gold: #c89535;
  --radius: 8px;
  --shadow: 0 1px 0 rgba(27, 53, 44, 0.03), 0 12px 30px rgba(32, 62, 52, 0.06);
  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(29, 107, 83, 0.28);
  outline-offset: 2px;
}

a {
  color: inherit;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 max(20px, calc((100vw - 1120px) / 2));
  background: rgba(247, 249, 247, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.brand-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--accent);
  border-radius: var(--radius);
}

.brand-symbol svg {
  width: 19px;
  height: 19px;
}

.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44vw;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #edf2ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.nav-tab {
  min-height: 32px;
  padding: 3px 14px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.nav-tab:hover {
  color: var(--ink);
}

.nav-tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(30, 59, 49, 0.12);
}

.icon-button,
.round-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-decoration: none;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.icon-button:hover,
.round-link:hover {
  color: var(--accent-dark);
  border-color: var(--accent);
}

.icon-button svg,
.round-link svg {
  width: 18px;
  height: 18px;
}

.icon-button.quiet,
.round-link.quiet {
  background: transparent;
  border-color: transparent;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

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

.button.primary:hover {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button.danger {
  color: #a23d2b;
  border-color: #efc7be;
  background: #fff8f6;
}

.button.danger:hover {
  color: #ffffff;
  background: var(--signal);
  border-color: var(--signal);
}

.button svg {
  width: 17px;
  height: 17px;
}

.button.full {
  width: 100%;
}

.button.icon-only {
  width: 40px;
  padding: 0;
}

main {
  display: block;
}

.site-cover {
  padding: 54px max(22px, calc((100vw - 1120px) / 2)) 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.cover-copy {
  max-width: 860px;
}

.cover-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--signal);
}

.cover-copy h1,
.admin-head h1,
.login-heading h1 {
  margin: 12px 0 0;
  font-size: 52px;
  line-height: 1.12;
  letter-spacing: 0;
}

.cover-tagline {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 17px;
}

.cover-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.cover-stats b {
  color: var(--accent-dark);
  font-weight: 750;
}

.content-wrap {
  width: min(900px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 72px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

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

.feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.article-card {
  padding: 24px 26px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.article-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.article-title {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.35;
  font-weight: 720;
}

.article-sub {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.article-sub time {
  font-family: var(--mono);
  font-size: 12px;
}

.article-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.article-actions .icon-button {
  width: 34px;
  height: 34px;
}

.article-body {
  margin: 18px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #2b4038;
  font-size: 16px;
}

.media-strip {
  margin-top: 20px;
}

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

.media-grid.single {
  grid-template-columns: minmax(0, min(620px, 100%));
}

.media-tile,
.media-tile img {
  width: 100%;
}

.media-tile {
  overflow: hidden;
  padding: 0;
  background: #e6eee9;
  border: 0;
  border-radius: 6px;
}

.media-tile img {
  height: 100%;
  min-height: 210px;
  max-height: 560px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 240ms ease;
}

.media-grid.single .media-tile img {
  aspect-ratio: 16 / 10;
}

.media-tile:hover img {
  transform: scale(1.012);
}

.file-list {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
}

.file-row:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-row svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--accent);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.file-size {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

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

.gallery-photo {
  overflow: hidden;
  padding: 0;
  background: #e2ebe5;
  border: 0;
  border-radius: var(--radius);
}

.gallery-photo img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 220ms ease, filter 220ms ease;
}

.gallery-photo:hover img {
  transform: scale(1.02);
  filter: saturate(1.05);
}

.gallery-list {
  display: grid;
  gap: 8px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.empty-state svg {
  width: 38px;
  height: 38px;
  color: var(--accent);
}

.empty-state p {
  max-width: 320px;
  margin: 14px 0 0;
  font-size: 15px;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(900px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 38px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.footer-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
}

.footer-admin:hover {
  color: var(--accent);
}

.footer-admin svg {
  width: 15px;
  height: 15px;
}

/* Admin */
.admin-layout {
  min-height: 100vh;
}

.admin-head {
  padding: 42px max(22px, calc((100vw - 1120px) / 2)) 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.admin-head-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.admin-head h1 {
  margin-top: 6px;
  font-size: 34px;
}

.admin-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.admin-stats {
  display: flex;
  gap: 9px;
  flex: 0 0 auto;
}

.stat-chip {
  padding: 7px 11px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.stat-chip b {
  color: var(--accent-dark);
}

.admin-content {
  padding-top: 26px;
}

.article-card.is-admin {
  border-color: #d5e2da;
}

.draft-mark {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  color: var(--signal);
  background: var(--signal-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

/* Login */
.login-page {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(33, 77, 63, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(33, 77, 63, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
}

.login-top {
  padding: 18px max(20px, calc((100vw - 1120px) / 2));
}

.login-wrap {
  display: grid;
  place-items: center;
  padding: 34px 20px 80px;
}

.login-panel {
  width: min(410px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-heading svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.login-heading h1 {
  margin: 0;
  font-size: 24px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: #fbfdfc;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  transition: border-color 140ms ease, background 140ms ease;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.7;
}

.field input:focus,
.field textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.form-error {
  margin: -2px 0 12px;
  color: #b2462e;
  font-size: 13px;
  font-weight: 600;
}

.form-success {
  margin: -2px 0 12px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 600;
}

/* Dialogs */
dialog {
  color: var(--ink);
  border: 0;
}

dialog::backdrop {
  background: rgba(18, 37, 31, 0.46);
  backdrop-filter: blur(3px);
}

.dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(13, 39, 30, 0.28);
}

.dialog-small {
  width: min(430px, calc(100vw - 28px));
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-body {
  padding: 20px;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.dialog-close {
  margin-left: auto;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 10px;
}

.attachment-list {
  display: grid;
  gap: 8px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 7px 10px 7px 7px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.attachment-thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  overflow: hidden;
  background: #e2ebe5;
  border-radius: 5px;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumb svg {
  width: 22px;
  height: 22px;
  margin: 11px;
  color: var(--accent);
}

.attachment-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
}

.attachment-note {
  color: var(--muted);
  font-size: 12px;
}

.remove-attachment {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.remove-attachment:hover {
  color: #b2462e;
  background: var(--signal-soft);
}

.remove-attachment svg {
  width: 16px;
  height: 16px;
}

.dialog-error {
  margin: 10px 0 0;
  color: #b2462e;
  font-size: 13px;
  font-weight: 650;
}

.confirm-text {
  padding: 22px 20px 6px;
}

.confirm-text p {
  margin: 0;
  line-height: 1.7;
}

/* Lightbox */
.lightbox-dialog {
  width: min(1120px, calc(100vw - 24px));
  max-width: none;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.lightbox-stage {
  position: relative;
  display: flex;
  flex-direction: column;
}

.lightbox-stage img {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 112px);
  margin: 0 auto;
  object-fit: contain;
  border-radius: var(--radius);
  background: #101b17;
}

.lightbox-caption {
  align-self: center;
  margin: 10px 0 0;
  padding: 4px 12px;
  color: #fff;
  background: rgba(15, 31, 26, 0.78);
  border-radius: 999px;
  font-size: 13px;
}

.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  color: #ffffff;
  background: #213a31;
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(17, 38, 30, 0.24);
  font-size: 14px;
  font-weight: 600;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  background: #a9402b;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.is-busy {
  opacity: 0.66;
  pointer-events: none;
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 8px 14px 6px;
  }

  .brand-text {
    max-width: 34vw;
  }

  .topbar-nav {
    order: 3;
    width: 100%;
    gap: 2px;
    padding: 3px;
    justify-content: center;
    overflow-x: auto;
  }

  .topbar-actions {
    order: 2;
    margin-left: auto;
    gap: 6px;
  }

  .nav-tab {
    min-height: 30px;
    padding: 2px 10px;
    font-size: 13px;
  }

  .topbar-actions .button span {
    display: none;
  }

  .topbar-actions .button {
    width: 40px;
    padding: 0;
  }

  .site-cover {
    padding: 38px 18px 28px;
  }

  .cover-copy h1 {
    font-size: 38px;
  }

  .cover-tagline {
    font-size: 15px;
  }

  .content-wrap {
    width: min(100% - 24px, 900px);
    padding-top: 22px;
  }

  .article-card {
    padding: 19px 16px;
  }

  .article-title {
    font-size: 19px;
  }

  .media-grid {
    grid-template-columns: 1fr;
  }

  .media-grid.single {
    grid-template-columns: 1fr;
  }

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

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

  .login-panel {
    padding: 24px 20px;
  }
}

@media (max-width: 420px) {
  .brand-symbol {
    width: 31px;
    height: 31px;
  }

  .brand {
    font-size: 15px;
  }

  .nav-tab {
    padding: 2px 7px;
  }

  .article-sub,
  .file-size {
    font-size: 11px;
  }
}
