/* ============================================================================
 *  OpenList 轨道风主题 · OO Line 19 回忆相片库
 *  app.orangray.top/pan/  ←  nginx sub_filter 注入
 *
 *  设计语言：CRT / JR East 信息导视（与 orangray.top/design-system 同构）
 *  主色：CRT 19 号线「远黛蓝」PT2935C #0047BB（OO 的年龄线）
 *  辅色：环线柠檬黄 PT130C #F5C400（仍在关联的人）
 *
 *  ⚠️ OpenList v4 前端 = SolidJS + Hope UI（stitches 运行时注入）。
 *     运行时样式带 hash 类名且后于本文件加载，所以这里只做：
 *     1) CSS 自定义属性层面的 token 覆盖（!important 兜底）
 *     2) 结构性、外观性覆盖（背景、圆角、字体、滚动条、选中色）
 *     3) 精准选择器留给 pan-theme.js 在 DOM 挂载后补刀
 *  ========================================================================== */

:root {
  /* ---- 轨道风 tokens（与 design-system/tokens.css 对齐） ---- */
  --l19-navy: #0047BB;         /* CRT 19 号线 远黛蓝 PT2935C */
  --l19-navy-deep: #003A96;
  --l19-loop: #F5C400;         /* 环线 柠檬黄 PT130C */
  --l19-paper: #FAF6EC;        /* 和纸底 */
  --l19-ink: #1A1A18;          /* 墨 */
  --l19-rail: #1A1A18;         /* 描边黑 */
  --l19-surface: #FFFFFF;
  --l19-muted: #6B6B66;

  /* ---- 覆盖 OpenList 站点主色（public.settings.main_color 的消费端） ---- */
  --hope-colors-primary9: var(--l19-navy) !important;
  --hope-colors-primary10: var(--l19-navy) !important;
  --hope-colors-primary11: var(--l19-navy-deep) !important;
  --hope-colors-info9: var(--l19-navy) !important;
  --hope-colors-info10: var(--l19-navy) !important;
  --hope-colors-info11: var(--l19-navy-deep) !important;
}

/* ---- 全局：和纸底 + 墨色描边基调 ---------------------------------------- */
html,
body {
  background: var(--l19-paper) !important;
  color: var(--l19-ink) !important;
}

body {
  font-family: "SF Pro SC", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Source Han Sans SC", -apple-system, "Segoe UI", sans-serif !important;
}

::selection {
  background: var(--l19-navy);
  color: #fff;
}

/* ---- 滚动条：轨道感细杆 -------------------------------------------------- */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--l19-navy) 55%, var(--l19-paper));
  border: 3px solid var(--l19-paper);
  border-radius: 5px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--l19-navy);
}

/* ---- 顶部导航：站牌化 ----------------------------------------------------
 * OpenList 头部由 Hope UI Portal 渲染，无稳定语义类；
 * 用层级 + 特征属性命中（post-MVP 若失效由 pan-theme.js 打标修正）。
 * -------------------------------------------------------------------------- */
#root > div > div:first-child,
nav {
  background: var(--l19-surface) !important;
  border-bottom: 2px solid var(--l19-rail) !important;
  backdrop-filter: none !important;
}

/* ---- 卡片 / 对象列表：白底黑框 ------------------------------------------
 * Hope UI 卡片普遍是大圆角浅灰底，改为轨道风硬边。
 * -------------------------------------------------------------------------- */
[class*="css-"] {
  scroll-margin-top: 5rem;
}

a {
  text-underline-offset: 0.25em;
}

/* 目录/文件行 hover：远黛蓝渐染 */
tr:hover,
[role="row"]:hover {
  background: color-mix(in srgb, var(--l19-navy) 7%, transparent) !important;
}

/* ---- 按钮：硬边化 -------------------------------------------------------- */
button {
  border-radius: 4px !important;
}

button[class*="primary"],
button[type="submit"] {
  background: var(--l19-navy) !important;
}

