/* ========================================
   SCHNIE 聊天 —— DeepSeek 风格界面
   ======================================== */

/* ---- 隐藏 radio ---- */
.records-radio {
  display: none;
}

/* ---- 页面容器 override ---- */
#content-inner:has(#records_page) {
  padding: 0 !important;
  max-width: 100% !important;
  background: transparent !important;
}
#page:has(#records_page) > .page-title {
  display: none;
}

/* ---- 横幅背景 ---- */
#records_page .page-top-card {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  z-index: -1;
  opacity: .06;
  background-size: cover;
  background-position: center;
  filter: blur(2px);
}

/* ========================================
   双栏容器 —— 四周留白，浮起圆角
   ======================================== */
.records-layout {
  display: flex;
  max-width: 1100px;
  height: calc(100vh - 60px - 36px);
  margin: 18px auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(0, 0, 0, .06);
}

/* ---- 左侧栏 ---- */
.records-sidebar {
  width: 260px;
  min-width: 260px;
  background: #f7f7f8;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.records-sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 14px;
  font-size: 1rem;
  font-weight: 700;
  color: #2b6cb0;
  letter-spacing: .02em;
}
.records-sidebar-header img {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.records-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  color: #444;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.records-sidebar-item:hover { background: #eaeaec; }
.records-sidebar-item:active { background: #dedee0; }

/* 选中态 */
#records-tab-0:checked ~ .records-sidebar label[for="records-tab-0"],
#records-tab-1:checked ~ .records-sidebar label[for="records-tab-1"],
#records-tab-2:checked ~ .records-sidebar label[for="records-tab-2"],
#records-tab-3:checked ~ .records-sidebar label[for="records-tab-3"],
#records-tab-4:checked ~ .records-sidebar label[for="records-tab-4"],
#records-tab-5:checked ~ .records-sidebar label[for="records-tab-5"],
#records-tab-6:checked ~ .records-sidebar label[for="records-tab-6"],
#records-tab-7:checked ~ .records-sidebar label[for="records-tab-7"],
#records-tab-8:checked ~ .records-sidebar label[for="records-tab-8"],
#records-tab-9:checked ~ .records-sidebar label[for="records-tab-9"] {
  background: #e3e3e5;
  color: #222;
  font-weight: 500;
}

/* ========================================
   主内容区
   ======================================== */
.records-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0;
}

.records-conv {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#records-tab-0:checked ~ .records-main #conv-0,
#records-tab-1:checked ~ .records-main #conv-1,
#records-tab-2:checked ~ .records-main #conv-2,
#records-tab-3:checked ~ .records-main #conv-3,
#records-tab-4:checked ~ .records-main #conv-4,
#records-tab-5:checked ~ .records-main #conv-5,
#records-tab-6:checked ~ .records-main #conv-6,
#records-tab-7:checked ~ .records-main #conv-7,
#records-tab-8:checked ~ .records-main #conv-8,
#records-tab-9:checked ~ .records-main #conv-9 {
  display: flex;
}

