/* 五个颜色变量构成全部配色，深浅色各一套。 */
:root {
  --bg: #fdfdfc;
  --fg: #1a1a19;
  --muted: #6b6b68;
  --border: #e4e4e1;
  --accent: #2f5d50;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* 系统偏好深色、但脚本尚未运行（还没有 data-theme 属性）时的兜底：
   避免在深色系统上出现"先白屏，initTheme() 跑完才变深色"的闪烁。
   一旦脚本显式设置了 data-theme="light"，这条规则就不再匹配，交还给
   上面的默认浅色 :root。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181a;
    --fg: #e8e8e6;
    --muted: #8b8f93;
    --border: #2a2d30;
    --accent: #7fb3a2;
  }
}

:root[data-theme="dark"] {
  --bg: #16181a;
  --fg: #e8e8e6;
  --muted: #8b8f93;
  --border: #2a2d30;
  --accent: #7fb3a2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

.view { max-width: 900px; margin: 0 auto; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- 登录 ---- */

#login-form {
  max-width: 20rem;
  margin: 12vh auto 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

#login-form label { color: var(--muted); font-size: .85rem; }

/* 全局简介：未配置时服务端会把占位符替换成空串，
   :empty 规则让空元素完全不占位，无需 JS 参与。
   pre-line 保留配置里写的换行。 */
#site-intro {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.7;
  white-space: pre-line;
}

#site-intro:empty { display: none; }

/* ---- 分享页 ---- */

#share-form {
  max-width: 22rem;
  margin: 12vh auto 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

#share-form label { color: var(--muted); font-size: .85rem; }

#share-file {
  margin: 0;
  font-family: var(--mono);
  font-size: .9rem;
  word-break: break-all;
}

#share-expires {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
}

#share-code {
  font-family: var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ---- 头部 ---- */

header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.site-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

#search { flex: 1; min-width: 6rem; }

/* ---- 表单控件 ---- */

input, button {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .35rem .6rem;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---- 面包屑 ---- */

#breadcrumb {
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: .5rem;
  word-break: break-all;
}

#breadcrumb a { color: var(--muted); }
#breadcrumb a:hover { color: var(--accent); }
#breadcrumb .sep { opacity: .5; padding: 0 .15rem; }

/* ---- 列表 ---- */

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  text-align: left;
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

thead th { border-bottom-width: 1px; padding: 0; }

thead button {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  padding: .4rem .5rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
}

thead button:hover { background: var(--border); color: var(--fg); }

/* 当前排序列：字重加粗、颜色转为主文字色，不用图标，与项目零视觉噪音的
   原则保持一致。 */
thead button.active { color: var(--fg); font-weight: 600; }

.sort-indicator { margin-left: .2rem; }

.col-size { width: 6.5rem; }
.col-time { width: 10.5rem; }
.col-act  { width: 7.5rem; }

td.size, td.time {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 文件类型标签：以小写扩展名文本代替图标，零视觉噪音。 */
.type {
  display: inline-block;
  width: 3.2em;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
  text-transform: lowercase;
  vertical-align: baseline;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

td.actions { text-align: right; }

td.actions button {
  border: 0;
  padding: .1rem .35rem;
  font-size: .78rem;
  color: var(--muted);
  background: transparent;
}

td.actions button:hover { color: var(--accent); }

/* 搜索结果视图下显示完整路径，字号更小 */
.path { color: var(--muted); font-size: .78rem; font-family: var(--mono); }

/* ---- 提示与统计 ---- */

.notice, .error {
  margin: 0 0 1rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  font-size: .85rem;
  color: var(--muted);
}

.error { color: var(--fg); }

#empty-state, #stats {
  color: var(--muted);
  font-size: .8rem;
  margin-top: 1rem;
}

/* ---- 预览 ---- */

#preview {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

#preview-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: min(900px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

#preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
}

#preview-name {
  font-family: var(--mono);
  font-size: .85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#preview-body {
  margin: 0;
  padding: .75rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
}

/* ---- 窄屏 ---- */

@media (max-width: 620px) {
  .col-time { display: none; }
  td.time { display: none; }
  .col-size { width: 5rem; }
  .col-act { width: 5.5rem; }
  header { flex-wrap: wrap; }
}
