:root {
  --background: #edf8f7;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --ink: #17201f;
  --muted: #6b7674;
  --line: #e1e9e7;
  --teal: #2d978c;
  --teal-dark: #166b65;
  --teal-soft: #e0f3f0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

a:focus-visible {
  outline: 3px solid rgba(45, 151, 140, 0.34);
  outline-offset: 3px;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.portal-shell {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 34px 20px 24px;
  border-right: 1px solid #e6e5dc;
  background: #f4f2ec;
  color: #202823;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
}

.portal-logo {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 40px;
  overflow: hidden;
}

.portal-logo img {
  width: 48px;
  height: 40px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.portal-brand > span:last-child {
  display: grid;
  gap: 2px;
}

.portal-brand strong {
  color: #202823;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.6px;
}

.portal-brand small {
  color: #50594f;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 2px;
}

.side-menu {
  display: grid;
  gap: 6px;
  margin-top: 36px;
  padding: 0;
}

.nav-caption {
  margin: 12px 12px 8px;
  color: #50594f;
  font-size: 10px;
  letter-spacing: 1px;
}

.menu-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px 13px;
  border-radius: 10px;
  color: #202823;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.menu-item:hover {
  color: #b83840;
  background: #eeece5;
}

.menu-item.is-active {
  color: #a8323a;
  background: #f0dedb;
  font-weight: 600;
}

.menu-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
}

.menu-icon svg {
  width: 20px;
  height: 20px;
}

.menu-arrow {
  display: none;
}

.sidebar-footer {
  margin-top: auto;
  padding: 24px 12px 0;
  border-top: 1px solid #e6e5dc;
}

.sidebar-footer p {
  margin: 0 0 14px;
  color: #50594f;
  font-size: 11px;
}

.sidebar-footer a {
  color: #50594f;
  font-size: 11px;
  font-weight: 400;
}

.sidebar a:focus-visible { outline: 2px solid #b83840; outline-offset: 4px; }

.portal-main {
  min-width: 0;
  min-height: 0;
}

.workspace {
  height: 100%;
  min-height: 0;
  background: #ffffff;
}

.embed-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.embed-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.embed-toolbar[hidden] { display: none; }

.open-external {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #c5dfdb;
  border-radius: 7px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.open-external:hover {
  background: var(--teal-soft);
}

.embed-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #f4f6f7;
}

.embed-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.frame-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(247, 251, 250, 0.96);
  color: var(--muted);
  font-size: 0.88rem;
}

.embed-stage.is-loading .frame-loading {
  display: flex;
}

.frame-loading > span {
  width: 22px;
  height: 22px;
  border: 2px solid #c5dfdb;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: loading-spin 700ms linear infinite;
}

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

@media (max-width: 1100px) {
  .portal-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .sidebar {
    padding-right: 14px;
    padding-left: 14px;
  }

}

@media (max-width: 700px) {
  .portal-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px 18px 12px;
    border-right: 0;
    border-bottom: 1px solid #e6e5dc;
  }

  .portal-brand {
    min-height: 40px;
    padding: 0;
  }

  .side-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
  }

  .menu-item {
    grid-template-columns: 20px 1fr;
    min-height: 44px;
    padding: 10px 12px;
  }

  .nav-caption {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

}

@media (max-width: 420px) {
  .open-external {
    padding: 0 10px;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .frame-loading > span {
    animation: none;
  }
}