/* ---- 标题栏（sticky 固定）---- */
.records-conv-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.records-conv-title { font-size: 1.05rem; font-weight: 600; color: #222; }
.records-conv-subtitle {
  font-size: .78rem; color: #aaa;
  display: flex; align-items: center; gap: 4px;
}
.records-subtitle-icon { font-size: .75rem; color: #f0a500; }
.records-conv-time { font-size: .8rem; color: #aaa; margin-left: auto; }

/* ---- 消息区（不再独立滚动）---- */
.records-conv-messages {
  padding: 20px 0 40px;
  width: 100%;
}

/* ---- 消息行 ---- */
.records-msg {
  display: flex;
  align-items: flex-start;
  padding: 8px 5% 8px 3%;
  gap: 12px;
}

/* ---- AI 消息 ---- */
.records-ai { justify-content: flex-start; }
.records-ai .records-msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  object-fit: cover;
}
.records-ai .records-msg-bubble {
  max-width: 85%;
  background: transparent;
  padding: 4px 0;
}
.records-ai .records-msg-bubble p {
  color: #333;
  margin: 0;
  line-height: 1.72;
  font-size: .93rem;
  word-break: break-word;
  overflow-wrap: break-word;
}
.records-ai .records-msg-bubble p + p { margin-top: .85em; }

/* ---- 粗体 & 列表项（📝 YAML 中 **text** 和 >text 语法）---- */
.records-ai .records-msg-bubble strong,
.records-user .records-msg-bubble strong,
.records-thinking-text strong {
  font-weight: 600;
  color: inherit;
}
.records-list-item {
  position: relative;
  padding-left: 1.2em !important;
  margin: 0 !important;
}
.records-list-item::before {
  content: '';
  position: absolute;
  left: 0; top: .58em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #c0c0c0;
}
.records-ai .records-msg-bubble .records-list-item { color: #555; }
.records-user .records-msg-bubble .records-list-item { color: #2a3a5e; }
.records-thinking-text .records-list-item::before { background: #bbb; }

/* ---- 用户消息 ---- */
.records-user { justify-content: flex-end; }
.records-user .records-msg-bubble {
  max-width: 85%;
  background: #eaf1fb;
  border-radius: 14px 4px 14px 14px;
  padding: 10px 16px;
}
.records-user .records-msg-bubble p {
  color: #1a1a2e;
  margin: 0;
  line-height: 1.65;
  font-size: .93rem;
  word-break: break-word;
  overflow-wrap: break-word;
}
.records-user .records-msg-bubble p + p { margin-top: .6em; }

/* ---- 动画 ---- */
.records-msg { animation: msgIn .35s ease-out; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.records-ai + .records-ai,
.records-user + .records-user { padding-top: 2px; }
.records-ai + .records-user,
.records-user + .records-ai { padding-top: 24px; }

/* ========================================
   思考模式 —— 可折叠灰色区块
   ======================================== */
.records-thinking {
  margin-bottom: 12px;
}

/* 去默认三角形 */
.records-thinking summary::-webkit-details-marker { display: none; }
.records-thinking summary::marker { display: none; content: ''; }
.records-thinking summary { list-style: none; }

.records-thinking summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 0 4px;
  font-size: .82rem;
  color: #999;
  user-select: none;
  outline: none;
  transition: color .2s;
}
.records-thinking summary:hover { color: #777; }

.records-thinking-time {
  color: #888;
}

/* 下拉箭头 */
.records-thinking-arrow {
  display: inline-block;
  width: 14px; height: 14px;
  position: relative;
  margin-left: 2px;
  transition: transform .25s;
}
.records-thinking-arrow::after {
  content: '';
  position: absolute;
  top: 4px; left: 3px;
  width: 6px; height: 6px;
  border-right: 1.5px solid #bbb;
  border-bottom: 1.5px solid #bbb;
  transform: rotate(-45deg);
}
/* 展开时箭头向下 */
.records-thinking[open] > summary > .records-thinking-arrow {
  transform: rotate(90deg);
}

/* 思考内容 —— flex 两栏：gutter（点+线）+ 文本 */
.records-thinking-content {
  display: flex;
  margin-top: 6px;
  gap: 0;
}

/* 左侧固定栏：圆点 + 竖线 */
.records-thinking-gutter {
  width: 16px;
  min-width: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.records-thinking-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #c0c0c0;
  margin-top: 5px;
  flex-shrink: 0;
}

.records-thinking-line {
  width: 2px;
  background: #e0e0e0;
  margin-top: 4px;
  flex: 1;
  min-height: 8px;
}

/* 右侧文本区 */
.records-thinking-text {
  flex: 1;
  min-width: 0;
  padding-right: 4px;
}
.records-thinking-text p {
  font-size: .85rem !important;
  color: #999 !important;
  line-height: 1.65 !important;
  margin: 0 !important;
}
.records-thinking-text p + p { margin-top: .6em !important; }

/* ========================================
   暗色模式
   ======================================== */
[data-theme="dark"] #records_page .page-top-card { opacity: .04; }

[data-theme="dark"] .records-layout {
  box-shadow: 0 4px 32px rgba(0, 0, 0, .3);
}

[data-theme="dark"] .records-sidebar {
  background: #1a1a1e;
  border-right-color: #2a2a2e;
}
[data-theme="dark"] .records-sidebar-header { color: #5b9bd5; }
[data-theme="dark"] .records-sidebar-item { color: #bbb; }
[data-theme="dark"] .records-sidebar-item:hover { background: #242428; }
[data-theme="dark"] .records-sidebar-item:active { background: #2a2a2e; }

[data-theme="dark"] #records-tab-0:checked ~ .records-sidebar label[for="records-tab-0"],
[data-theme="dark"] #records-tab-1:checked ~ .records-sidebar label[for="records-tab-1"],
[data-theme="dark"] #records-tab-2:checked ~ .records-sidebar label[for="records-tab-2"],
[data-theme="dark"] #records-tab-3:checked ~ .records-sidebar label[for="records-tab-3"],
[data-theme="dark"] #records-tab-4:checked ~ .records-sidebar label[for="records-tab-4"],
[data-theme="dark"] #records-tab-5:checked ~ .records-sidebar label[for="records-tab-5"],
[data-theme="dark"] #records-tab-6:checked ~ .records-sidebar label[for="records-tab-6"],
[data-theme="dark"] #records-tab-7:checked ~ .records-sidebar label[for="records-tab-7"],
[data-theme="dark"] #records-tab-8:checked ~ .records-sidebar label[for="records-tab-8"],
[data-theme="dark"] #records-tab-9:checked ~ .records-sidebar label[for="records-tab-9"] {
  background: #2a2a2e; color: #eee;
}

[data-theme="dark"] .records-main { background: #212327; }

[data-theme="dark"] .records-conv-header {
  background: #1e1e20;
  border-color: #2a2a2c;
}
[data-theme="dark"] .records-conv-title { color: #eee; }
[data-theme="dark"] .records-conv-subtitle,
[data-theme="dark"] .records-conv-time { color: #666; }
[data-theme="dark"] .records-subtitle-icon { color: #e0a800; }

[data-theme="dark"] .records-ai .records-msg-bubble p { color: #ddd; }
[data-theme="dark"] .records-ai .records-msg-bubble .records-list-item { color: #aaa; }
[data-theme="dark"] .records-user .records-msg-bubble { background: #1e3a5f; }
[data-theme="dark"] .records-user .records-msg-bubble p { color: #dce4f5; }

[data-theme="dark"] .records-thinking-arrow::after { border-color: #666; }
[data-theme="dark"] .records-thinking-dot { background: #555; }
[data-theme="dark"] .records-thinking-line { background: #333; }
[data-theme="dark"] .records-user .records-msg-bubble .records-list-item { color: #aab8d4; }
[data-theme="dark"] .records-list-item::before { background: #555; }
[data-theme="dark"] .records-hamburger-icon { background: #aaa; }
[data-theme="dark"] .records-thinking-text p { color: #777 !important; }

/* ========================================
   响应式
   ======================================== */

/* ---- 汉堡菜单（默认隐藏，移动端显示）---- */
.records-hamburger-check { display: none; }
.records-overlay { display: none; }
.records-hamburger-btn {
  display: none;
  flex-shrink: 0;
  width: 28px; height: 28px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
  cursor: pointer;
  margin-right: 2px;
}

/* ---- 平板 / 小屏桌面 ---- */
@media screen and (max-width: 900px) {
  .records-layout {
    margin: 10px;
    height: calc(100vh - 60px - 20px);
  }
  .records-sidebar {
    width: 200px;
    min-width: 200px;
  }
}

/* ---- iPad / 竖屏平板 ---- */
@media screen and (max-width: 768px) {
  .records-layout {
    margin: 0;
    height: calc(100vh - 60px);
    border-radius: 0;
    box-shadow: none;
  }
  .records-sidebar {
    width: 170px;
    min-width: 170px;
  }
  .records-sidebar-header { padding: 16px 12px 10px; font-size: .9rem; }
  .records-sidebar-header img { width: 24px; height: 24px; }
  .records-sidebar-item { padding: 8px 12px; font-size: .82rem; margin: 1px 4px; }

  .records-conv-header {
    padding: 10px 14px 8px;
    flex-wrap: wrap;
    gap: 4px 8px;
  }
  .records-conv-title { font-size: .95rem; }
  .records-conv-time { font-size: .72rem; }

  .records-msg { padding: 6px 3% 6px 2%; gap: 8px; }
  .records-user .records-msg-bubble { max-width: 90%; padding: 8px 12px; }
  .records-ai .records-msg-avatar { width: 26px; height: 26px; margin-top: 0; }
  .records-ai .records-msg-bubble p,
  .records-user .records-msg-bubble p { font-size: .87rem; line-height: 1.6; }
  .records-ai .records-msg-bubble p + p { margin-top: .65em; }
  .records-user .records-msg-bubble p + p { margin-top: .45em; }

  .records-thinking-gutter { width: 14px; min-width: 14px; }
}

/* ---- 手机横屏 / 大屏手机（启用汉堡菜单）---- */
@media screen and (max-width: 600px) {
  /* ---- 汉堡按钮（内嵌在标题栏左侧）---- */
  .records-hamburger-btn {
    display: flex;
    width: 26px; height: 26px;
    gap: 4px;
  }
  .records-hamburger-icon {
    display: block;
    width: 16px; height: 2px;
    background: #555;
    border-radius: 1px;
    transition: transform .25s ease, opacity .25s ease;
  }
  /* 点击时三条线变形为 X */
  #records-hamburger:checked ~ .records-layout .records-hamburger-btn .records-hamburger-icon:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  #records-hamburger:checked ~ .records-layout .records-hamburger-btn .records-hamburger-icon:nth-child(2) {
    opacity: 0;
  }
  #records-hamburger:checked ~ .records-layout .records-hamburger-btn .records-hamburger-icon:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* ---- 遮罩 ---- */
  .records-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, .35);
    animation: recordsFadeIn .25s ease;
  }
  #records-hamburger:checked ~ .records-overlay {
    display: block;
  }

  @keyframes recordsFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* ---- 侧栏变抽屉 ---- */
  .records-layout {
    position: relative;
  }
  .records-sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    width: 260px !important;
    min-width: 260px !important;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 0 0 24px rgba(0, 0, 0, .15);
    border-right: 1px solid #e5e5e5;
  }
  #records-hamburger:checked ~ .records-layout .records-sidebar {
    transform: translateX(0);
  }

  /* ---- 侧栏 header ---- */
  .records-sidebar-header {
    justify-content: flex-start;
    padding: 16px 14px 12px;
    font-size: 1rem;
  }
  .records-sidebar-header img { display: none; }

  /* ---- 侧栏列表项回正常宽 ---- */
  .records-sidebar-item {
    justify-content: flex-start;
    padding: 10px 14px;
    margin: 1px 6px;
    font-size: .85rem;
    border-radius: 6px;
  }
  .records-sidebar-text { display: block; }

  /* ---- 主内容区 ---- */
  .records-conv-header { padding: 10px 16px 8px; }
  .records-conv-subtitle { font-size: .72rem; }
  .records-msg { padding: 10px 7% 10px 6%; gap: 8px; }
  .records-user .records-msg-bubble { max-width: 80%; border-radius: 12px 4px 12px 12px; padding: 8px 12px; }
  .records-ai .records-msg-bubble p,
  .records-user .records-msg-bubble p { font-size: .85rem; line-height: 1.55; }

  .records-ai .records-msg-avatar { display: none; }

  .records-thinking summary { font-size: .76rem; }
  .records-thinking-text p { font-size: .78rem !important; }
}

/* ---- 手机竖屏（侧栏保持抽屉模式）---- */
@media screen and (max-width: 480px) {
  .records-layout { margin: 0; height: 100dvh; border-radius: 0; }

  .records-hamburger-btn {
    width: 24px; height: 24px;
    gap: 3px;
  }
  .records-hamburger-icon { width: 14px; }

  /* 侧栏高度撑满 */
  .records-sidebar {
    height: 100dvh;
    width: 260px !important;
    min-width: 260px !important;
  }

  .records-sidebar-header {
    padding: 14px 14px 10px;
    font-size: 1rem;
  }
  .records-sidebar-header img { display: none; }
  .records-sidebar-item {
    padding: 10px 14px;
    font-size: .85rem;
  }
  .records-sidebar-text { display: block; }

  .records-conv-header {
    padding: 10px 14px 8px;
    gap: 6px;
  }
  .records-conv-title { font-size: .9rem; }
  .records-conv-time { font-size: .7rem; }
  .records-conv-subtitle { font-size: .7rem; }

  .records-msg { padding: 12px 8% 12px 7%; gap: 6px; }
  .records-user .records-msg-bubble { max-width: 78%; padding: 8px 10px; border-radius: 10px 3px 10px 10px; }
  .records-ai .records-msg-avatar { display: none; }
  .records-ai .records-msg-bubble p,
  .records-user .records-msg-bubble p { font-size: .82rem; line-height: 1.5; }

  .records-ai + .records-user,
  .records-user + .records-ai { padding-top: 18px; }

  .records-thinking summary { font-size: .74rem; }
  .records-thinking-text p { font-size: .76rem !important; }
  .records-thinking-gutter { width: 12px; min-width: 12px; }
  .records-thinking-dot { width: 5px; height: 5px; }
  .records-thinking-line { width: 1.5px; }
}

/* ---- 超小屏手机 ---- */
@media screen and (max-width: 360px) {
  .records-sidebar {
    width: 240px !important;
    min-width: 240px !important;
  }
  .records-sidebar-header { font-size: .92rem; }
  .records-sidebar-header img { display: none; }
  .records-sidebar-item { padding: 9px 14px; font-size: .82rem; }
  .records-sidebar-text { display: block; }

  .records-hamburger-btn {
    width: 22px; height: 22px;
    gap: 3px;
  }
  .records-hamburger-icon { width: 13px; }

  .records-conv-header { padding: 8px 12px 6px; }
  .records-conv-title { font-size: .85rem; }
  .records-conv-time { font-size: .66rem; }

  .records-conv-messages { padding: 12px 0 30px; }
  .records-msg { padding: 8px 9% 8px 8%; gap: 4px; }
  .records-user .records-msg-bubble { max-width: 82%; padding: 6px 8px; border-radius: 8px 3px 8px 8px; }
  .records-ai .records-msg-avatar { display: none; }
  .records-ai .records-msg-bubble p,
  .records-user .records-msg-bubble p { font-size: .8rem; line-height: 1.48; }
  .records-ai .records-msg-bubble p + p { margin-top: .5em; }
  .records-user .records-msg-bubble p + p { margin-top: .3em; }

  .records-thinking summary { font-size: .72rem; }
  .records-thinking-text p { font-size: .74rem !important; }
  .records-thinking-gutter { width: 10px; min-width: 10px; }
}
