/* ===== 档案储存 · 极简黑白主题 ===== */

/* --- 亮色模式（默认） --- */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #888888;
  --border: #000000;
  --card-bg: #ffffff;
  --hover-bg: #000000;
  --hover-fg: #ffffff;
  --overlay: rgba(0,0,0,0.3);
  --quote-bg: #f5f5f5;
  --shadow: none;
}

/* --- 暗色模式（跟随系统） --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #ffffff;
    --muted: #666666;
    --border: #ffffff;
    --card-bg: #000000;
    --hover-bg: #ffffff;
    --hover-fg: #000000;
    --overlay: rgba(255,255,255,0.15);
    --quote-bg: #1a1a1a;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

/* ===== 屏幕系统 ===== */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  animation: fadein 0.4s ease;
}

.screen.active {
  display: block;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 开头过渡页 ===== */
[data-screen="splash"] {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

[data-screen="splash"].active {
  display: flex;
}

.splash-inner {
  text-align: center;
  padding: 40px;
}

.splash-line {
  width: 1px;
  height: 40px;
  background: var(--border);
  margin: 0 auto;
  animation: linegrow 0.8s ease;
}

@keyframes linegrow {
  from { height: 0; }
  to { height: 40px; }
}

.splash-label {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin: 24px 0 12px;
  text-transform: uppercase;
}

.splash-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.splash-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 32px;
}

.splash-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

/* ===== 按钮 ===== */
.btn-solid, .btn-outline, .btn-mini, .btn-back, .btn-close {
  border: 1px solid var(--border);
  background: var(--border);
  color: var(--bg);
  padding: 8px 20px;
  font-size: 14px;
  transition: all 0.15s;
}

.btn-solid:hover, .btn-outline:hover {
  background: var(--bg);
  color: var(--fg);
}

.btn-outline {
  background: transparent;
  color: var(--fg);
}

.btn-outline:hover {
  background: var(--fg);
  color: var(--bg);
}

.btn-mini {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 5px 12px;
  font-size: 13px;
}

.btn-mini:hover {
  background: var(--fg);
  color: var(--bg);
}

.btn-back {
  border: none;
  background: transparent;
  color: var(--fg);
  padding: 4px 8px;
  font-size: 15px;
}

.btn-back:hover {
  text-decoration: underline;
}

.btn-close {
  border: none;
  background: transparent;
  color: var(--fg);
  padding: 4px 8px;
  font-size: 16px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.layer-hint {
  padding: 8px 20px;
  font-size: 12px;
  color: var(--muted);
}

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  max-width: 900px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.search-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  font-size: 14px;
  outline: none;
  transition: border-width 0.15s;
}

.search-bar input:focus {
  border-width: 2px;
}

.search-bar input::placeholder {
  color: var(--muted);
}

/* ===== 卡片区 ===== */
.card-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  max-width: 900px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card:hover {
  background: var(--hover-bg);
  color: var(--hover-fg);
}

.card:hover .card-meta {
  color: var(--hover-fg);
  opacity: 0.7;
}

.card-num {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.card:hover .card-num {
  color: var(--hover-fg);
  opacity: 0.7;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.card-summary {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card:hover .card-summary {
  color: var(--hover-fg);
  opacity: 0.7;
}

.card-meta {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: auto;
}

/* ===== 过渡页 ===== */
[data-screen="transition"] {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

[data-screen="transition"].active {
  display: flex;
}

.trans-inner {
  text-align: center;
  padding: 40px;
}

.trans-bar {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 auto 24px;
  animation: barpulse 1s ease infinite alternate;
}

@keyframes barpulse {
  from { width: 20px; opacity: 0.4; }
  to { width: 60px; opacity: 1; }
}

.trans-label {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 12px;
}

.trans-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.trans-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ===== 读取页 ===== */
[data-screen="reader"] {
  padding-bottom: 60px;
}

.reader-paper {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px;
}

.reader-paper h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.reader-source {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 24px;
}

/* --- 文档分段 --- */
.doc-section {
  margin-bottom: 28px;
}

.doc-section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid var(--border);
  scroll-margin-top: 60px;
}

.doc-section-title.sub {
  font-size: 15px;
  font-weight: 600;
  border-left-width: 2px;
}

/* --- 内容块 --- */
.block-paragraph {
  margin: 8px 0;
  line-height: 1.8;
  font-size: 14px;
}

.block-list {
  margin: 8px 0;
  padding-left: 20px;
}

.block-list li {
  list-style: none;
  margin: 4px 0;
  font-size: 14px;
  line-height: 1.7;
  position: relative;
  padding-left: 14px;
}

.block-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  font-weight: 700;
}

.block-list.ordered li::before {
  content: '';
}

.block-list.ordered {
  counter-reset: item;
  padding-left: 0;
}

.block-list.ordered li {
  counter-increment: item;
  padding-left: 24px;
}

.block-list.ordered li::before {
  content: counter(item);
  position: absolute;
  left: 0;
  top: 0;
  font-size: 12px;
  font-weight: 700;
  width: 18px;
  text-align: right;
}

.block-quote {
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--quote-bg);
  border-left: 3px solid var(--border);
  font-size: 14px;
  line-height: 1.7;
}

.block-image {
  margin: 12px 0;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
}

/* ===== 左滑目录 ===== */
.toc-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toc-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 16px 0;
}

.toc-drawer.open {
  transform: translateX(0);
}

.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.toc-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.toc-nav {
  padding: 0 8px;
}

.toc-nav a {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: all 0.1s;
  line-height: 1.4;
}

.toc-nav a:hover {
  background: var(--fg);
  color: var(--bg);
  padding-left: 16px;
}

.toc-nav a.sub {
  padding-left: 24px;
  font-size: 12px;
  color: var(--muted);
}

.toc-edge {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  background: var(--border);
  color: var(--bg);
  padding: 12px 4px;
  font-size: 11px;
  writing-mode: vertical-rl;
  letter-spacing: 0.2em;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toc-edge:hover {
  opacity: 1;
}

/* ===== 编辑弹窗 ===== */
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 0;
  box-shadow: none;
}

dialog::backdrop {
  background: var(--overlay);
}

.editor-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.editor-mode {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
}

.editor-head h2 {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.editor-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--muted);
}

