:root {
  --blue: #1a3a5c;
  --blue-light: #2d5f8a;
  --gold: #d4a843;
  --white: #ffffff;
  --bg: #f4f6f8;
  --text: #1a1a2e;
  --text-muted: #666;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

/* Header */
.app-header {
  background: var(--blue);
  color: var(--white);
  padding: env(safe-area-inset-top) 0 0 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}

.header-inner {
  padding: 18px 20px 16px;
}

.site-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-subtitle {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.4px;
  text-transform: lowercase;
}

/* Main content area */
.app-content {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
  max-width: 600px;
  margin: 0 auto;
}

.tab-content {
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tab-content.active {
  display: block;
  opacity: 1;
}

/* Cards */
.post-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.post-card .post-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  margin-bottom: 12px;
}

.post-card .category-badge {
  display: inline-block;
  background: var(--gold);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}

.post-card .post-title {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.post-card .post-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.post-card .post-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.post-card .post-body.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card .read-more {
  background: none;
  border: none;
  color: var(--blue-light);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 0 0;
  cursor: pointer;
  display: inline-block;
}

.post-card .read-more:active {
  opacity: 0.6;
}

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gallery-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  position: relative;
  cursor: pointer;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-card .placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

.gallery-card .placeholder svg {
  width: 36px;
  height: 36px;
  opacity: 0.85;
}

.gallery-card .caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
  color: var(--white);
  font-size: 12px;
  font-weight: 500;
}

/* Loader */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(212, 168, 67, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty + error states */
.empty-state, .error-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon, .error-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state .text, .error-state .text {
  font-size: 14px;
}

.error-state .text {
  color: #b14545;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  border-top: 1px solid #eee;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

.nav-item {
  background: none;
  border: none;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: color 0.15s ease;
  min-height: var(--nav-height);
}

.nav-item .nav-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.15s ease;
}

.nav-item .nav-label {
  font-size: 11px;
  font-weight: 500;
}

.nav-item.active {
  color: var(--gold);
}

.nav-item.active .nav-icon {
  transform: scale(1.08);
}

.nav-item:active {
  opacity: 0.7;
}

/* Slight tuning for narrow screens */
@media (max-width: 360px) {
  .nav-item .nav-label { font-size: 10px; }
  .site-title { font-size: 20px; }
  .header-inner { padding: 16px 16px 14px; }
}