/* ---- 面包屑：线路区段化 --------------------------------------------------
 * 面包屑是「线路走向」的隐喻载体：分隔符换成线路箭头。
 * -------------------------------------------------------------------------- */
.hope-breadcrumb__separator,
[class*="breadcrumb"] svg {
  color: var(--l19-navy) !important;
}

[class*="breadcrumb"] a {
  color: var(--l19-ink) !important;
  font-weight: 600;
}

[class*="breadcrumb"] a:hover {
  color: var(--l19-navy) !important;
}

/* ---- README 预览区（markdown-body）：纸面排版 --------------------------- */
.markdown-body {
  color: var(--l19-ink) !important;
  font-size: 0.95rem !important;
  line-height: 1.75 !important;
}

.markdown-body h1,
.markdown-body h2 {
  border-bottom: 2px solid var(--l19-rail) !important;
  padding-bottom: 0.3em;
}

/* ---- 深色模式：轨道风是纸面语言，禁用 OpenList 深色 -------------------- */
.hope-ui-dark,
.hope-ui-dark body,
html.hope-ui-dark {
  background: var(--l19-paper) !important;
  color: var(--l19-ink) !important;
}

/* ★ obj-box：文件列表容器（诊断发现其深色底 rgb(32,36,37) 来自
 *   stitches 运行时注入的深色变量，hope-ui-dark class 移除也拦不住，
 *   因为样式在 class 移除前已按深色编译）。直接纸面覆盖。 */
.obj-box,
.obj-box[class*="css-"],
[class*="obj-box"] {
  background: var(--l19-surface) !important;
  color: var(--l19-ink) !important;
  border: 2px solid var(--l19-rail) !important;
  border-radius: 0 !important;
}

/* Hope UI 深色主题变量兜底：所有 hope-c-*-css 运行时类可能内联深色变量 */
:root,
html,
body {
  --hope-colors-neutral1: var(--l19-paper) !important;
  --hope-colors-neutral2: var(--l19-surface) !important;
  --hope-colors-neutral3: var(--l19-surface) !important;
  --hope-colors-neutral4: var(--l19-surface) !important;
  --hope-colors-neutral5: var(--l19-paper) !important;
  --hope-colors-neutral6: var(--l19-paper) !important;
  --hope-colors-neutral7: var(--l19-paper) !important;
  --hope-colors-neutral8: var(--l19-paper) !important;
  --hope-colors-neutral9: var(--l19-paper) !important;
  --hope-colors-neutral10: var(--l19-paper) !important;
  --hope-colors-neutral11: var(--l19-paper) !important;
  --hope-colors-neutral12: var(--l19-ink) !important;
  --hope-colors-background: var(--l19-paper) !important;
}

/* 行文本：墨色（深色变量残留会把行字变浅灰看不清） */
.obj-box a,
.list-item,
.name-box {
  color: var(--l19-ink) !important;
}

.hope-ui-dark .markdown-body {
  color: var(--l19-ink) !important;
}

/* OpenList 顶栏在深浅模式切换下的背景统一为纸面 */
[class*="css-"] header,
header[class*="css-"] {
  background: var(--l19-surface) !important;
}

/* 公告与登录入口等浮层的纸面化 */
[class*="hope-modal"],
[class*="hope-drawer"] {
  background: var(--l19-surface) !important;
  color: var(--l19-ink) !important;
  border: 2px solid var(--l19-rail) !important;
  border-radius: 0 !important;
}

/* ---- 站点目录行：CRT/JR 换乘站式站牌（pan-theme.js 渲染） -------------- */
.l19-station-row .l19-station__link {
  display: flex;
  align-items: center;
  /* Hope UI hope-stack 运行时样式把 gap 压成 normal(0)，
     必须 !important 才站得住（实测 gapFromBadge=0 压字） */
  gap: 0.75rem !important;
  text-decoration: none !important;
  color: inherit !important;
}

/* 换乘站名与徽章串布局：左站名右线群 */
.l19-station-row .l19-station__body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  min-width: 0;
  margin-left: 0.75rem;
}

.l19-station-row .l19-station__name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--l19-ink);
}

