:root {
  --color-primary: #176b4b;
  --color-primary-hover: #0f593d;
  --color-primary-soft: #e9f5ee;
  --color-bg: #f6f7f3;
  --color-surface: #ffffff;
  --color-surface-muted: #eff3ee;
  --color-text: #182820;
  --color-text-muted: #62746b;
  --color-border: #dbe3dc;
  --color-danger: #b63d36;
  --color-warning: #8a5b0a;
  --color-success: #176b4b;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(20, 42, 31, .07), 0 2px 8px rgba(20, 42, 31, .04);
  --shadow-md: 0 12px 28px rgba(20, 42, 31, .10);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --sidebar-width: 272px;
  --topbar-height: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--color-bg); scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font: 400 16px/1.55 var(--font-body);
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--color-primary); text-underline-offset: 3px; }
a:hover { color: var(--color-primary-hover); }
h1, h2, h3, h4 { color: var(--color-text); font-family: var(--font-display); line-height: 1.18; }
h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.45rem, 2.4vw, 2rem); }
h3 { font-size: 1.125rem; }
p { max-width: 75ch; }

button, input, select, textarea { font: inherit; }
button, [role="button"] { min-height: 44px; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #f0b44d; outline-offset: 3px; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: inset 0 1px 1px rgba(20, 42, 31, .03);
}
textarea { min-height: 116px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #77877f; opacity: 1; }
label { gap: var(--space-2); color: #345448; font-weight: 700; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(23, 107, 75, .18); }

.button, .primary, .submit, button.primary, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 10px 16px;
  color: #fff;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
}
.button:hover, .primary:hover, .submit:hover, button.primary:hover, button[type="submit"]:hover { color: #fff; border-color: var(--color-primary-hover); background: var(--color-primary-hover); }
.secondary, .outline, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 10px 16px;
  color: var(--color-primary);
  border: 1px solid #b9d3c3;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
}
.secondary:hover, .outline:hover, .ghost:hover { background: var(--color-primary-soft); }
.danger, button.danger { color: #fff; border-color: var(--color-danger); background: var(--color-danger); }
.icon-button, .shell-icon-button { display: inline-grid; width: 44px; min-width: 44px; min-height: 44px; place-items: center; padding: 0; color: var(--color-text); border: 0; border-radius: 50%; background: transparent; }
.icon-button:hover, .shell-icon-button:hover { background: var(--color-surface-muted); }

.card, .account, .market > *, .village-page > *, .messages, .profile-activity, .follow-list {
  border-color: var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card { background: var(--color-surface); }
.card:hover { box-shadow: var(--shadow-md); }
.category, .role, .badge, .chip, .pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.15;
}
.pill { min-height: 40px; border: 0; background: transparent; }
.pill.selected, .pill:hover { background: var(--color-surface); color: var(--color-primary-hover); box-shadow: var(--shadow-sm); }
.filter-row { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
.empty-state, [data-empty-state] { display: grid; min-height: 180px; place-items: center; padding: var(--space-8); color: var(--color-text-muted); border: 1px dashed #b9cbc0; border-radius: var(--radius-lg); background: var(--color-surface-muted); text-align: center; }

/* Shared desktop shell. It is injected only where a page has no legacy shell. */
body.has-app-shell { display: block !important; min-height: 100vh; padding: 0 !important; background: var(--color-bg) !important; }
.site-sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: var(--space-5) var(--space-3) var(--space-4);
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  background: rgba(255, 255, 255, .97);
}
.site-brand, .brand {
  display: flex;
  min-height: 52px;
  height: auto;
  align-items: center;
  gap: var(--space-3);
  margin: 0 var(--space-2) var(--space-6);
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: -.02em;
  text-decoration: none;
}
.sidebar .brand { font-size: 1rem; line-height: 1.15; }
.sidebar .brand > span:last-child { display: block; overflow: visible; font-size: 1rem; line-height: 1.15; }
.site-brand-mark, .brand-mark { display: inline-grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: var(--color-primary); color: #fff; font-family: var(--font-display); font-size: 1.25rem; }
.site-nav, .sidebar .nav { display: grid; gap: 4px; }
.site-nav a, .sidebar .nav a {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  color: #3b5d50;
  border-radius: var(--radius-sm);
  font-size: .96rem;
  font-weight: 650;
  text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"], .sidebar .nav a:hover, .sidebar .nav a.active { color: #fff; background: var(--color-primary); }
.shell-nav-icon, .sidebar .nav i { display: inline-grid; width: 22px; min-width: 22px; place-items: center; color: currentColor; font-style: normal; font-size: 1rem; }
.site-nav-label, .sidebar .nav-label { margin: var(--space-6) var(--space-2) var(--space-2); color: #71857a; font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.site-sidebar-footer, .sidebar .side-footer { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin-top: auto; padding: var(--space-5) var(--space-2) 0; border-top: 1px solid var(--color-border); }
.site-sidebar-footer a, .sidebar .side-footer a { color: var(--color-text-muted); font-size: .78rem; text-decoration: none; }

.site-topbar, .topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 12px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}
.site-topbar .search, .topbar .search { display: flex; width: min(460px, 52vw); min-height: 44px; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--color-surface-muted); }
.site-topbar .search:focus-within, .topbar .search:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(23, 107, 75, .16); }
.site-topbar .search input, .topbar .search input { min-height: 40px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.site-top-actions, .top-actions { display: flex; align-items: center; gap: var(--space-2); }
.site-profile-link, .profile-trigger { display: inline-flex; min-height: 44px; align-items: center; gap: var(--space-2); padding: 4px 8px 4px 4px; color: var(--color-text); border-radius: 999px; font-weight: 750; text-decoration: none; }
.site-profile-link:hover, .profile-trigger:hover { background: var(--color-surface-muted); }
.avatar { width: 36px; height: 36px; flex: 0 0 auto; background: var(--color-primary); }
.has-app-shell .app-main { min-height: 100vh; margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + var(--space-8)) clamp(var(--space-4), 4vw, 64px) 80px; }
.has-app-shell .app-main > * { width: min(100%, 1160px); margin-right: auto; margin-left: auto; }
.has-app-shell .account { margin-top: var(--space-6); margin-bottom: var(--space-6); }
.has-legacy-shell main { margin-left: var(--sidebar-width); padding-top: var(--topbar-height); }
.has-legacy-shell .topbar { left: var(--sidebar-width); }
.has-legacy-shell .content, .has-legacy-shell .home-content { width: min(100%, 1240px); margin-inline: auto; padding: clamp(24px, 4vw, 48px); }

.mobile-bottom-nav, .mobile-more-panel { display: none; }

/* The administration surface shares tokens while retaining its separate information architecture. */
body.design-admin-page { background: var(--color-bg); color: var(--color-text); }
body.design-admin-page main { color: var(--color-text); }

@media (max-width: 900px) {
  :root { --topbar-height: 64px; }
  .site-sidebar, .has-legacy-shell .sidebar { display: none; }
  .site-topbar, .topbar, .has-legacy-shell .topbar { left: 0; padding-inline: var(--space-3); }
  .site-topbar .search, .topbar .search { width: auto; flex: 1; }
  .site-profile-name, .topbar .profile-trigger > span:last-child { display: none; }
  .has-app-shell .app-main, .has-legacy-shell main { margin-left: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .has-legacy-shell .content, .has-legacy-shell .home-content { padding: var(--space-5) var(--space-4) calc(88px + env(safe-area-inset-bottom)); }
  .mobile-bottom-nav {
    position: fixed;
    z-index: 60;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--color-border);
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -6px 18px rgba(20, 42, 31, .08);
  }
  .mobile-bottom-nav a, .mobile-bottom-nav button { display: grid; min-width: 0; min-height: 60px; place-items: center; align-content: center; gap: 2px; padding: 5px 2px; color: var(--color-text-muted); border: 0; background: transparent; font-size: .68rem; font-weight: 750; text-decoration: none; }
  .mobile-bottom-nav .nav-icon { font-size: 1.2rem; line-height: 1; }
  .mobile-bottom-nav a[aria-current="page"], .mobile-bottom-nav button[aria-expanded="true"] { color: var(--color-primary); }
  .mobile-more-panel { position: fixed; z-index: 59; right: var(--space-3); bottom: calc(72px + env(safe-area-inset-bottom)); left: var(--space-3); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-md); }
  .mobile-more-panel.open { display: grid; gap: var(--space-1); }
  .mobile-more-panel a { display: flex; min-height: 44px; align-items: center; padding: 10px 12px; color: var(--color-text); border-radius: var(--radius-sm); font-weight: 700; text-decoration: none; }
  .mobile-more-panel a:hover { background: var(--color-primary-soft); }
  .cards, .home-cards { grid-template-columns: 1fr !important; }
  .messages { min-height: calc(100vh - 160px); }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .has-app-shell .app-main { padding-inline: clamp(var(--space-5), 3vw, var(--space-8)); }
  .has-legacy-shell .content, .has-legacy-shell .home-content { padding-inline: clamp(var(--space-5), 3vw, var(--space-8)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Shared long-form reading surface, used by public news articles. */
.article { width: min(100%, 760px); margin: 0 auto; padding: 0; }
.article .back { display: inline-flex; min-height: 44px; align-items: center; color: var(--color-primary); font-weight: 800; text-decoration: none; }
.article .category { margin-top: var(--space-4); }
.article h1 { max-width: 19ch; margin: var(--space-3) 0; font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -.025em; }
.article .lead { margin: 0; color: #435f53; font-size: clamp(1.08rem, 2vw, 1.28rem); line-height: 1.7; }
.article-image { display: block; width: 100%; max-height: 480px; margin: var(--space-6) 0; border-radius: var(--radius-lg); object-fit: cover; }
.article-image.article-image-fallback { display: grid; min-height: 260px; place-items: center; background: linear-gradient(135deg, #dceee3, #f0f6f1); color: var(--color-primary-hover); font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.article .byline { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-4) 0; color: var(--color-text-muted); border-block: 1px solid var(--color-border); font-size: .9rem; }
.article .byline a { color: var(--color-primary); font-weight: 800; text-decoration: none; }
.article-content { max-width: 68ch; margin-top: var(--space-6); color: #273c32; font-size: clamp(1.05rem, 1.8vw, 1.18rem); line-height: 1.85; }
.article-content p { margin: 0 0 1.35em; }.article-content a { font-weight: 700; }.article-content img { max-width: 100%; height: auto; }
.social { margin-top: var(--space-10); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }.like-area { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }.like-button, .comment-submit { min-height: 44px; padding: 10px 16px; border: 1px solid var(--color-primary); border-radius: var(--radius-sm); background: var(--color-primary); box-shadow: var(--shadow-sm); font-weight: 800; }.like-button.liked { color: var(--color-primary-hover); border-color: #b9d3c3; background: var(--color-primary-soft); }.comments-heading { margin: var(--space-8) 0 var(--space-4); }.comments-list { gap: var(--space-3); }.comment { padding: var(--space-4); border-color: var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }.comment-meta { color: var(--color-text-muted); }.comment-content { font-size: 1rem; line-height: 1.65; }.comment-form textarea { min-height: 132px; }.comment-submit { justify-self: start; }
@media (max-width: 620px) { .article { width: 100%; }.article h1 { max-width: none; }.article-image { margin-inline: 0; }.article-content { line-height: 1.78; }.comment-meta { align-items: flex-start; flex-direction: column; gap: var(--space-1); }.comment-submit { width: 100%; } }
