/* ==========================================================================
   抖音续火花 · 界面样式 (ios.css)
   设计方向：iOS 结构 + 中式简洁审美
   - 墨色为主、朱砂点缀，克制用色
   - 细边框、弱阴影、大留白
   - 移动端优先（前台主要面向手机用户）
   ========================================================================== */

/* ---------------------------------------------------------------
   1. 设计变量 · 浅色
   --------------------------------------------------------------- */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-alt: #f5f5f7;
  --surface-soft: #ececf0;

  --border: #e5e5ea;
  --border-strong: #d6d6dc;

  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-faint: #9a9aa0;

  /* 墨色主色 */
  --primary: #1d1d1f;
  --primary-strong: #000000;
  --primary-soft: rgba(29, 29, 31, 0.06);
  --btn-bg: #1d1d1f;
  --btn-fg: #ffffff;

  /* 朱砂点缀 */
  --accent: #c8501e;
  --accent-soft: rgba(200, 80, 30, 0.1);

  --success: #2e7d5b;
  --success-soft: rgba(46, 125, 91, 0.1);
  --warning: #b7791f;
  --warning-soft: rgba(183, 121, 31, 0.1);
  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, 0.1);
  --info: #5f6b7a;
  --info-soft: rgba(95, 107, 122, 0.1);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --focus: 0 0 0 3px rgba(29, 29, 31, 0.1);
  --fire-grad: #1d1d1f;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --sidebar-width: 236px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

/* ---------------------------------------------------------------
   2. 设计变量 · 深色
   --------------------------------------------------------------- */
html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-alt: #242426;
  --surface-soft: #2e2e30;

  --border: #2e2e30;
  --border-strong: #3d3d40;

  --text: #f5f5f7;
  --text-muted: #a1a1a6;
  --text-faint: #75757a;

  --primary: #f5f5f7;
  --primary-strong: #ffffff;
  --primary-soft: rgba(245, 245, 247, 0.08);
  --btn-bg: #f5f5f7;
  --btn-fg: #1d1d1f;

  --accent: #e0642f;
  --accent-soft: rgba(224, 100, 47, 0.14);

  --success: #4caf82;
  --success-soft: rgba(76, 175, 130, 0.14);
  --warning: #d4a24c;
  --warning-soft: rgba(212, 162, 76, 0.14);
  --danger: #e05b4d;
  --danger-soft: rgba(224, 91, 77, 0.14);
  --info: #98a3b0;
  --info-soft: rgba(152, 163, 176, 0.14);

  --shadow: none;
  --focus: 0 0 0 3px rgba(245, 245, 247, 0.14);
  --fire-grad: #f5f5f7;
}

/* ---------------------------------------------------------------
   3. 基础
   --------------------------------------------------------------- */
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

svg {
  stroke-width: 1.75;
}

::selection {
  background: var(--accent-soft);
}

/* 锚点定位留出顶栏高度 */
section[id],
details[id],
div[id] {
  scroll-margin-top: 84px;
}

/* ---------------------------------------------------------------
   4. 布局骨架
   --------------------------------------------------------------- */
.sidebar {
  padding: 20px 14px;
  gap: 24px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand-mark {
  border-radius: 10px;
  background: var(--fire-grad);
  box-shadow: none;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-faint);
}

.nav-groups {
  gap: 20px;
}

.nav-group-title {
  margin: 0 10px 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  text-transform: none;
}

.nav-group {
  gap: 2px;
}

