/* 界面样式（主题）。登记在 app/themes.py，右上角切换，<html data-theme="…">。
   默认的「账房」不在这里：它就是 app.css 本身。每套主题 = 自己的版面 + 一组设计变量 + 部件规则：
     ai     靛蓝 · 侧栏   导航在左边的深色侧栏，内容区顶上一条工具栏
     sumi   墨黑 · 紧凑   整体缩小一号、行距压紧的操作台，卡片带标题条，表格隔行变色
     wakaba 嫩绿 · 宽松   正文居中、字大留白多，页面标题是一条色带
   约束：
   · 只改 app.css 的 :root 里已有的变量（tests/test_themes.py 守着）；
   · 页头的断点是按宽度量出来的：顶部导航的版面里，导航各项不许比默认的宽（紧凑版整体缩小，宽松版把页头钉在默认字号）；
   · 危险 / 警示色（--color-danger*）不跟主题走。 */

/* 切换菜单里的色块：左半底色、右半强调色（颜色写在这里，不写进页面） */
.theme-swatch-chouba { --swatch-a: #f5f2ea; --swatch-b: #c2401c; }
.theme-swatch-ai { --swatch-a: #101a33; --swatch-b: #3b63e6; }
.theme-swatch-sumi { --swatch-a: #1b1a18; --swatch-b: #f1c232; }
.theme-swatch-wakaba { --swatch-a: #f1f6f2; --swatch-b: #0f7a5c; }

/* ============================================================
   靛蓝 · 侧栏
   ============================================================ */
html[data-theme="ai"] {
  --color-paper: #f3f5f9;
  --color-surface: #ffffff;
  --color-ink: #141a26;
  --color-ink-soft: #5b6577;
  --color-line: #e2e6ee;
  --color-line-strong: #c7cedb;
  --color-accent: #2447c8;
  --color-accent-deep: #18328f;
  --color-accent-soft: #e6ecfd;
  --color-accent-edge: #c3d0f7;
  --accent-rgb: 36 71 200;
  --color-bar: #cdd6ea;
  --color-bar-hover: #aab8dc;
  --radius: 6px;
  --shadow-card: 0 1px 0 rgb(20 26 38 / 0.04);
}
/* 标题不用明朝体：这一套靠粗细，不靠字体对比 */
html[data-theme="ai"], html[data-theme="ai"][lang="zh"] { --font-serif: var(--font-sans); }
html[data-theme="ai"] body { background: var(--color-paper); }
html[data-theme="ai"] h1, html[data-theme="ai"] h2, html[data-theme="ai"] h3 { font-weight: 800; letter-spacing: -0.01em; }
html[data-theme="ai"] .btn { border-radius: 6px; }
html[data-theme="ai"] .btn-primary { box-shadow: none; }
html[data-theme="ai"] .badge, html[data-theme="ai"] .chip { border-radius: 4px; }
html[data-theme="ai"] .card { box-shadow: none; }
html[data-theme="ai"] .table thead th { background: #f7f9fc; color: var(--color-ink); letter-spacing: 0.03em; }
html[data-theme="ai"] .stat-card { border-left: 3px solid var(--color-accent); }
html[data-theme="ai"] input, html[data-theme="ai"] select, html[data-theme="ai"] textarea { border-radius: 6px; }
html[data-theme="ai"] .brand-mark { border-radius: 6px; box-shadow: none; }

/* 侧栏版面只在放得下的宽度用；再窄就退回顶部导航（app.css 的 Responsive 那一套） */
@media (min-width: 1100px) {
  html[data-theme="ai"] body { padding-left: 15rem; padding-top: 3.25rem; }
  /* 侧栏：页头整块钉在左边。里面换一组变量，导航、弹出的子菜单都跟着变成深底浅字 */
  html[data-theme="ai"] .site-header {
    --color-surface: #101a33;
    --color-ink: #f2f5fc;
    --color-ink-soft: #a9b4cf;
    --color-line: #24304f;
    --color-line-strong: #36446b;
    --color-accent: #3b63e6;
    --color-accent-deep: #ffffff;
    --color-accent-soft: #2447c8;
    --accent-rgb: 59 99 230;
    --header-gap: 0.5rem;
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: 15rem; padding: 1rem 0.75rem;
    flex-direction: column; flex-wrap: nowrap !important; align-items: stretch; gap: 0.25rem !important;
    border-bottom: none; color: var(--color-ink);
  }
  html[data-theme="ai"] .site-header .brand { padding: 0.25rem 0.5rem 0.9rem; }
  html[data-theme="ai"] .site-header .brand-name { color: var(--color-ink); }
  html[data-theme="ai"] .site-header .env-badge { align-self: flex-start; margin: 0 0 0.6rem 0.5rem; }
  html[data-theme="ai"] .site-header .site-nav {
    flex-direction: column; flex-wrap: nowrap; flex: 1 1 auto; gap: 0.15rem;
    order: 0 !important; flex-basis: auto !important; position: static !important;
  }
  html[data-theme="ai"] .site-header .site-nav > a,
  html[data-theme="ai"] .site-header .nav-dropdown > summary {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.55rem 0.75rem; border-radius: 6px;
  }
  html[data-theme="ai"] .site-header .site-nav > a:hover,
  html[data-theme="ai"] .site-header .nav-dropdown > summary:hover,
  html[data-theme="ai"] .site-header .nav-dropdown-menu a:hover { background: rgb(255 255 255 / 0.08); }
  html[data-theme="ai"] .site-header .site-nav > a.is-active,
  html[data-theme="ai"] .site-header .nav-dropdown > summary.is-active {
    background: var(--color-accent-soft); color: #fff; box-shadow: inset 3px 0 0 #9db4ff;
  }
  /* 子菜单从侧栏右边弹出（小箭头改朝右） */
  html[data-theme="ai"] .site-header .nav-dropdown > summary .lang-caret,
  html[data-theme="ai"] .site-header .nav-dropdown[open] > summary .lang-caret { transform: rotate(-90deg); }
  html[data-theme="ai"] .site-header .nav-dropdown-menu {
    /* top 不加 !important：靠下的几项伸出屏幕底时，base.html 的脚本会用内联样式把它往上挪 */
    top: -0.3rem; left: 100% !important; right: auto !important;
    max-height: calc(100vh - 1rem); overflow-y: auto;
    margin-left: 0.5rem; border-radius: 8px; box-shadow: 0 14px 34px rgb(8 14 32 / 0.45);
  }
  /* 鼠标从导航项移到子菜单，中间那道缝不能断（断了菜单会收起来） */
  html[data-theme="ai"] .site-header .nav-dropdown-menu::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: -0.6rem; width: 0.6rem;
  }
  /* 内容区顶上的工具栏：版本号、语言、界面样式、账户。回到浅色的那组变量 */
  html[data-theme="ai"] .header-tools {
    --color-surface: #ffffff;
    --color-ink: #141a26;
    --color-ink-soft: #5b6577;
    --color-line: #e2e6ee;
    --color-line-strong: #c7cedb;
    --color-accent: #2447c8;
    --color-accent-deep: #18328f;
    --color-accent-soft: #e6ecfd;
    --accent-rgb: 36 71 200;
    position: fixed; top: 0; right: 0; left: 15rem; z-index: 39; height: 3.25rem;
    display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem;
    padding: 0 var(--space-page);
    background: var(--color-surface); border-bottom: 1px solid var(--color-line); color: var(--color-ink);
  }
  html[data-theme="ai"] .header-tools .header-ver { margin: 0 !important; }
  html[data-theme="ai"] .header-tools .lang-dropdown { margin-left: 0 !important; }
  html[data-theme="ai"] .header-tools .theme-dropdown { margin-left: 0; }
  /* 贴顶的几块（模版预览、广告图预览、出品清单的详情栏）要让开顶上的工具栏 */
  html[data-theme="ai"] .lt-preview, html[data-theme="ai"] .ad-editor-preview { top: 4.25rem; }
  html[data-theme="ai"] .detail-pane { top: 4.25rem; max-height: calc(100vh - 5.25rem); }
  html[data-theme="ai"] .page { padding-top: 1.75rem; }
}
/* 退回顶部导航的宽度：当前项用下划线，不用药丸 */
@media (max-width: 1099.98px) {
  html[data-theme="ai"] .site-header { box-shadow: inset 0 3px 0 var(--color-accent); }
  html[data-theme="ai"] .site-nav a, html[data-theme="ai"] .nav-dropdown summary { border-radius: 2px; }
  html[data-theme="ai"] .site-nav a.is-active, html[data-theme="ai"] .nav-dropdown summary.is-active {
    background: transparent; color: var(--color-accent); box-shadow: inset 0 -2px 0 var(--color-accent);
  }
}

/* ============================================================
   墨黑 · 紧凑
   ============================================================ */
html[data-theme="sumi"] {
  --color-paper: #e9e7e1;
  --color-surface: #fbfaf7;
  --color-ink: #161514;
  --color-ink-soft: #5f5b53;
  --color-line: #d6d2c7;
  --color-line-strong: #b3ae9f;
  --color-accent: #1d1c1a;
  --color-accent-deep: #000000;
  --color-accent-soft: #e2ded3;
  --color-accent-edge: #c9c4b6;
  --accent-rgb: 29 28 26;
  --color-bar: #cfcabd;
  --color-bar-hover: #aaa494;
  --radius: 2px;
  --shadow-card: none;
  --space-page: clamp(0.6rem, 0.3rem + 1vw, 1.2rem);
  /* 整体缩小一号：间距、圆角、导航都按 rem 算，一起变小（页头只会更窄，断点仍然够用） */
  font-size: 14px;
}
html[data-theme="sumi"] body { background: var(--color-paper); font-size: 13px; line-height: 1.5; }
/* 页头：一条墨色，金色只点在「现在在哪」 */
html[data-theme="sumi"] .site-header {
  --color-surface: #1b1a18;
  --color-ink: #f4f1e9;
  --color-ink-soft: #b5afa2;
  --color-line: #34322e;
  --color-line-strong: #4f4c45;
  --color-accent: #f1c232;
  --color-accent-deep: #1b1a18;
  --color-accent-soft: #f1c232;
  --accent-rgb: 241 194 50;
  padding-top: 0.45rem; padding-bottom: 0.45rem;
  border-bottom: 3px solid #f1c232; color: var(--color-ink);
}
html[data-theme="sumi"] .site-header .brand-mark { color: #1b1a18; border-radius: 2px; box-shadow: none; }
html[data-theme="sumi"] .site-header .brand-name { color: var(--color-ink); }
html[data-theme="sumi"] .site-header .brand-name small { display: none; }
html[data-theme="sumi"] .site-header .site-nav a, html[data-theme="sumi"] .site-header .nav-dropdown summary { border-radius: 2px; }
html[data-theme="sumi"] .site-header .site-nav a:hover,
html[data-theme="sumi"] .site-header .nav-dropdown summary:hover,
html[data-theme="sumi"] .site-header .lang-dropdown summary:hover,
html[data-theme="sumi"] .site-header .lang-opt:hover,
html[data-theme="sumi"] .site-header .user-menu summary:hover,
html[data-theme="sumi"] .site-header .nav-dropdown-menu a:hover { background: rgb(255 255 255 / 0.09); }
html[data-theme="sumi"] .site-header .nav-dropdown-menu,
html[data-theme="sumi"] .site-header .lang-menu,
html[data-theme="sumi"] .site-header .user-menu-panel { box-shadow: 0 14px 30px rgb(0 0 0 / 0.4); border-radius: 2px; }
html[data-theme="sumi"] .site-header .env-badge, html[data-theme="sumi"] .site-header .user-avatar { color: #1b1a18; }
/* 正文：压紧 */
html[data-theme="sumi"] .page { padding-top: 0.8rem; padding-bottom: 2rem; }
html[data-theme="sumi"] .page-head {
  align-items: center; margin-bottom: 0.7rem; padding: 0.45rem 0.8rem;
  background: var(--color-surface); border: 1px solid var(--color-line-strong); border-left: 5px solid #f1c232;
}
html[data-theme="sumi"] .page-head h1 { margin: 0; font-size: 1.25rem; font-weight: 800; }
html[data-theme="sumi"] .page-sub { font-size: 0.85rem; }
/* 卡片 = 带标题条的面板 */
html[data-theme="sumi"] .card { padding: 0.75rem 0.9rem; border-color: var(--color-line-strong); }
html[data-theme="sumi"] .card > .card-title:first-child, html[data-theme="sumi"] .card > .card-head:first-child {
  margin: -0.75rem -0.9rem 0.7rem; padding: 0.4rem 0.9rem;
  background: var(--color-accent-soft); border-bottom: 1px solid var(--color-line-strong);
}
html[data-theme="sumi"] .card-title { font-size: 0.95rem; font-weight: 800; }
html[data-theme="sumi"] .stat-row { gap: 0; margin-bottom: 0.8rem; border: 1px solid var(--color-line-strong); background: var(--color-surface); }
html[data-theme="sumi"] .stat-card { border: none; border-right: 1px solid var(--color-line); padding: 0.5rem 0.8rem; }
html[data-theme="sumi"] .stat-num { font-size: 1.3rem; }
/* 表格：行距小、隔行变色、表头是一条深色 */
html[data-theme="sumi"] .table th, html[data-theme="sumi"] .table td { padding: 0.32rem 0.5rem; }
html[data-theme="sumi"] .table thead th {
  background: #2a2926; color: #f4f1e9; border-bottom: none; letter-spacing: 0.04em;
}
html[data-theme="sumi"] .table thead th a { color: inherit; }
/* 表头里的筛选框是白底的，字要回到深色（不然跟着表头变成浅字，看不见） */
html[data-theme="sumi"] .table thead th input, html[data-theme="sumi"] .table thead th select { color: #161514; }
html[data-theme="sumi"] .table tbody tr:nth-child(even) { background: rgb(22 21 20 / 0.035); }
html[data-theme="sumi"] .table tbody tr:hover { background: rgb(241 194 50 / 0.16); }
html[data-theme="sumi"] .btn { border-radius: 2px; padding: 0.36rem 0.85rem; }
html[data-theme="sumi"] .btn-small { padding: 0.18rem 0.6rem; }
html[data-theme="sumi"] .btn-primary { box-shadow: 2px 2px 0 #f1c232; }
html[data-theme="sumi"] .btn-primary:active { box-shadow: none; }
html[data-theme="sumi"] .badge, html[data-theme="sumi"] .chip { border-radius: 2px; }
html[data-theme="sumi"] input, html[data-theme="sumi"] select, html[data-theme="sumi"] textarea { border-radius: 2px; padding: 0.32rem 0.5rem; }
html[data-theme="sumi"] input:focus, html[data-theme="sumi"] select:focus, html[data-theme="sumi"] textarea:focus {
  box-shadow: 2px 2px 0 #f1c232;
}
/* 强调色是黑的，「要办的」数字和普通数字就分不出来了：这一处用深金色 */
html[data-theme="sumi"] .sale-tile.is-todo .chip-count { color: #8f6400; }

/* ============================================================
   嫩绿 · 宽松
   ============================================================ */
html[data-theme="wakaba"] {
  --color-paper: #f1f6f2;
  --color-surface: #ffffff;
  --color-ink: #1d2a24;
  --color-ink-soft: #60706a;
  --color-line: #e3ebe6;
  --color-line-strong: #c6d5cc;
  --color-accent: #0f7a5c;
  --color-accent-deep: #0a5a44;
  --color-accent-soft: #dff3ea;
  --color-accent-edge: #b5ddcb;
  --accent-rgb: 15 122 92;
  --color-bar: #cfe3d8;
  --color-bar-hover: #a9cdbb;
  --radius: 18px;
  --shadow-card: 0 2px 4px rgb(29 42 36 / 0.04), 0 16px 38px rgb(29 42 36 / 0.07);
}
/* 标题用圆体（没有的机器退回正文的黑体） */
html[data-theme="wakaba"] { --font-serif: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
html[data-theme="wakaba"][lang="zh"] { --font-serif: "Yuanti SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
html[data-theme="wakaba"] body {
  font-size: 16px; line-height: 1.75;
  background:
    radial-gradient(900px 420px at 8% -8%, rgb(var(--accent-rgb) / 0.09), transparent 62%),
    radial-gradient(700px 360px at 96% 4%, rgb(214 190 96 / 0.1), transparent 60%),
    var(--color-paper);
}
/* 页头钉在默认字号：正文放大了，导航不能跟着变宽（断点是按默认字号量的） */
html[data-theme="wakaba"] .site-header {
  font-size: 15px; line-height: 1.65;
  border-bottom: none; box-shadow: 0 1px 0 var(--color-line), 0 8px 24px rgb(29 42 36 / 0.05);
}
html[data-theme="wakaba"] .brand-mark { border-radius: 50%; box-shadow: none; }
/* 正文居中成一栏，两边留白 */
html[data-theme="wakaba"] .page { max-width: 1360px; margin: 0 auto; padding-top: 2.2rem; padding-bottom: 5rem; }
/* 页面标题是一条色带 */
html[data-theme="wakaba"] .page-head {
  align-items: center; margin-bottom: 2rem; padding: 1.6rem 2rem;
  border-radius: 24px;
  background: linear-gradient(120deg, rgb(var(--accent-rgb) / 0.14), rgb(214 190 96 / 0.14));
}
html[data-theme="wakaba"] .page-head h1 { font-size: 2.1rem; margin: 0.15rem 0 0.3rem; }
html[data-theme="wakaba"] .card, html[data-theme="wakaba"] .stat-card { border-color: transparent; }
html[data-theme="wakaba"] .card { padding: 1.8rem 2rem; }
html[data-theme="wakaba"] .card-title { font-size: 1.2rem; margin-bottom: 1.2rem; padding-bottom: 0.8rem; border-bottom-style: dashed; }
html[data-theme="wakaba"] .stat-row { gap: 1.1rem; margin-bottom: 2rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
html[data-theme="wakaba"] .stat-card { padding: 1.3rem 1.5rem; border-radius: 20px; box-shadow: var(--shadow-card); }
html[data-theme="wakaba"] .stat-num { font-size: 2.2rem; color: var(--color-accent-deep); }
html[data-theme="wakaba"] .table th, html[data-theme="wakaba"] .table td { padding: 0.85rem 0.75rem; }
html[data-theme="wakaba"] .btn { padding: 0.6rem 1.3rem; }
html[data-theme="wakaba"] .btn-small { padding: 0.3rem 0.9rem; }
html[data-theme="wakaba"] .btn-primary { box-shadow: 0 6px 16px rgb(var(--accent-rgb) / 0.28); }
html[data-theme="wakaba"] input, html[data-theme="wakaba"] select, html[data-theme="wakaba"] textarea { border-radius: 12px; padding: 0.6rem 0.85rem; }
