/* ttshare 接口文档站样式（手工维护） */

:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --sidebar-w: 272px;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-muted);
  padding: 1px 5px;
  border-radius: 5px;
  color: #0f172a;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------ 布局 */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  min-width: 200px;
  max-width: min(520px, 45vw);
  border-right: none;
  background: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  flex: 0 0 auto;
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.sidebar-search {
  flex: 0 0 auto;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.logo-desc {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-2);
}

.token-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.nav-search,
.token-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.nav-search:focus,
.token-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.token-input-row {
  display: flex;
  gap: 6px;
}

.token-toggle-btn {
  flex: 0 0 auto;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}

.token-toggle-btn:hover { background: var(--bg-muted); }

.token-query-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 550;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}

.token-query-btn:hover { background: #1d4ed8; }
.token-query-btn:disabled { opacity: 0.6; cursor: default; }

.sidebar-menu {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-menu .nav-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0 16px;
}

.nav-list, .nav-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-group { margin: 0; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  margin: 0;
  padding: 12px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text-2);
  font-size: 0.95rem;
}

.nav-group-list .nav-group-toggle { padding-left: 36px; }
.nav-group-list .nav-group-list .nav-group-toggle { padding-left: 48px; }

.nav-group-toggle:hover {
  color: var(--text);
  background: rgba(59, 130, 246, 0.08);
}

.nav-group-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: inherit;
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.nav-group-count {
  flex: 0 0 auto;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  color: var(--text-3);
  background: var(--bg-muted, #f1f5f9);
  border-radius: 999px;
}

.nav-group-list .nav-group .nav-group-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: inherit;
}

.nav-group-chevron {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-right: 12px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 0.2s ease;
}

.nav-group:not(.is-collapsed) > .nav-group-toggle .nav-group-chevron {
  transform: rotate(90deg);
}

.nav-group.is-collapsed > .nav-group-list {
  display: none;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 20px;
  color: var(--text-2);
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  white-space: normal;
  line-height: 1.45;
}

.nav-group-list > .nav-item > .nav-link { padding-left: 47px; }
.nav-group-list .nav-group-list > .nav-item > .nav-link { padding-left: 62px; }
.nav-group-list .nav-group-list .nav-group-list > .nav-item > .nav-link { padding-left: 76px; }