.nav-item {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.nav-item.active {
  color: var(--text);
  background: var(--surface-alt);
  font-weight: 600;
  box-shadow: none;
}

.nav-item.active svg {
  color: var(--accent);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.user-avatar {
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

.user-copy small {
  font-size: 11px;
  color: var(--text-faint);
}

.main-area {
  padding: 28px 32px 48px;
}

.page-header {
  margin-bottom: 24px;
}

.page-heading h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-heading p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------------------------------------------------------------
   5. 按钮
   --------------------------------------------------------------- */
.button,
.link-button,
.ghost-button,
.soft-button,
.danger-button,
.success-button {
  min-height: 42px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.button,
.button-primary,
.link-button {
  color: var(--btn-fg);
  background: var(--btn-bg);
}

.button:hover,
.button-primary:hover,
.link-button:hover {
  opacity: 0.85;
  background: var(--btn-bg);
}

.button-quiet,
.ghost-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.button-quiet:hover,
.ghost-button:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.button-soft,
.soft-button {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.button-soft:hover,
.soft-button:hover {
  opacity: 0.85;
}

.button-danger,
.danger-button {
  color: var(--danger);
  background: var(--danger-soft);
}

.button-danger:hover,
.danger-button:hover {
  color: #ffffff;
  background: var(--danger);
}

.button-success,
.success-button {
  color: var(--success);
  background: var(--success-soft);
}

.icon-button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------------------------------------------------------------
   6. 表单
   --------------------------------------------------------------- */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  font-size: 16px; /* 防止 iOS 聚焦自动放大 */
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--text-faint);
  background: var(--surface);
}

textarea {
  min-height: 104px;
  resize: vertical;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.stack-form label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------
   7. 卡片 / 面板
   --------------------------------------------------------------- */
.collapsible-section,
.panel,
.metric-card,
.table-shell,
.overview-strip,
.account-row,
.target-record {
  border-radius: var(--radius-lg);
}

.collapsible-section,
.panel,
.metric-card,
.table-shell {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.dashboard-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 17px;
  font-weight: 600;
}

.section-header h3,
.panel-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.muted {
  color: var(--text-muted);
}

.compact {
  font-size: 13px;
}

/* ---------------------------------------------------------------
   8. 概览 / 指标
   --------------------------------------------------------------- */
.overview-strip {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overview-primary,
.overview-cell {
  padding: 22px;
}

.metric-grid {
  gap: 14px;
}

.metric-card {
  padding: 18px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.metric-card.success { border-top: 2px solid var(--success); }
.metric-card.warning { border-top: 2px solid var(--warning); }
.metric-card.danger  { border-top: 2px solid var(--danger); }
.metric-card.info    { border-top: 2px solid var(--info); }

/* ---------------------------------------------------------------
   9. 提示 / 状态
   --------------------------------------------------------------- */
.flash {
  padding: 12px 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
}

.status-banner {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.status-chip,
.pill {
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-soft);
  color: var(--text-muted);
}

/* ---------------------------------------------------------------
   10. 表格
   --------------------------------------------------------------- */
.table-shell {
  overflow: hidden;
}

th, td {
  padding: 13px 15px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  background: var(--surface-alt);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-alt);
}

/* ---------------------------------------------------------------
   11. 认证页（登录 / 注册）· 移动端优先
   --------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
}

.auth-shell {
  width: 100%;
  max-width: 380px;
}

.auth-head {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--fire-grad);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-logo svg {
  width: 26px;
  height: 26px;
}

.auth-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-head p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-faint);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.auth-sub {
  margin: 6px 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-switch {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--accent);
  font-weight: 500;
  margin-left: 2px;
}

.auth-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------
   12. 移动端导航（底部标签栏）
   --------------------------------------------------------------- */
.tabbar {
  display: none;
}

@media (max-width: 900px) {
  .mobile-topbar {
    height: 54px;
    padding: 0 14px;
    padding-top: env(safe-area-inset-top);
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--border);
  }

  .mobile-brand {
    font-size: 15px;
    font-weight: 600;
  }

  .mobile-brand .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    border-radius: 8px;
  }

  .app-shell {
    display: block;
    min-height: calc(100vh - 54px);
  }

  .sidebar {
    width: 268px;
    padding: 20px 14px;
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.18);
  }

  .main-area {
    padding: 18px 16px calc(88px + env(safe-area-inset-bottom));
  }

  .desktop-theme-toggle {
    display: none;
  }

  .page-header {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .page-header-actions,
  .action-bar {
    justify-content: flex-start;
  }

  .action-bar {
    width: 100%;
  }

  .action-bar > form,
  .action-bar > .button,
  .action-bar > .link-button,
  .action-bar > a {
    flex: 1 1 140px;
  }

  .panel {
    padding: 16px;
  }

  /* 底部标签栏 */
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--border);
  }

  .tabbar-item {
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 500;
    transition: color 0.15s ease;
  }

  .tabbar-item svg {
    width: 21px;
    height: 21px;
  }

  .tabbar-item.active {
    color: var(--text);
  }

  .tabbar-item.active svg {
    color: var(--accent);
  }
}

/* ---------------------------------------------------------------
   14. 后台分组
   --------------------------------------------------------------- */
.stack-group {
  display: grid;
  gap: 16px;
}

.group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.group-label::before {
  content: "";
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--accent);
}

