.tool-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 1rem !important;
}

/* Header brand */
header.site-header .container {
  width: calc(100% - 24px);
  max-width: none;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 0;
}
header.site-header .brand {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
  flex: 0 0 auto;
  position: relative;
  left: 0;
  cursor: pointer;
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Noto Sans KR", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}
header.site-header .brand-logo {
  display: block;
  width: 162px;
  height: auto;
  flex: 0 0 162px;
  max-width: none;
  object-fit: contain;
}
header.site-header .brand span {
  display: block;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  line-height: 1;
}
header.site-header nav {
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.72rem;
  white-space: nowrap;
  margin-left: 5cm;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.2rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.language-switch a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}
.language-switch a.active,
.language-switch a:hover {
  color: var(--accent);
  font-weight: 700;
}
.language-switch .sep { color: var(--border); }

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-row p {
  margin: 0;
  color: var(--muted);
  font-weight: 400;
}
.footer-row a { font-weight: 400; }
.footer-home {
  white-space: nowrap;
  color: var(--accent) !important;
  font-weight: 400 !important;
}
.footer-home a {
  color: var(--accent) !important;
  font-weight: 400 !important;
}

/* Keep the official green/black CNU logo legible on dark system themes. */
@media (prefers-color-scheme: dark) {
  header.site-header .brand-logo {
    background: #fff;
    padding: 3px 5px;
    border-radius: 3px;
    box-sizing: content-box;
  }
}

/* Desktop header: use the available width as three visual zones.
   Brand stays at the left, language switch stays at the right, and only
   the five tool links receive the wider inter-item spacing. */
@media (min-width: 901px) {
  header.site-header .container {
    display: flex;
    align-items: center;
  }
  header.site-header nav {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 0;
    margin-left: 2rem;
  }
  header.site-header nav > a + a {
    margin-left: 2rem;
  }
  header.site-header nav > .language-switch {
    margin-left: auto;
  }
}

@media (max-width: 900px) {
  header.site-header .container { align-items: center; }
  header.site-header nav {
    gap: 0.55rem;
    font-size: 0.9rem;
    margin-left: 5cm;
  }
}

@media (max-width: 640px) {
  .tool-grid { grid-template-columns: 1fr !important; }
  header.site-header .container {
    width: 92%;
    max-width: 880px;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  header.site-header .brand { left: 0; }
  header.site-header .brand-logo {
    width: 148px;
    flex-basis: 148px;
  }
  header.site-header nav {
    flex-wrap: wrap;
    white-space: normal;
    margin-left: 0;
  }
  .language-switch {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
  .footer-row { align-items: flex-start; }
}
