html, body {
  margin: 0;
  min-width: 1024px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Yu Gothic UI", "Yu Gothic", YuGothic, "Hiragino Sans", "Segoe UI", sans-serif;
  line-height: 1.5;
  font-size: var(--font-body);
}

body.has-shell {
  padding-left: var(--sidebar-width);
  padding-top: var(--header-height);
  transition: padding-left 0.18s ease;
}

body.has-shell.is-collapsed,
html.shell-collapsed body.has-shell {
  padding-left: var(--sidebar-rail-width);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  color: #dbe4f3;
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.08);
  z-index: 40;
  transition: width 0.18s ease;
}

body.is-collapsed .app-sidebar,
html.shell-collapsed .app-sidebar {
  width: var(--sidebar-rail-width);
}

.rail {
  width: var(--sidebar-rail-width);
  background: var(--color-rail);
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-rail-width);
}

.brand {
  height: var(--header-height);
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand img {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  object-fit: contain;
  background: #fff;
}

.brand-fallback {
  display: none;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: #fff;
  color: #2458c6;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0.02em;
  font-size: 12px;
}

.rail-tabs {
  padding: 12px 7px;
  flex: 1;
  overflow: auto;
}

.rail-tab {
  width: 70px;
  height: 66px;
  border: 0;
  background: transparent;
  color: #91a0b6;
  border-radius: 12px;
  margin: 3px 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.rail-tab .i { font-size: 19px; line-height: 1; display: grid; place-items: center; }
.rail-tab .i svg { width: 22px; height: 22px; display: block; }
.rail-tab .t { font-size: 10px; font-weight: 800; }
.rail-tab:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.rail-tab.is-active {
  background: linear-gradient(180deg, #2f63da, #244fb2);
  color: #fff;
}

.rail-collapse {
  margin: 8px 7px 12px;
  width: 70px;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  display: none;
  place-items: center;
  padding: 0;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.rail-collapse svg {
  width: 26px;
  height: 26px;
  display: block;
}

body.is-collapsed .rail-collapse,
html.shell-collapsed .rail-collapse {
  display: grid;
}

.menu-collapse {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 9px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.menu-collapse svg {
  width: 18px;
  height: 18px;
  display: block;
}

.menu-collapse:hover {
  background: rgba(255, 255, 255, 0.14);
}

body.is-collapsed .menu-collapse,
html.shell-collapsed .menu-collapse {
  display: none;
}

.menu-panel {
  width: var(--sidebar-menu-width);
  background: var(--color-panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: width 0.18s ease, opacity 0.18s ease;
}

body.is-collapsed .menu-panel,
html.shell-collapsed .menu-panel {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.menu-head {
  height: var(--header-height);
  padding: 12px 10px 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.menu-head-text { min-width: 0; }
.menu-head strong { display: block; color: #fff; font-size: 15px; }
.menu-head-text span { font-size: 10px; color: #8290a7; }

.menu-body { padding: 13px 12px; overflow: auto; flex: 1; }
.menu-label {
  font-size: 10px;
  color: #718198;
  font-weight: 800;
  margin: 10px 10px 7px;
}

.menu-link {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 42px;
  padding: 0 11px;
  border-radius: 9px;
  text-decoration: none;
  color: #c9d3e2;
  font-size: 12px;
  margin: 3px 0;
}

.menu-link:hover,
.menu-link.is-active {
  background: var(--color-panel-2);
  color: #fff;
  text-decoration: none;
}

.app-topbar {
  height: var(--header-height);
  background: var(--color-header);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e8eef8;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 30;
  gap: 12px;
}

body.has-shell.is-collapsed .app-topbar,
html.shell-collapsed body.has-shell .app-topbar {
  left: var(--sidebar-rail-width);
}
.app-topbar .breadcrumbs { color: #93a4bc; }
.app-topbar .page-title h1 { color: #fff; }
.app-topbar .page-title p { color: #b7c4d6; }
.app-topbar .page-updated { color: #9aabc0; }

.page-title { min-width: 0; }
.breadcrumbs {
  font-size: var(--font-caption);
  color: #8791a0;
  margin-bottom: 4px;
}
.page-title h1 {
  font-size: var(--font-title);
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.page-title-meta {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  margin-top: 3px;
}
.page-title p {
  font-size: var(--font-caption);
  color: var(--color-muted);
  margin: 0;
  min-width: 0;
  flex: 1;
}
.page-updated {
  display: inline;
  margin: 0;
  font-size: 10px;
  color: #97a0ad;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
}
.page-updated:empty { display: none; }

.command {
  margin-left: auto;
  width: min(300px, 28vw);
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #c5d0de;
  font-size: 11px;
  cursor: pointer;
}
.app-topbar .command:hover { background: rgba(255, 255, 255, 0.14); }

.command kbd {
  margin-left: auto;
  font-size: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  padding: 1px 5px;
  color: #c5d0de;
}

.command-pop {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  right: 220px;
  width: 360px;
  max-height: 420px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  z-index: 50;
  padding: 8px;
}

.command-pop input {
  width: 100%;
  height: 36px;
  border: 1px solid #dce2eb;
  border-radius: 8px;
  padding: 0 10px;
  margin-bottom: 8px;
}

.command-item {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--color-text);
  font-size: 12px;
}

.command-item:hover,
.command-item.is-on {
  background: #f2f5f9;
  text-decoration: none;
}

.command-item small {
  display: block;
  color: var(--color-muted);
  font-size: 10px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  cursor: pointer;
  color: #e8eef8;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

.env-badge,
.app-topbar .env-badge {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
}

.env-badge.is-dev {
  color: #0f766e;
  background: #ecfdf8;
  border: 1px solid #99f6e4;
}

.env-badge.is-prod {
  color: #b42318;
  background: #fff1f1;
  border: 1px solid #ffd9d9;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.08);
}

.user-chip {
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 10px;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  min-width: 84px;
}

.user-chip b { font-size: 11px; }
.user-chip span { color: #9aabc0; }

.logout-btn {
  height: 38px;
  border: 1px solid rgba(248, 180, 180, 0.45);
  background: rgba(255, 241, 241, 0.12);
  color: #fecaca;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.logout-btn:hover { background: rgba(255, 241, 241, 0.2); }

.app-content {
  padding: 14px 18px 28px;
  transition: opacity 0.16s ease;
}
body.has-shell .wrap.app-content { padding: 14px 18px 28px; }

.page-transit {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 80;
  display: none;
  place-items: center;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(1.5px);
}

body.has-shell .page-transit { left: var(--sidebar-width); }
body.has-shell.is-collapsed .page-transit,
html.shell-collapsed body.has-shell .page-transit {
  left: var(--sidebar-rail-width);
}

html.is-page-loading .page-transit,
body.is-navigating .page-transit {
  display: grid;
}

.page-transit-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 180px;
  padding: 22px 26px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.28);
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 800;
}

.page-transit-card p { margin: 0; }

html.is-page-loading .app-content,
body.is-navigating .app-content {
  pointer-events: none;
}

body.has-shell .app-header,
body.has-shell .tab-bar,
body.has-shell .header-bar .nav-links {
  display: none !important;
}

@media (max-width: 1180px) {
  .command { width: 180px; }
  .app-topbar { padding: 0 14px; }
  .app-content { padding: 14px 14px 28px; }
}
