/* 与 index.html 一致的侧栏 + 主区壳层（子页面共用） */
:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --primary: #3867f5;
  --primary-hover: #2a56e8;
  --primary-soft: #ecf1ff;
  --sidebar-top: #5b90ff;
  --sidebar-bottom: #3867f5;
  --accent: #0d9488;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --page-bg: #f0f4f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.09);
  --focus-ring: 0 0 0 3px rgba(56, 103, 245, 0.22);
  --sidebar-w: 228px;
  --content-pad-x: clamp(16px, 3.2vw, 36px);
  --content-block-gap: 20px;
  --radius-page: 12px;
  --line-body: 1.55;
}

.app-shell * {
  box-sizing: border-box;
}

body.app-shell {
  margin: 0;
  background-color: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-family: var(--font-sans);
  line-height: var(--line-body);
  -webkit-font-smoothing: antialiased;
}

.app-shell .sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(165deg, var(--sidebar-top) 0%, var(--sidebar-bottom) 48%, #2d4fc4 100%);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.app-shell .sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 30px;
  font-size: 22px;
  font-weight: 600;
}

.app-shell .sidebar-menu {
  flex: 1;
}

.app-shell .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin: 3px 12px;
  font-size: 15px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  border: none;
  background: transparent;
  align-self: stretch;
  text-align: left;
  font-family: inherit;
  border-radius: 10px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.app-shell .menu-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.app-shell .menu-item.active {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.app-shell .sidebar-footer {
  background: rgba(255, 255, 255, 0.12);
  margin: 0 10px;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.app-shell .footer-title {
  font-size: 13px;
  margin-bottom: 6px;
  opacity: 0.95;
}

.app-shell .footer-num {
  font-size: 22px;
  font-weight: 700;
}

.app-shell .main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}

.app-shell .main-header {
  background: var(--surface);
  padding: 16px var(--content-pad-x);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.app-shell .main-header--simple {
  justify-content: flex-start;
}

.app-shell .main-header--simple .header-title {
  flex: 1 1 200px;
  min-width: 0;
}

.app-shell .header-title h1 {
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.3;
}

.app-shell .header-title p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 4px 0 0;
  line-height: 1.45;
  max-width: 52ch;
}

.app-shell .secondary-main-inner {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: var(--content-block-gap) var(--content-pad-x) max(28px, env(safe-area-inset-bottom, 0px));
}

/* OAuth 等说明页内卡片 */
.app-shell .oauth-panel {
  max-width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-page);
  padding: clamp(18px, 4vw, 28px);
  box-shadow: var(--shadow-sm);
}

.app-shell .oauth-panel h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.app-shell .oauth-panel p,
.app-shell .oauth-panel li {
  line-height: 1.65;
}

.app-shell .oauth-panel ol {
  margin: 0;
}

.app-shell .oauth-panel .muted {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 16px;
}

.app-shell .oauth-panel a {
  color: var(--primary);
}

.app-shell .oauth-panel .btn-row {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

@media (max-width: 520px) {
  .app-shell .oauth-panel .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .app-shell .oauth-panel .btn-row a.btn {
    width: 100%;
    justify-content: center;
  }
}

.app-shell .oauth-panel a.btn,
.app-shell .oauth-panel button.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff !important;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.15s ease;
}

.app-shell .oauth-panel a.btn:hover,
.app-shell .oauth-panel button.btn-primary:hover {
  background: var(--primary-hover);
}

.app-shell .oauth-panel a.btn-secondary {
  background: var(--text-secondary);
}

.app-shell .oauth-panel a.btn-secondary:hover {
  background: #334155;
}

.app-shell .oauth-panel code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  word-break: break-all;
}

.app-shell .oauth-panel pre {
  background: var(--surface-2);
  padding: 12px;
  overflow-x: auto;
  word-break: break-all;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.app-shell .oauth-panel label {
  display: block;
  margin-top: 12px;
  font-weight: 600;
  font-size: 14px;
}

.app-shell .oauth-panel input[type="text"],
.app-shell .oauth-panel input[type="password"],
.app-shell .oauth-panel input[type="url"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.app-shell .oauth-panel input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.app-shell .oauth-panel .note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  padding: 12px;
  margin: 16px 0;
  border-radius: 8px;
  font-size: 14px;
}

.app-shell .oauth-panel .ok {
  color: #15803d;
}

.app-shell .oauth-panel .err {
  color: var(--danger);
}

.app-shell .hidden {
  display: none !important;
}

.app-shell .oauth-panel button[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  padding: 10px 18px;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
}

.app-shell .oauth-panel button[type="button"]:hover {
  background: var(--primary-hover);
}

.app-shell .oauth-panel button.secondary {
  background: var(--text-secondary);
  margin-left: 8px;
}

.app-shell .oauth-panel .oauth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.app-shell .oauth-panel .oauth-actions button[type="button"] {
  margin-top: 0;
}

@media (max-width: 520px) {
  .app-shell .oauth-panel .oauth-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .app-shell .oauth-panel .oauth-actions button.secondary {
    margin-left: 0;
  }
}

.app-shell .oauth-panel button.secondary:hover {
  background: #334155;
}

.app-shell .sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.app-shell .sidebar-toggle svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}

.app-shell .sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10000;
  -webkit-tap-highlight-color: transparent;
}

body.app-shell.sidebar-open .sidebar-overlay {
  display: block;
}

@media (max-width: 900px) {
  body.app-shell {
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
  }

  body.app-shell.sidebar-open {
    overflow: hidden;
  }

  .app-shell .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 88vw);
    min-height: 100vh;
    min-height: 100dvh;
    z-index: 10001;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  body.app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.18);
  }

  .app-shell .sidebar-toggle {
    display: inline-flex;
  }

  .app-shell .main {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .app-shell .main-header {
    padding: 12px var(--content-pad-x);
  }

  .app-shell .main-header--simple {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
  }

  .app-shell .main-header--simple .header-title {
    flex: 1;
    min-width: 0;
  }

  .app-shell .header-title h1 {
    font-size: 19px;
    line-height: 1.25;
  }

  .app-shell .header-title p {
    font-size: 13px;
  }

  .app-shell .secondary-main-inner {
    padding: 14px var(--content-pad-x) max(20px, env(safe-area-inset-bottom, 0px));
  }
}

