:root {
  --navy-deep: #0D2137;
  --navy: #1A3A5C;
  --navy-soft: #2C4A6F;
  --blue: #2471A3;
  --teal: #1ABC9C;
  --teal-dark: #16A085;
  --cream: #FAF7F2;
  --cream-warm: #F4EFE5;
  --cream-dark: #E8E0D0;
  --text: #1A2333;
  --text-soft: #4A5568;
  --text-muted: #8794A8;
  --border: #DDE3EB;
  --border-soft: #ECEFF4;
  --white: #FFFFFF;
  --error: #C0392B;
  --success: #16A085;
  --shadow-sm: 0 2px 8px rgba(13, 33, 55, 0.06);
  --shadow: 0 6px 24px rgba(13, 33, 55, 0.08);
  --shadow-lg: 0 18px 50px rgba(13, 33, 55, 0.16);
  --radius: 14px;
  --radius-lg: 20px;
  --font-serif: 'Playfair Display', 'Georgia', serif;
  --font-sans: 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text);
  background: var(--cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

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

.kicker {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin-bottom: 10px;
}
.kicker-light { color: var(--teal); }

.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ============ LOGIN PAGE ============ */
#loginPage {
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, rgba(26, 188, 156, 0.10), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(36, 113, 163, 0.15), transparent 50%),
    linear-gradient(135deg, var(--navy-deep) 0%, var(--navy) 100%);
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}
#loginPage.active { display: flex; }
.login-bg-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}
.login-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.login-header {
  text-align: center;
  color: var(--white);
  margin-bottom: 8px;
}
.login-header .kicker {
  color: var(--teal);
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--cream);
  letter-spacing: 0.01em;
  margin: 4px 0;
}
.brand-subtitle {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
  font-weight: 400;
  margin-top: 6px;
}

.login-card,
.newsletter-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.05);
}
.login-card h2,
.newsletter-card h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}
.login-card .hint,
.newsletter-card p {
  color: var(--text-soft);
  font-size: 0.92rem;
  margin-bottom: 18px;
  line-height: 1.5;
}

.code-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 18px 0 22px;
}
.code-digit {
  width: 52px;
  height: 60px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--cream);
  color: var(--navy);
  outline: none;
  transition: all 0.2s ease;
}
.code-digit:focus {
  border-color: var(--teal);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(26, 188, 156, 0.18);
  transform: translateY(-1px);
}
.code-digit.filled {
  border-color: var(--navy-soft);
  background: var(--white);
}
.code-digit.error {
  border-color: var(--error);
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--navy-deep);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(13, 33, 55, 0.25);
}
.btn-secondary {
  background: var(--teal);
  color: var(--white);
}
.btn-secondary:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(22, 160, 133, 0.25);
}
.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.25);
  width: auto;
  padding: 9px 18px;
  font-size: 0.85rem;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}

.newsletter-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.newsletter-form input {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--cream);
  color: var(--navy);
  outline: none;
  transition: all 0.2s;
  width: 100%;
}
.newsletter-form input:focus {
  border-color: var(--teal);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(26, 188, 156, 0.15);
}

.form-message {
  font-size: 0.88rem;
  text-align: center;
  min-height: 1.2em;
  margin-top: 8px;
  transition: color 0.2s;
}
.form-message.error { color: var(--error); }
.form-message.success { color: var(--success); }

.login-footer {
  text-align: center;
  margin-top: 8px;
}
.login-footer p {
  color: rgba(255,255,255,0.45);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

/* ============ NAVBAR ============ */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border-soft);
  padding: 16px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  gap: 24px;
}
.nav-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.nav-brand-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.2;
}
.nav-brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-links {
  display: flex;
  gap: 4px;
}
.nav-links a {
  color: var(--text-soft);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
}
.nav-links a:hover {
  color: var(--navy);
  background: var(--cream-warm);
}
.nav-links a.active {
  color: var(--navy);
  background: var(--cream-dark);
}
.navbar .btn-ghost {
  color: var(--text-soft);
  border-color: var(--border);
}
.navbar .btn-ghost:hover {
  background: var(--cream);
  color: var(--navy);
  border-color: var(--navy-soft);
}

.btn-logout {
  background: var(--white);
  color: var(--navy);
  border: 1.5px solid var(--border);
  width: auto;
  padding: 9px 18px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
}
.btn-logout::before {
  content: '';
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231A3A5C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><polyline points='16 17 21 12 16 7'/><line x1='21' y1='12' x2='9' y2='12'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
}
.btn-logout:hover {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13, 33, 55, 0.18);
}
.btn-logout:hover::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><polyline points='16 17 21 12 16 7'/><line x1='21' y1='12' x2='9' y2='12'/></svg>");
}

/* ============ APP CONTENT ============ */
.app-main {
  padding: 48px 36px 80px;
  min-height: calc(100vh - 80px);
}
.container { max-width: 1180px; margin: 0 auto; }

