:root {
  --sand: #f4efe4;
  --paper: #fffdf8;
  --ink: #1f2937;
  --muted: #6b7280;
  --brand: #a24b1a;
  --brand-2: #d97706;
  --line: #e6dfd3;
  --card: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Iowan Old Style", "Baskerville", "Palatino Linotype", serif;
  background:
    radial-gradient(circle at 10% 0%, #fff8ea 0, transparent 40%),
    radial-gradient(circle at 90% 20%, #fde8cf 0, transparent 35%),
    var(--sand);
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
}

.topbar {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 16px;
  gap: 16px;
}

.brand {
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(1.35rem, 4.2vw, 1.65rem);
  letter-spacing: 0.2px;
  color: var(--brand);
}

.brand-inline {
  display: none;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.52rem;
  letter-spacing: 0.2px;
  color: var(--brand);
  white-space: nowrap;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 2px solid #f3dfc8;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  text-decoration: none;
  padding: 6px 9px;
  border-radius: 999px;
  color: #5b4a3e;
  border: 1px solid transparent;
}

.nav a:hover,
.nav a.active {
  border-color: #e9d7c2;
  background: #fff5e7;
  color: var(--brand);
}

.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 68px 20px 34px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.35rem, 6vw, 3.6rem);
  line-height: 1.05;
}

.hero p {
  margin: 14px 0 0;
  color: #5f564e;
  max-width: 760px;
  font-size: 1.08rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  border: 1px solid var(--brand);
  color: #fff;
  background: var(--brand);
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.btn.secondary {
  color: var(--brand);
  background: transparent;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 46px;
}

.section-title {
  font-size: 1.4rem;
  margin: 20px 0 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.card h3 {
  margin-top: 0;
}

.span-4 {
  grid-column: span 4;
}

.span-6 {
  grid-column: span 6;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.article-list {
  display: grid;
  gap: 12px;
}

.article-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid #e7c59f;
  border-radius: 12px;
  padding: 12px 14px;
}

.article-item h3 {
  margin: 0 0 6px;
  font-size: 1.04rem;
}

.article-item a {
  color: #14568f;
}

.split {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 16px;
}

footer {
  border-top: 1px solid var(--line);
  color: #64574e;
  text-align: center;
  padding: 18px;
  font-size: 0.92rem;
}

#mg-chat-btn {
  position: fixed;
  right: 20px;
  bottom: 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(104, 50, 20, 0.32);
}

#mg-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 510px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  display: none;
  overflow: hidden;
  border: 2px solid #d9c2a8;
}

#mg-chat-panel.open {
  display: flex;
  flex-direction: column;
}

#mg-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #eadccf;
  background: #fff8ef;
}

#mg-chat-close {
  border: 1px solid #d6c5b3;
  background: #fff;
  color: #5d4a3e;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  line-height: 1;
  cursor: pointer;
}

#mg-chat-log {
  flex: 1;
  overflow: auto;
  padding: 12px;
}

.msg {
  margin: 8px 0;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;
}

.msg.user {
  background: #fff1c8;
}

.msg.bot {
  background: #f3f4f6;
}

.msg.bot a {
  color: #1d4ed8;
  text-decoration: underline;
  word-break: break-all;
}

#mg-chat-input-row {
  display: flex;
  border-top: 1px solid #e5e7eb;
}

#mg-chat-input {
  flex: 1;
  border: 0;
  padding: 12px;
  font-size: 14px;
}

#mg-chat-send {
  border: 0;
  background: var(--brand);
  color: #fff;
  width: 46px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

#mg-chat-send:disabled {
  opacity: 0.65;
}

@media (min-width: 621px) {
  .topbar {
    padding: 12px 20px;
    gap: 0;
  }

  .brand {
    display: none;
  }

  .brand-inline {
    display: inline-block;
  }

  .header-row {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
  }

  .header-avatar {
    width: 58px;
    height: 58px;
  }

  .nav {
    margin-left: auto;
    justify-content: flex-end;
  }
}

@media (max-width: 900px) {
  .span-4,
  .span-6,
  .span-8,
  .split {
    grid-column: span 12;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 10px 14px;
    gap: 12px;
  }

  .brand {
    text-align: center;
    font-size: 1.52rem;
  }

  .header-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: center;
    gap: 10px;
  }

  .nav {
    gap: 8px;
    justify-content: flex-start;
    align-content: center;
    min-height: 90px;
  }

  .header-avatar {
    width: 86px;
    height: 86px;
  }

  .hero {
    padding: 42px 14px 22px;
  }

  main {
    padding: 0 14px 26px;
  }

  #mg-chat-btn {
    right: 14px;
    bottom: 14px;
  }

  #mg-chat-panel {
    right: 12px;
    left: 12px;
    bottom: 84px;
    width: auto;
    max-width: none;
    height: 50vh;
    border-radius: 14px;
    border: 2px solid #d2b495;
  }
}
