:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  --bg: #03140d;
  --bg-deep: #020d09;
  --panel: rgba(7, 38, 25, 0.94);
  --panel-soft: rgba(9, 46, 30, 0.76);
  --line: rgba(115, 238, 156, 0.25);
  --line-strong: rgba(115, 238, 156, 0.56);
  --text: #f4fff7;
  --muted: rgba(224, 247, 232, 0.64);
  --green: #65f59a;
  --green-soft: rgba(101, 245, 154, 0.12);
  --cyan: #4bdce6;
  --yellow: #f5ce69;
  --red: #ff6b78;
  --header-height: 70px;
  --sidebar-width: 250px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

body {
  color: var(--text);
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
}

.icon-sprite {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.portal-shell {
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-width: 780px;
  min-height: 520px;
  padding: 8px;
  background:
    radial-gradient(circle at 50% -10%, rgba(70, 181, 112, 0.12), transparent 38%),
    linear-gradient(90deg, rgba(101, 245, 154, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(101, 245, 154, 0.025) 1px, transparent 1px),
    var(--bg-deep);
  background-size: auto, 36px 36px, 36px 36px, auto;
}

.portal-header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(370px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(110deg, rgba(101, 245, 154, 0.13), transparent 43%), rgba(5, 35, 23, 0.95);
  box-shadow: inset 0 0 26px rgba(101, 245, 154, 0.05), 0 12px 32px rgba(0, 13, 8, 0.3);
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.portal-header::after {
  position: absolute;
  right: 13px;
  bottom: 0;
  width: 28%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--green));
  content: "";
}

.portal-brand,
.portal-system-status,
.header-actions,
.workspace-header,
.current-page-icon,
.nav-item,
.sidebar-heading {
  display: flex;
  align-items: center;
}

.portal-brand {
  min-width: 0;
}

.brand-icon,
.current-page-icon,
.loading-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(101, 245, 154, 0.55);
  background: var(--green-soft);
  color: var(--green);
  clip-path: polygon(0 0, 78% 0, 100% 22%, 100% 100%, 22% 100%, 0 78%);
}

.brand-icon {
  width: 38px;
  height: 38px;
  margin-right: 10px;
  font-size: 21px;
}

.brand-copy {
  min-width: 0;
}

.brand-copy p,
.current-page-copy p {
  margin: 0;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-copy h1 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.05;
  white-space: nowrap;
}

.project-name {
  max-width: 190px;
  margin-left: 14px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-system-status {
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
}

.status-pill,
.mode-badge,
.page-status {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border: 1px solid rgba(101, 245, 154, 0.35);
  border-radius: 12px;
  color: var(--green);
  font-size: 10px;
}

.status-pill {
  gap: 6px;
  padding: 0 8px;
}

.status-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px rgba(101, 245, 154, 0.8);
}

#systemClock {
  color: var(--muted);
  font-size: 11px;
}

.header-actions {
  justify-content: flex-end;
  gap: 6px;
}

.action-button,
.icon-button,
.frame-error button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid rgba(101, 245, 154, 0.32);
  border-radius: 4px;
  background: rgba(3, 31, 20, 0.72);
  cursor: pointer;
}

.action-button {
  gap: 6px;
  padding: 0 10px;
  font-size: 12px;
}

.action-button svg,
.icon-button svg {
  color: var(--green);
  font-size: 16px;
}

.action-button:hover,
.icon-button:hover,
.frame-error button:hover {
  border-color: var(--green);
  background: rgba(101, 245, 154, 0.12);
}

.icon-button {
  width: 32px;
  padding: 0;
}

.mobile-only {
  display: none;
}

.portal-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 0;
  padding-top: 7px;
}

.portal-sidebar {
  display: grid;
  grid-template-rows: 45px minmax(0, 1fr) 36px;
  min-height: 0;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(101, 245, 154, 0.055), transparent 42%), rgba(3, 27, 18, 0.94);
  box-shadow: inset -16px 0 28px rgba(0, 12, 8, 0.18);
}

.sidebar-heading {
  justify-content: space-between;
  padding: 0 13px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.sidebar-heading small {
  color: rgba(101, 245, 154, 0.5);
  font-size: 9px;
  letter-spacing: 0.12em;
}

#portalNavigation {
  min-height: 0;
  padding: 9px 7px 16px;
  overflow: auto;
  scrollbar-color: rgba(101, 245, 154, 0.3) transparent;
  scrollbar-width: thin;
}

.nav-group + .nav-group {
  margin-top: 13px;
}