.app-section { display: none; }
.app-section.active {
  display: block;
  animation: fadeIn 0.35s ease;
}

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

.app-section h1 {
  font-size: 2.4rem;
  margin-bottom: 12px;
}
.lead {
  color: var(--text-soft);
  font-size: 1.05rem;
  margin-bottom: 28px;
  max-width: 720px;
  line-height: 1.65;
}
.lead-light {
  color: rgba(255,255,255,0.82);
}

/* Welcome hero */
.welcome-hero {
  background:
    radial-gradient(circle at 90% 10%, rgba(26, 188, 156, 0.18), transparent 50%),
    linear-gradient(135deg, var(--navy-deep), var(--navy));
  border-radius: var(--radius-lg);
  padding: 64px 56px;
  color: var(--white);
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}
.welcome-hero .kicker { margin-bottom: 14px; }
.welcome-hero h1 {
  color: var(--cream);
  font-size: 2.6rem;
  max-width: 680px;
}
.welcome-hero .lead {
  margin-top: 14px;
  max-width: 700px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.info-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  transition: all 0.2s;
}
.info-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--cream-dark);
}
.info-card h3 {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--teal-dark);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.info-card p {
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 16px;
  margin: 28px 0 24px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 18px 22px;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.filter-bar select {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 36px 9px 14px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  background: var(--white);
  color: var(--navy);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='%231A3A5C'><path d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px;
  min-width: 200px;
  transition: all 0.2s;
}
.filter-bar select:focus,
.filter-bar select:hover {
  border-color: var(--teal);
}
.filter-count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-bottom: 10px;
}

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--cream-dark);
}

.card .tag {
  display: inline-block;
  background: var(--cream-warm);
  color: var(--navy);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
  align-self: flex-start;
}
.card h3 {
  font-size: 1.18rem;
  line-height: 1.35;
  margin-bottom: 10px;
}
.card .meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.card .meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}
.card .description {
  color: var(--text-soft);
  font-size: 0.93rem;
  line-height: 1.55;
  margin-bottom: 20px;
  flex-grow: 1;
}
.card .card-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
}
.card-actions .btn {
  background: var(--navy);
  color: var(--white);
  padding: 10px 18px;
  font-size: 0.88rem;
  width: auto;
}
.card-actions .btn:hover {
  background: var(--navy-deep);
}

/* Image cards */
.image-card {
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}
.image-card .image-area {
  width: 100%;
  height: 240px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-soft);
  overflow: hidden;
  background: var(--navy-deep);
}
.image-card .image-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.image-card:hover .image-area img {
  transform: scale(1.04);
}
.image-card .image-content {
  padding: 22px 24px 24px;
}
.image-card .image-content .tag {
  margin-bottom: 12px;
}
.image-card h3 {
  font-size: 1.08rem;
  margin-bottom: 6px;
}
.image-card .body-part {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.image-card .desc {
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.55;
  margin-bottom: 14px;
}
.image-card .source {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  font-style: italic;
}

.modal-image {
  margin: 0 -8px 20px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--navy-deep);
}
.modal-image img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  display: block;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 33, 55, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  max-width: 600px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s;
}
.modal-close:hover {
  background: var(--cream);
  color: var(--navy);
}
.modal h2 {
  font-size: 1.6rem;
  margin-bottom: 6px;
  padding-right: 40px;
}
.modal .modal-tag {
  display: inline-block;
  background: var(--cream-warm);
  color: var(--navy);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.modal .modal-meta {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.modal .modal-desc {
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.65;
  margin-bottom: 24px;
}
.modal .modal-note {
  background: var(--cream-warm);
  border-left: 3px solid var(--teal);
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.55;
}

/* Footer */
.app-footer {
  background: var(--white);
  border-top: 1px solid var(--border-soft);
  padding: 24px 36px;
  text-align: center;
}
.app-footer p {
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

/* Responsive */
@media (max-width: 900px) {
  .navbar {
    padding: 14px 20px;
    flex-wrap: wrap;
  }
  .nav-brand-title { font-size: 1.05rem; }
  .app-main { padding: 32px 20px 60px; }
  .welcome-hero { padding: 44px 28px; }
  .welcome-hero h1 { font-size: 2rem; }
  .app-section h1 { font-size: 1.9rem; }
  .filter-count { width: 100%; margin-left: 0; padding-bottom: 0; }
}

@media (max-width: 600px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .nav-links { width: 100%; overflow-x: auto; }
  .nav-links a { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }
  .login-card, .newsletter-card { padding: 24px 22px; }
  .brand-name { font-size: 1.9rem; }
  .code-digit { width: 42px; height: 52px; font-size: 1.35rem; }
  .code-inputs { gap: 6px; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar select { min-width: 100%; }
  .filter-group { width: 100%; }
}