.section-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.empty-state {
  padding: 28px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-faint);
  font-size: 14px;
  text-align: center;
}

.collapsible-section > summary {
  padding: 15px 18px;
  gap: 12px;
}

.collapsible-section > summary strong {
  font-weight: 600;
}

.collapsible-section > summary small {
  color: var(--text-faint);
}

.collapsible-body {
  padding: 4px 18px 18px;
}

.account-summary-list,
.account-management-list {
  display: grid;
  gap: 10px;
}

.account-row {
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-avatar {
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 620px) {
  .stack-group {
    gap: 12px;
  }

  .collapsible-section > summary {
    padding: 14px;
  }

  .collapsible-body {
    padding: 2px 14px 16px;
  }

  .account-row {
    padding: 13px 14px;
  }
}

@media (max-width: 620px) {
  .main-area {
    padding-inline: 14px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .metric-card {
    padding: 15px;
  }

  .metric-value {
    font-size: 22px;
  }

  .overview-primary,
  .overview-cell {
    padding: 18px;
  }

  .section-header,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .auth-page {
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    align-items: flex-start;
  }

  .auth-head {
    margin: 12px 0 22px;
  }

  .auth-card {
    padding: 22px 18px;
    border-radius: 18px;
  }

  .button,
  .link-button,
  .ghost-button,
  .soft-button,
  .danger-button,
  .success-button {
    width: 100%;
  }

  .button-row > *,
  .button-grid > * {
    flex: 1 1 100%;
  }
}

/* ------------------------------------------------------------------
   15. 登录工作区操作区（精简按钮层级）
   只保留 2 个主按钮，其余降级为一行文字操作，避免按钮堆砌。
   ------------------------------------------------------------------ */
.login-primary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.login-primary-actions .button {
  width: 100%;
  justify-content: center;
}

.login-quiet-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 16px;
  padding-top: 2px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease;
}

.text-button svg {
  width: 14px;
  height: 14px;
}

.text-button:hover {
  color: var(--text);
}

.text-button-danger:hover {
  color: var(--danger);
}

@media (max-width: 620px) {
  .login-primary-actions {
    grid-template-columns: 1fr;
  }

  .login-quiet-actions {
    gap: 2px 14px;
  }
}

/* ------------------------------------------------------------------
   16. 登录凭证导入（Cookie / storage-state.json）
   ------------------------------------------------------------------ */
.credential-import {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.credential-import-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.credential-import-head > svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--accent);
}

.credential-import-head strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.credential-import-head small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.credential-import form {
  display: grid;
  gap: 14px;
}

.credential-import .field {
  display: grid;
  gap: 6px;
}

.credential-import .field > span {
  color: var(--text-muted);
  font-size: 13px;
}

.credential-import textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px; /* 16px 可避免 iOS 聚焦时自动放大 */
  line-height: 1.5;
  resize: vertical;
}

.credential-import textarea:focus,
.credential-import input:focus {
  outline: none;
  border-color: var(--accent);
}

[data-credential-import-status] {
  margin: 0;
}

[data-credential-import-status]:empty {
  display: none;
}

[data-credential-import-status][data-tone="success"] {
  color: var(--success);
}

[data-credential-import-status][data-tone="danger"] {
  color: var(--danger);
}

[data-credential-import-status][data-tone="pending"] {
  color: var(--text-muted);
}

.import-help {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.import-help > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  list-style: none;
}

.import-help > summary::-webkit-details-marker {
  display: none;
}

.import-help > summary::before {
  content: "?";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 10px;
}

.import-help-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.75;
}

.import-help-steps code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
  font-size: 12px;
}

@media (max-width: 620px) {
  .credential-import {
    padding: 14px;
  }
}