.nav-link:hover {
  color: var(--text);
  background: rgba(59, 130, 246, 0.08);
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-link-title {
  min-width: 0;
  width: 100%;
  white-space: normal;
  word-break: break-word;
}

a.nav-link-title {
  color: inherit;
  text-decoration: none;
}

.nav-code-link {
  color: inherit;
  text-decoration: none;
}

.nav-code-link:hover { text-decoration: underline; }

.nav-code-link.is-active { color: #60a5fa; }

.nav-code-sep { color: var(--text-3); }

.nav-link-code {
  margin-left: 0;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-3);
  white-space: normal;
  word-break: break-all;
}

.nav-link.is-active .nav-link-code { color: #60a5fa; }

.sidebar-tools {
  flex: 0 0 auto;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.sidebar-resizer {
  flex: 0 0 5px;
  width: 5px;
  margin: 0 -2px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 2;
  touch-action: none;
  user-select: none;
}

.sidebar-resizer::after {
  content: '';
  position: absolute;
  inset: 0 2px;
  background: var(--border);
  opacity: 0.35;
  transition: opacity 0.15s, background 0.15s;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.is-dragging::after,
.sidebar-resizer:focus-visible::after {
  opacity: 1;
  background: #93c5fd;
}

body.sidebar-resize-active {
  cursor: col-resize;
  user-select: none;
}

body.sidebar-resize-active .sidebar-resizer::after {
  opacity: 1;
  background: var(--accent);
}

/* ------------------------------------------------------------ 内容区 */

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

.mobile-topbar { display: none; }

.content {
  flex: 1 1 auto;
  padding: 32px 44px 80px;
  max-width: 940px;
  width: 100%;
}

.api-detail h2 {
  font-size: 24px;
  font-weight: 650;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.api-key {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.api-key code {
  background: var(--bg-muted);
  font-size: 12.5px;
  padding: 3px 8px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.api-desc {
  color: var(--text-2);
  margin: 0 0 18px;
  font-size: 14.5px;
}

.hint {
  color: var(--text-3);
  font-size: 12.5px;
  margin: 6px 0 0;
  line-height: 1.6;
}

.hint.muted { font-size: 11.5px; opacity: 0.92; }

/* 分区 */

.section {
  margin: 26px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.section:first-of-type { border-top: none; padding-top: 0; }

.section-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}

.section p { margin: 0 0 10px; color: var(--text-2); font-size: 14px; }

/* 代码块 */

.code-block {
  position: relative;
  background: #0f172a;
  border-radius: var(--radius);
  margin: 10px 0 0;
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #e2e8f0;
}

.code-block code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  font-size: 11.5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  cursor: pointer;
  font-family: inherit;
}

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

.http-example-playground {
  margin-top: 8px;
}

.http-example-playground .http-curl-editor {
  min-height: 7.5rem;
  max-height: 14rem;
}

.http-example-playground .example-params-editor {
  margin: 12px 0 10px;
  padding: 10px 12px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.example-params-hint { margin: 0 0 8px; }

.http-example-playground .pg-submit.example-run-btn {
  width: auto;
}

.live-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 8px;
}

.live-result-head .token-expiry-title {
  margin: 0;
}

.live-result-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

.live-result-tab {
  padding: 4px 12px;
  font-size: 0.82rem;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--mono);
}

.live-result-tab + .live-result-tab {
  border-left: 1px solid var(--border);
}

.live-result-tab.is-active {
  background: rgba(59, 130, 246, 0.14);
  color: var(--accent);
}

.live-result-tab:hover:not(.is-active) {
  background: rgba(59, 130, 246, 0.06);
}

.live-result-pane.is-collapsed {
  display: none !important;
}

.live-data-wrap {
  overflow-x: auto;
  margin-top: 6px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.live-data-table {
  font-size: 12.5px;
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.live-data-table th,
.live-data-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.live-data-table th code { font-size: 12px; }

/* 表格 */

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: 4px;
}

.params-table th,
.params-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.params-table th {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-strong);
}

.params-table td { color: var(--text-2); }
.params-table td:first-child { white-space: nowrap; }
.params-table tr:last-child td { border-bottom: none; }

.row-expired td { background: var(--danger-soft); }

.badge-expired {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
}

.fields-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

/* 接口总览 */
.ov-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.ov-stat {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  text-align: center;
}

.ov-stat b {
  display: block;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ov-stat span {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.ov-api-list {
  line-height: 2;
}

.ov-api-list a { margin-right: 8px; }

.ov-api-list code {
  font-size: 12px;
  padding: 1px 6px;
}

.field-chip {
  background: var(--bg-muted);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
}

/* ------------------------------------------------------------ 试调 */

.playground {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.pg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.pg-label {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  min-width: 44px;
}

.pg-input {
  width: 110px;
  padding: 6px 9px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-family: inherit;
  outline: none;
}

.pg-input:focus { border-color: var(--accent); }

.pg-input--grow {
  flex: 1;
  width: auto;
  min-width: 0;
  font-family: var(--mono);
}

.pg-row--wide .pg-label {
  min-width: 72px;
}

.pg-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--mono);
  line-height: 1.45;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  resize: vertical;
  min-height: 120px;
  outline: none;
  background: var(--bg);
}

.pg-textarea:focus { border-color: var(--accent); }

.credit-curl-preview {
  margin: 0 0 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 220px;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--mono);
}

.credit-pg-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  margin-top: 10px;
}

.credit-pg-actions .pg-secondary {
  margin-left: auto;
  flex-shrink: 0;
}

.pg-secondary {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 550;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.25;
}

.pg-secondary:hover { background: var(--bg-muted); }

.pg-submit {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 550;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.25;
  flex-shrink: 0;
}

.pg-submit:hover { background: #1d4ed8; }

/* 结果卡片 */

.live-query-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
}

.live-query-result.is-loading { color: var(--text-3); }

.live-query-result.is-error {
  border-color: #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
}

.live-query-result.is-valid { border-color: #a7f3d0; background: var(--ok-soft); }
.live-query-result.is-warning { border-color: #fde68a; background: var(--warn-soft); }
.live-query-result.is-expired { border-color: #fecaca; background: var(--danger-soft); }

.live-json {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 320px;
}

/* 侧栏里的有效期结果（紧凑） */

.token-expiry-result {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12.5px;
}

.token-expiry-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
  margin-bottom: 8px;
}

.token-expiry-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}

.token-expiry-row:last-child { border-bottom: none; }

.token-expiry-label { color: var(--text-3); flex: 0 0 auto; }

.token-expiry-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  word-break: break-all;
}

.token-expiry-remain {
  margin-top: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 12.5px;
  text-align: center;
}

.token-expiry-remain.is-valid { background: var(--ok-soft); color: var(--ok); }
.token-expiry-remain.is-warning { background: var(--warn-soft); color: var(--warn); }
.token-expiry-remain.is-expired { background: var(--danger-soft); color: var(--danger); }

.key-info-table-wrap { overflow-x: auto; margin-top: 6px; }
.key-info-table { min-width: 520px; }
.key-info-table .remain-cell { white-space: nowrap; }
.key-info-table .remain-cell.remain-warn { color: var(--warn); font-weight: 500; }

.example-subtitle {
  margin: 14px 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
}

.section > .example-subtitle:first-of-type {
  margin-top: 4px;
}

.period-cell,
.token-expiry-value--period {
  font-size: 0.9rem;
  line-height: 1.5;
}

.period-line {
  display: block;
}

.period-line + .period-line {
  margin-top: 4px;
  color: var(--text-2);
}

/* ------------------------------------------------------------ 欢迎页 */

.welcome h2 {
  font-size: 24px;
  font-weight: 650;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.welcome p {
  color: var(--text-2);
  font-size: 14.5px;
  margin: 0 0 12px;
}

.welcome-quick-link {
  font-weight: 550;
}

.welcome-catalog { margin-top: 30px; }

.welcome-catalog-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.welcome-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.welcome-card {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.welcome-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.welcome-card-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.welcome-card-desc {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ------------------------------------------------------------ 移动端 */

@media (max-width: 900px) {
  .layout { display: block; }

  .sidebar-resizer { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    flex: none;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 30;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-2);
    cursor: pointer;
    font-family: inherit;
  }

  .mobile-nav-toggle-icon,
  .mobile-nav-toggle-icon::before,
  .mobile-nav-toggle-icon::after {
    display: block;
    width: 14px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
  }

  .mobile-nav-toggle-icon::before,
  .mobile-nav-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
  }

  .mobile-nav-toggle-icon::before { top: -4px; }
  .mobile-nav-toggle-icon::after { top: 4px; }

  .mobile-topbar-title { font-size: 14px; font-weight: 600; }

  .content { padding: 20px 16px 60px; }

  .api-detail h2, .welcome h2 { font-size: 20px; }
}
