/* 应用壳：贴近 A4N SettingsShell —— 轻侧栏 + 开敞主区 */

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
}

/* 顶栏：page-header */
.app-header {
  height: var(--h-header);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: var(--hair) solid var(--line-soft);
  background: rgba(25, 30, 36, 0.88);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  z-index: 5;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 10px;
  font-weight: var(--w-heavy);
  letter-spacing: 0;
  color: #fff;
  background: var(--surface-2);
  box-shadow: 0 4px 10px -4px rgb(var(--accent-rgb) / 0.5);
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-brand-text {
  min-width: 0;
}

.app-brand h1 {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-brand .sub {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.app-actions .btn-ghost {
  color: var(--muted);
}

.nav-toggle {
  display: none;
  margin-right: 4px;
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  position: relative;
  display: block;
  width: 16px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
  position: absolute;
  left: 0;
  content: "";
}

.nav-toggle-bars::before { top: -5px; }
.nav-toggle-bars::after { top: 5px; }

/* 主体：settings-layout */
.app-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* 侧栏：settings-nav —— 无分组硬边框，item 悬浮 */
.app-nav {
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  padding: 8px;
  border-right: var(--hair) solid var(--line-soft);
  background: rgba(13, 17, 21, 0.62);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section:last-child {
  margin-bottom: 0;
}

.nav-section-title {
  padding: 14px 10px 4px;
  font-size: 11px;
  font-weight: var(--w-bold);
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
}

.nav-section:first-child .nav-section-title {
  padding-top: 6px;
}

/* 去掉分组盒子，保持导航紧凑 */
.nav-group {
  border-radius: 0;
  overflow: visible;
  background: transparent;
  border: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--h-nav-item);
  padding: 8px 12px;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.nav-item:active {
  transform: scale(0.985);
}

a.nav-item:hover,
a.nav-item:focus {
  text-decoration: none;
}

.nav-item:last-child {
  border-bottom: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.nav-item.active {
  color: #f0b59a;
  font-weight: 650;
  background: rgb(var(--accent-rgb) / 0.13);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* 导航图标使用统一线性图标，降低文字占位符带来的临时感。 */
.nav-icon {
  width: 18px;
  height: 18px;
  display: block;
  padding: 1px;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-icon use {
  pointer-events: none;
}

.nav-item:hover .nav-icon {
  color: var(--muted);
  background: transparent;
}

.nav-item.active .nav-icon {
  color: #f0b59a;
  opacity: 1;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 主区：settings-main —— 开敞 */
.app-main {
  min-height: 0;
  overflow: auto;
  padding: var(--pad-main);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  background: transparent;
}

/* 开敞主画布：无重边框盒子 */
.view-surface {
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
  min-height: 0;
  max-width: none;
  margin: 0;
  width: 100%;
  padding: var(--pad-surface);
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  animation: viewIn 0.28s var(--ease-out);
}

.view-surface > * {
  margin-bottom: 0 !important;
}

.app-nav::-webkit-scrollbar,
.app-main::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.chat-session-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.docs-main::-webkit-scrollbar,
.docs-side::-webkit-scrollbar,
.notification-list::-webkit-scrollbar,
.user-modal-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.app-nav::-webkit-scrollbar-thumb,
.app-main::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.chat-session-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.docs-main::-webkit-scrollbar-thumb,
.docs-side::-webkit-scrollbar-thumb,
.notification-list::-webkit-scrollbar-thumb,
.user-modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 登录 */
.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 400px);
  gap: 48px;
  align-items: center;
  min-height: 100%;
  min-height: 100dvh;
  padding: 40px 48px;
  background: var(--page-bg);
}

.auth-hero {
  max-width: 480px;
}

.auth-hero .eyebrow {
  display: inline-flex;
  margin-bottom: 14px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: var(--w-semibold);
  color: #f0b59a;
  background: rgb(var(--accent-rgb) / 0.12);
  border: var(--hair) solid rgb(var(--accent-rgb) / 0.2);
  line-height: 1.2;
}

.auth-hero h1 {
  font-size: clamp(28px, 3vw, 34px);
  margin-bottom: 12px;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-hero p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 0;
  max-width: 44ch;
}

.auth-card {
  padding: 24px 26px;
  border-radius: var(--r-xl);
  border: var(--hair) solid var(--line);
  background: rgba(28, 33, 39, 0.92);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
}

.auth-card .field {
  margin-bottom: 12px;
}

.auth-card .btn-block {
  margin-top: 4px;
}

.auth-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
}

/* 落地 */
.home-page {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
}

.home-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 28px;
  flex-shrink: 0;
}

.home-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 28px 56px;
}

.home-hero {
  width: min(640px, 100%);
  text-align: center;
}

.home-hero .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 15px;
  margin: 0 auto 16px;
}

.home-hero h1 {
  font-size: clamp(30px, 3.5vw, 36px);
  margin-bottom: 12px;
  letter-spacing: 0;
}

.home-hero .lead {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 46ch;
  margin: 0 auto 22px;
}

.home-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.home-meter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  text-align: left;
  margin-bottom: 20px;
}

.home-meter .cell {
  padding: 14px;
  border-radius: var(--r-lg);
  border: var(--hair) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.home-meter .cell:hover {
  border-color: rgb(var(--accent-rgb) / 0.28);
  transform: translateY(-1px);
}

.home-meter .cell span {
  display: block;
  font-size: 11px;
  font-weight: var(--w-semibold);
  color: var(--muted);
  margin-bottom: 6px;
}

.home-meter .cell strong {
  display: block;
  font-size: 15px;
  font-weight: var(--w-bold);
  margin-bottom: 4px;
  letter-spacing: 0;
}

.home-meter .cell small {
  display: block;
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.4;
}

.home-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* 落地公告（现网 announcement） */
.home-announce {
  text-align: left;
  max-width: 420px;
  margin: 0 auto 22px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: var(--hair) solid rgb(var(--warn-rgb) / 0.28);
  background: rgb(var(--warn-rgb) / 0.08);
}

.home-announce-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.home-announce-head strong {
  font-size: 13px;
  font-weight: 650;
}

.home-announce-body {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* 卡片内嵌表：去掉双重边框 */
.section-block.card-flush {
  padding: 0;
  overflow: hidden;
}

.section-block.card-flush > .panel-head {
  padding: 14px 16px 0 !important;
}

.section-block.card-flush > .table-wrap {
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.control-w-status {
  width: auto;
  min-width: 110px;
}

.brand-mark.lg {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 12px;
  margin-bottom: 16px;
}

.brand-mark.sm {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 9px;
}

.docs-signal {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 8px;
}

.docs-signal .stat {
  margin: 0;
}

.model-card .row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.seg-auth {
  margin-bottom: 16px;
}

.toolbar-split {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* 文档 */
.docs-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100%;
  background: var(--page-bg);
}

.docs-side {
  padding: 16px 10px;
  border-right: var(--hair) solid var(--line-soft);
  background: rgba(17, 20, 24, 0.5);
  overflow: auto;
  overscroll-behavior: contain;
}

.docs-side .docs-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 12px;
  margin-bottom: 4px;
  border-bottom: var(--hair) solid var(--line-soft);
}

.docs-side .docs-brand span {
  font-size: 12.5px;
  font-weight: var(--w-bold);
}

.docs-side a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  line-height: 1.3;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.docs-side a:hover,
.docs-side a.active {
  background: rgb(var(--accent-rgb) / 0.12);
  color: var(--text);
  text-decoration: none;
}

.docs-main {
  padding: 28px 36px 64px;
  max-width: 760px;
  overflow: auto;
  min-width: 0;
  overscroll-behavior: contain;
  scroll-padding-top: 24px;
}

.docs-main .docs-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.docs-main h1 {
  margin-bottom: 10px;
  font-size: 28px;
  letter-spacing: 0;
}

.docs-main h2 {
  margin: 32px 0 10px;
  font-size: 17px;
  scroll-margin-top: 16px;
}

.docs-main p {
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.65;
  font-size: 14px;
}

.docs-main pre {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: var(--hair) solid var(--line-soft);
  background: rgba(0, 0, 0, 0.28);
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #e6e1db;
}

.provider-detail {
  padding: 14px 16px;
  border: var(--hair) solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.stack-cards {
  display: flex;
  flex-direction: column;
  gap: 10px !important;
  margin: 0;
}

@media (min-width: 1280px) {
  .app-main {
    padding: 18px 22px 22px;
  }
}

@media (max-width: 960px) {
  .app-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .app-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: min(280px, 82vw);
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: var(--hair) solid var(--line);
    border-bottom: 0;
    background: #15191e;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 0.24s var(--ease-out),
      visibility 0s linear 0.24s;
    white-space: normal;
    scrollbar-width: none;
  }

  .app-nav::-webkit-scrollbar {
    display: none;
  }

  body.nav-open .app-nav {
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
    box-shadow: var(--shadow-lg);
  }

  body.console-mode.nav-open .app > .console-card {
    z-index: auto;
  }

  body.nav-open .app::after {
    position: absolute;
    inset: var(--h-header) 0 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.56);
    content: "";
  }

  body.nav-open .app-main {
    overflow: hidden;
  }

  .app-nav .nav-section,
  .app-nav .nav-group {
    display: block;
    margin: 0 0 4px;
  }

  .app-nav .nav-section-title {
    display: block;
  }

  .app-nav .nav-item {
    width: 100%;
    min-height: 36px;
    margin: 0 0 2px;
    padding: 7px 9px;
  }

  .app-nav .nav-item.active {
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .app-main {
    padding: 14px 14px 18px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 28px 20px;
  }

  .home-meter {
    grid-template-columns: 1fr;
  }

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

  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-side {
    display: flex;
    overflow-x: auto;
    border-right: none;
    border-bottom: var(--hair) solid var(--line-soft);
    gap: 4px;
    position: relative;
    z-index: 2;
    background: rgba(17, 20, 24, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .docs-side .docs-brand {
    display: none;
  }

  .docs-side a {
    white-space: nowrap;
    margin: 0;
  }

  .docs-main {
    padding: 22px 18px 48px;
  }
}

@media (max-width: 520px) {
  .app-brand .sub {
    display: none;
  }

  .home-actions {
    flex-direction: column;
  }

  .home-actions .btn {
    width: 100%;
  }
}

@media (hover: none) {
  .btn-primary:hover:not(:disabled),
  .btn-secondary:hover:not(:disabled),
  .btn-danger:hover:not(:disabled),
  .model-card:hover,
  .rule-card:hover,
  .home-meter .cell:hover {
    transform: none;
  }
}