.l19-station-row:hover .l19-station__name {
  color: var(--l19-navy);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* 换乘徽章串：相识年线 → 19 逐线 + 环线（CRT 官方识别色） */
.l19-xfer {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
}

.l19-xfer__badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.2rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  border: 1px solid rgba(26, 26, 24, 0.55);
  border-radius: 3px;
}

.l19-xfer__badge--loop {
  background: var(--l19-loop) !important;
  color: var(--l19-ink) !important;
}

.l19-station-row .l19-station__note {
  flex-basis: 100%;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--l19-muted);
}

.l19-station-row:hover {
  background: color-mix(in srgb, var(--l19-loop) 16%, transparent) !important;
}

/* ---- 人名检索框（新组件：rt 系轨道风） ---------------------------------- */
#l19-pan-search {
  margin: var(--rt-space-4, 1rem) 0;
  max-width: 30rem;
}

#l19-pan-search .l19-search__label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--l19-muted);
}

#l19-pan-search .l19-search__bar {
  position: relative;
  display: flex;
  align-items: center;
  border: 2px solid var(--l19-rail);
  border-radius: 0;
  background: var(--l19-surface);
  box-shadow: 3px 3px 0 rgba(26, 26, 24, 0.85);
}

#l19-pan-search .l19-search__input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.9rem;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--l19-ink);
  font: inherit;
  font-size: 0.95rem;
}

#l19-pan-search .l19-search__input::placeholder {
  color: color-mix(in srgb, var(--l19-muted) 75%, transparent);
}

#l19-pan-search .l19-search__input:focus-visible {
  outline: 3px solid var(--l19-navy);
  outline-offset: 2px;
}

/* 右端轨道装饰：三段色轨（navy / loop / navy） */
#l19-pan-search .l19-search__line {
  display: inline-block;
  width: 3.2rem;
  height: 6px;
  margin-right: 0.7rem;
  background: linear-gradient(
    90deg,
    var(--l19-navy) 0 38%,
    var(--l19-loop) 38% 62%,
    var(--l19-navy) 62% 100%
  );
}

#l19-pan-search.l19-search--nohit .l19-search__bar {
  border-color: color-mix(in srgb, var(--l19-navy) 55%, var(--l19-rail));
}

#l19-pan-search.l19-search--nohit::after {
  content: "没有这个站 · 试试别的名字";
  display: block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--l19-muted);
}

/* ---- 顶栏字标（pan-theme.js 渲染，替代 OpenList 螺旋 logo） ------------- */
#l19-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#l19-logo .l19-logo__code {
  display: inline-grid;
  place-items: center;
  padding: 0.2rem 0.45rem;
  border: 2px solid var(--l19-ink);
  border-radius: 5px;
  background: var(--l19-loop);
  color: var(--l19-ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  box-shadow: 2px 2px 0 rgba(26, 26, 24, 0.85);
}

#l19-logo .l19-logo__text {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--l19-ink);
}

@media (max-width: 720px) {
  #l19-logo .l19-logo__text {
    display: none;
  }
}

/* ---- 相片预览画廊（pan-theme.js 渲染，站点目录内启用） ------------------ */
#l19-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 5rem;
  /* Hope UI hope-stack（flex column + align-items:center）会把块级子元素
     收缩到内容宽——画廊必须显式撑满 */
  width: 100%;
  align-self: stretch;
}

.l19-gal__card {
  position: relative;
  border: 2px solid var(--l19-rail);
  background: var(--l19-surface);
  box-shadow: 3px 3px 0 rgba(26, 26, 24, 0.85);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  overflow: hidden;
}

.l19-gal__card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 rgba(26, 26, 24, 0.85);
}

.l19-gal__card--sel {
  border-color: var(--l19-navy);
  outline: 3px solid var(--l19-navy);
  outline-offset: -1px;
}

.l19-gal__card--sel .l19-gal__check {
  opacity: 1;
  background: var(--l19-navy);
  color: #fff;
}

