:root {
  color: #172033;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  font-synthesis: none;
  --brand: #c9242e;
  --brand-deep: #a91520;
  --sidebar: #172033;
  --sidebar-soft: #202c42;
  --sidebar-width: 136px;
  --line: #e6eaf0;
  --muted: #667085;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f4f6f9;
}

button {
  font: inherit;
}

.system-shell {
  display: block;
  width: 100%;
  height: 100%;
}

.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  min-width: 0;
  flex-direction: column;
  color: #fff;
  background:
    radial-gradient(circle at 0 0, rgba(201, 36, 46, 0.22), transparent 34%),
    linear-gradient(180deg, #192338 0%, #121a2a 100%);
  box-shadow: 8px 0 28px rgba(16, 24, 40, 0.2);
  transform: none;
}

.sidebar.is-open {
  transform: translateX(0);
}

.sidebar-reveal-zone {
  display: none;
}

.sidebar-reveal-zone::after {
  position: absolute;
  top: 50%;
  left: 0;
  width: 3px;
  height: 64px;
  border-radius: 0 4px 4px 0;
  background: rgba(201, 36, 46, 0.14);
  content: "";
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 160ms ease;
}

.sidebar-reveal-zone:hover::after {
  opacity: 1;
}

.brand {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 5px;
  padding: 9px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-logo {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  color: #aeb8ca;
  font-size: 8px;
}

.nav-heading {
  padding: 12px 9px 6px;
  color: #8794aa;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.tool-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 5px;
}

.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 5px;
  padding: 7px 5px;
  border: 0;
  border-radius: 8px;
  color: #c8d0dd;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  box-shadow: 0 8px 20px rgba(169, 21, 32, 0.3);
}

.nav-item.is-active::before {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: -5px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: #fff;
  content: "";
}

.nav-icon {
  display: grid;
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.is-active .nav-icon {
  background: rgba(255, 255, 255, 0.15);
}

.nav-icon svg,
.menu-button svg,
.open-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.nav-copy strong {
  font-size: 10px;
  font-weight: 700;
}

.nav-copy small {
  overflow: hidden;
  color: currentColor;
  font-size: 8px;
  opacity: 0.68;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #9ba8bb;
  font-size: 8px;
}

.sidebar-footer p {
  margin: 6px 0 0 13px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #d5dae3;
  font-size: 9px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #f2b84b;
  box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.12);
}

.system-status.is-ready .status-dot {
  background: #35c48d;
  box-shadow: 0 0 0 4px rgba(53, 196, 141, 0.12);
}

.system-status.is-error .status-dot {
  background: #f97066;
  box-shadow: 0 0 0 4px rgba(249, 112, 102, 0.12);
}

.workspace {
  display: grid;
  width: calc(100% - var(--sidebar-width));
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 68px minmax(0, 1fr);
  margin-left: var(--sidebar-width);
}

.workspace-header {
  position: relative;
  z-index: 5;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.04);
}

.workspace-title {
  min-width: 0;
}

.workspace-title h1 {
  margin: 0;
  color: #1d2939;
  font-size: 19px;
  line-height: 1.25;
}

.workspace-title p {
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-button,
.open-button {
  display: inline-flex;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid #dfe3e9;
  border-radius: 9px;
  color: #475467;
  background: #fff;
  cursor: pointer;
}

.menu-button {
  display: none;
  width: 38px;
  padding: 0;
}

.open-button {
  gap: 7px;
  margin-left: auto;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 600;
}

.menu-button:hover,
.open-button:hover {
  border-color: #c8ced8;
  color: var(--brand);
  background: #f9fafb;
}

.tool-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #eef1f5;
}

.tool-frame {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  border: 0;
  background: #f5f6f8;
}

.tool-frame.is-active {
  display: block;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 880px) {
  .sidebar-reveal-zone {
    display: none;
  }

  .sidebar {
    width: min(280px, 84vw);
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .workspace {
    width: 100%;
    margin-left: 0;
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 15;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.42);
  }

  .sidebar-scrim.is-visible {
    display: block;
  }

  .menu-button {
    display: inline-flex;
  }

  .workspace-header {
    padding-left: 14px;
  }
}

@media (max-width: 520px) {
  .workspace {
    grid-template-rows: 62px minmax(0, 1fr);
  }

  .workspace-header {
    padding-right: 10px;
  }

  .workspace-title h1 {
    font-size: 16px;
  }

  .workspace-title p {
    display: none;
  }

  .open-button {
    width: 38px;
    padding: 0;
  }

  .open-button span {
    display: none;
  }
}
