.site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--header-height);
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 1px;
  background: var(--color-bg);
}

.header__brand {
  grid-column: span 12;
  display: flex;
  align-items: center;
  padding: 0.6rem 0.75rem 0;
  font-size: var(--text-h1);
  outline: var(--border-width) solid var(--color-fg);
}

.header__brand h1:first-child {
  flex: 1;
}

.header__actions {
  grid-column: span 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  outline: var(--border-width) solid var(--color-fg);
  padding-right: 0.5rem;
}

.header__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  color: var(--color-fg);
}

.header__icon-btn:hover {
  background: var(--color-accent-bg);
  color: var(--color-accent-fg);
}

.panel-toggle {
  display: none;
  text-transform: none;
  font-size: 0.95rem;
  letter-spacing: -0.08em;
  line-height: 1;
}

.panel-toggle__icon--expand {
  display: none;
}

.site[data-right-panel="collapsed"] .panel-toggle__icon--collapse {
  display: none;
}

.site[data-right-panel="collapsed"] .panel-toggle__icon--expand {
  display: block;
}

.theme-toggle {
  position: relative;
  overflow: hidden;
}

.theme-toggle__icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition:
    opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle__icon svg {
  width: 1.2em;
  height: 1.2em;
}

.theme-toggle__icon--moon svg {
  width: 1.22em;
  height: 1.22em;
}

.theme-toggle__icon--sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-toggle__icon--moon {
  opacity: 0;
  transform: rotate(-60deg) scale(0.4);
}

[data-theme="dark"] .theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(60deg) scale(0.4);
}

[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

@media (min-width: 768px) {
  .header__brand {
    grid-column: span 9;
    padding-top: 0.25rem;
  }

  .header__actions {
    grid-column: span 9;
    padding-right: 0.75rem;
  }

  .panel-toggle {
    display: flex;
  }

  .main {
    grid-template-columns: 1fr 1fr;
  }

  .site[data-right-panel="collapsed"] .main {
    grid-template-columns: 1fr;
  }

  .site[data-right-panel="collapsed"] .panel-right {
    display: none;
  }
}

/* Main grid */
.main {
  position: absolute;
  inset: var(--header-height) 0 var(--footer-height);
  display: grid;
  gap: 1px;
  outline: var(--border-width) solid var(--color-fg);
}

.panel-left,
.panel-right {
  position: relative;
  height: 100%;
  width: 100%;
  outline: var(--border-width) solid var(--color-fg);
  background: var(--color-bg);
}

.panel-right {
  overflow-y: auto;
  padding-top: 3rem;
}

@media (min-width: 768px) {
  .panel-right {
    padding-top: 0;
  }
}

@media (max-width: 767px) {
  html,
  body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .site {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .header {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: var(--header-height) var(--tab-height);
    height: var(--mobile-top-height);
  }

  .site--simple .header {
    grid-template-rows: var(--header-height);
    height: var(--header-height);
  }

  .header__brand {
    grid-column: 1 / span 4;
    grid-row: 1;
    justify-content: flex-start;
    padding: 0.6rem 0.75rem 0;
  }

  .header__brand h1:first-child {
    flex: 1;
  }

  .header__actions {
    grid-column: 5 / span 2;
    grid-row: 1;
    justify-content: center;
    padding-right: 0;
  }

  .main {
    inset: var(--mobile-top-height) 0 var(--footer-height);
    outline: none;
  }

  .panel-right {
    padding-top: 0;
    outline: none;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .site[data-mobile-view="home"] .panel-left {
    height: 0;
    min-height: 0;
    overflow: visible;
    outline: none;
  }

  .site[data-mobile-view="tab"] .panel-right {
    display: none;
  }

  .site[data-mobile-view="tab"] .panel-left {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    outline: none;
  }
}

/* Footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1px;
  height: var(--footer-height);
  background: var(--color-bg);
  color: var(--color-fg);
}

.footer__left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  outline: var(--border-width) solid var(--color-fg);
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  min-width: max-content;
}

.footer__meta,
.footer__info h4 {
  margin: 0;
  white-space: nowrap;
}

.footer__info {
  flex: 0 0 auto;
  padding: 0 0.25rem;
}

.footer__info:hover,
.footer__info.is-active {
  background: var(--color-accent-bg);
  color: var(--color-accent-fg);
}

.footer__social {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  outline: var(--border-width) solid var(--color-fg);
}

.footer__email {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

.footer__email h4 {
  margin: 0;
}

.footer__social-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  flex: 1 1 auto;
}

.footer__social-link {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 0.5rem;
}

.footer__social-link:last-child {
  padding-right: 0.75rem;
}

@media (max-width: 767px) {
  .footer {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: var(--footer-height);
  }

  .footer__social {
    order: -1;
    min-height: var(--footer-row-height);
  }

  .footer__left {
    order: 0;
    min-width: 0;
    min-height: var(--footer-row-height);
    align-items: center;
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  .footer__meta {
    white-space: normal;
    line-height: 1.3;
    flex: 1 1 auto;
    min-width: 0;
  }

  .footer__social-link {
    padding: 0.5rem 0.4rem;
  }

  .footer__email {
    padding: 0.5rem 0.75rem;
  }
}

@media (min-width: 769px) {
  .footer {
    grid-template-columns: 1fr 1fr;
  }

  .footer__left {
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    min-width: 0;
  }

  .footer__social-link {
    padding: 0.5rem 0.75rem;
  }
}