.nav-group h3 {
  margin: 0 7px 6px;
  color: rgba(224, 247, 232, 0.45);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.nav-item {
  position: relative;
  width: 100%;
  min-height: 54px;
  gap: 9px;
  margin: 3px 0;
  padding: 6px 8px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 2px;
  background: var(--green);
  content: "";
  opacity: 0;
}

.nav-item:hover {
  border-color: rgba(101, 245, 154, 0.2);
  background: rgba(101, 245, 154, 0.06);
}

.nav-item.is-active {
  border-color: rgba(101, 245, 154, 0.42);
  background: linear-gradient(90deg, rgba(101, 245, 154, 0.16), rgba(101, 245, 154, 0.045));
}

.nav-item.is-active::before {
  opacity: 1;
}

.nav-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(101, 245, 154, 0.24);
  color: var(--green);
  background: rgba(101, 245, 154, 0.06);
}

.nav-icon svg {
  font-size: 18px;
}

.nav-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.nav-copy b {
  font-size: 13px;
  font-weight: 650;
}

.nav-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-chevron {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: rgba(224, 247, 232, 0.3);
}

.nav-item.is-active .nav-chevron,
.nav-item.is-active .nav-icon {
  color: var(--cyan);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  color: rgba(224, 247, 232, 0.4);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.sidebar-footer b {
  color: var(--green);
  font-weight: 500;
}

.portal-workspace {
  display: grid;
  grid-template-rows: 45px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  margin-left: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(2, 22, 14, 0.54);
}

.workspace-header {
  gap: 9px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(101, 245, 154, 0.08), transparent 36%), rgba(5, 32, 21, 0.9);
}

.current-page-icon {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

.current-page-copy {
  min-width: 0;
}

.current-page-copy h2 {
  margin: 1px 0 0;
  font-size: 16px;
  line-height: 1;
}

.workspace-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.mode-badge,
.page-status {
  padding: 0 8px;
}

.mode-badge {
  border-color: rgba(245, 206, 105, 0.42);
  color: var(--yellow);
}

.mode-badge.is-production {
  border-color: rgba(101, 245, 154, 0.35);
  color: var(--green);
}

.page-status {
  border-color: rgba(75, 220, 230, 0.32);
  color: var(--cyan);
}

.frame-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 6px;
  overflow: hidden;
}

#detailFrame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #03140d;
  opacity: 0;
}

#detailFrame.is-ready {
  opacity: 1;
}

.frame-loading,
.frame-error {
  position: absolute;
  inset: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(101, 245, 154, 0.22);
  background: linear-gradient(135deg, rgba(101, 245, 154, 0.045), transparent), rgba(3, 24, 16, 0.98);
}

.frame-loading[hidden],
.frame-error[hidden] {
  display: none;
}

.loading-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  font-size: 26px;
}

.frame-loading strong,
.frame-error strong {
  font-size: 15px;
}

.frame-loading small,
.frame-error p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.frame-error > span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 107, 120, 0.52);
  color: var(--red);
  font-size: 22px;
}

.frame-error button {
  margin-top: 6px;
  padding: 0 14px;
  color: var(--green);
}

@media (max-width: 1150px) {
  :root { --sidebar-width: 218px; }
  .project-name { display: none; }
  .portal-header { grid-template-columns: minmax(320px, 1fr) auto auto; }
  .nav-copy small { display: none; }
  .nav-item { min-height: 46px; }
}

@media (max-width: 900px) {
  .portal-shell { min-width: 640px; }
  .portal-header { grid-template-columns: minmax(300px, 1fr) auto; }
  .portal-system-status { display: none; }
  .mobile-only { display: inline-flex; }
  .portal-body { grid-template-columns: minmax(0, 1fr); }
  .portal-sidebar {
    position: fixed;
    top: 78px;
    bottom: 8px;
    left: 8px;
    z-index: 20;
    width: 250px;
    transform: translateX(calc(-100% - 12px));
  }
  .portal-sidebar.is-open { transform: translateX(0); }
  .portal-workspace { margin-left: 0; }
}

@media (max-width: 700px) {
  .portal-shell { min-width: 0; padding: 5px; }
  .portal-header { grid-template-columns: minmax(0, 1fr) auto; padding: 7px 9px; }
  .brand-copy p { display: none; }
  .brand-copy h1 { font-size: 17px; }
  .brand-icon { width: 33px; height: 33px; }
  .action-button span { display: none; }
  .action-button { width: 32px; padding: 0; }
  .workspace-meta .mode-badge { display: none; }
}

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