.field input, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  font-size: 14px;
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-width: 2px;
}

.field textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.6;
}

.editor-tools {
  margin-bottom: 12px;
}

.editor-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.editor-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 20px;
  background: var(--border);
  color: var(--bg);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 移动端 ===== */
@media (max-width: 600px) {
  .card-area {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .card {
    padding: 12px;
    min-height: 90px;
  }

  .card-title {
    font-size: 14px;
  }

  .splash-title {
    font-size: 32px;
  }

  .reader-paper {
    padding: 16px 14px;
  }

  .reader-paper h1 {
    font-size: 22px;
  }

  .topbar {
    padding: 10px 14px;
  }

  .search-bar {
    padding: 8px 12px;
  }
}

/* ===== 密码弹窗 ===== */
.pwd-dialog {
  text-align: center;
  padding: 32px 28px !important;
}

.pwd-dialog .pwd-icon {
  font-size: 28px;
  margin-bottom: 12px;
}

.pwd-dialog .pwd-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pwd-dialog .pwd-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.pwd-dialog .pwd-input-wrap {
  position: relative;
  margin-bottom: 16px;
}

.pwd-dialog .pwd-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--fg);
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.1em;
  outline: none;
  transition: border-width 0.15s;
}

.pwd-dialog .pwd-input:focus {
  border-width: 2px;
}

.pwd-dialog .pwd-input.error {
  border-color: #cc0000;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.pwd-dialog .pwd-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.pwd-dialog .pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
}

.pwd-dialog .pwd-toggle:hover {
  color: var(--fg);
}

/* ===== 大字母卡片标识 ===== */
.card-letter {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
  margin: 4px 0;
}