.l19-gal__imgbox {
  aspect-ratio: 1;
  background: color-mix(in srgb, var(--l19-paper) 60%, #fff);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.l19-gal__imgbox--err::after {
  content: "· 预览不可用 ·";
  font-size: 0.72rem;
  color: var(--l19-muted);
  letter-spacing: 0.1em;
}

.l19-gal__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.l19-gal__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-top: 2px solid var(--l19-rail);
  background: var(--l19-surface);
}

.l19-gal__name {
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--l19-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.l19-gal__size {
  flex: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.65rem;
  color: var(--l19-muted);
}

.l19-gal__check {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--l19-rail);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: transparent;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.l19-gal__card:hover .l19-gal__check {
  opacity: 1;
}

/* 下载关闭态：勾选圈不显示，光标回归默认（pan-theme.js body class 控制） */
body.l19-dl-closed .l19-gal__check {
  display: none;
}

body.l19-dl-closed .l19-gal__card {
  cursor: default;
}

body.l19-dl-closed .l19-gal__card:hover {
  transform: none;
  box-shadow: 3px 3px 0 rgba(26, 26, 24, 0.85);
}

/* ---- 画廊浮动工具条 ------------------------------------------------------ */
#l19-gal-toolbar {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 2147483645;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--l19-rail);
  background: var(--l19-surface);
  box-shadow: 3px 3px 0 rgba(26, 26, 24, 0.85);
}

.l19-gal__btn {
  padding: 0.4rem 0.85rem;
  border: 2px solid var(--l19-rail);
  border-radius: 0;
  background: var(--l19-surface);
  color: var(--l19-ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.l19-gal__btn:hover {
  background: color-mix(in srgb, var(--l19-loop) 30%, #fff);
}

.l19-gal__btn--primary {
  background: var(--l19-navy);
  border-color: var(--l19-navy-deep);
  color: #fff;
}

.l19-gal__btn--primary:hover {
  background: var(--l19-navy-deep);
}

.l19-gal__btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.l19-gal__count {
  min-width: 4.5em;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--l19-muted);
}

/* ---- 移动端：底部安全区 -------------------------------------------------- */
@media (max-width: 720px) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  #l19-pan-search {
    max-width: 100%;
  }

  #l19-pan-search .l19-search__line {
    width: 2rem;
  }

  /* 画廊：小屏两列，工具条贴底全宽 */
  #l19-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  #l19-gal-toolbar {
    left: 0.6rem;
    right: 0.6rem;
    transform: none;
    bottom: calc(0.6rem + env(safe-area-inset-bottom));
    padding: 0.5rem 0.6rem;
    gap: 0.4rem;
  }

  .l19-gal__btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.74rem;
  }

  .l19-gal__count {
    min-width: 0;
    flex: 1;
    font-size: 0.72rem;
  }
}

/* ============================================================================
 *  L19 徽章：pan-theme.js 在 header 位置插入的站牌
 *  ========================================================================== */
#l19-pan-sign {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 2147483646;
  display: flex;
  align-items: stretch;
  border: 2px solid var(--l19-rail);
  border-left: 0;
  border-bottom: 0;
  background: var(--l19-surface);
  box-shadow: 2px 2px 0 rgba(26, 26, 24, 0.85);
  font-family: "SF Pro SC", "PingFang SC", sans-serif;
  text-decoration: none;
  overflow: hidden;
}

#l19-pan-sign .l19-pan-sign__code {
  display: grid;
  place-items: center;
  min-width: 2.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--l19-navy);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  line-height: 1.2;
  text-align: center;
}

#l19-pan-sign .l19-pan-sign__text {
  display: grid;
  align-content: center;
  gap: 0.1rem;
  padding: 0.3rem 0.7rem 0.3rem 0.6rem;
}

#l19-pan-sign .l19-pan-sign__title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--l19-ink);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#l19-pan-sign .l19-pan-sign__sub {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--l19-muted);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

@media (max-width: 720px) {
  #l19-pan-sign .l19-pan-sign__sub {
    display: none;
  }
}
