/*
 * files.1mb.tech 前端样式：中文、米白背景、系统字体、低动效。
 * 无外部字体、无 CDN、无图标库。
 */

:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #efe9dc;
  --ink: #2b2721;
  --muted: #6f675b;
  --line: #e0d8c8;
  --accent: #3f6b52;
  --accent-ink: #ffffff;
  --accent-soft: #e4ede5;
  --danger: #a8442f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(43, 39, 33, 0.06), 0 8px 24px rgba(43, 39, 33, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --surface: #262320;
    --surface-2: #322e29;
    --ink: #f0ece3;
    --muted: #a99f8f;
    --line: #3a352e;
    --accent: #8fbd9d;
    --accent-ink: #10231a;
    --accent-soft: #2c3a30;
    --danger: #e08a74;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC",
    Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

main {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 20px 56px;
}

/* ---------------------------------------------------------------- */
/* 页头                                                              */
/* ---------------------------------------------------------------- */

header {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.fine {
  font-size: 0.82rem;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- */
/* 状态栏                                                            */
/* ---------------------------------------------------------------- */

#status {
  min-height: 1.6em;
  margin: 0 0 16px;
  font-size: 0.92rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

#status:empty {
  display: none;
}

#status.is-error {
  color: var(--danger);
  font-weight: 600;
}

/* ---------------------------------------------------------------- */
/* 卡片                                                              */
/* ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 0 20px;
  box-shadow: var(--shadow);
}

.card > :last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------- */
/* 按钮与链接按钮                                                    */
/* ---------------------------------------------------------------- */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:hover,
.button:hover {
  filter: brightness(1.06);
}

button:active,
.button:active {
  filter: brightness(0.96);
}

button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

button.quiet,
.button.secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}

button.quiet:hover,
.button.secondary:hover {
  filter: none;
  background: var(--accent-soft);
}

/* ---------------------------------------------------------------- */
/* 表单                                                              */
/* ---------------------------------------------------------------- */

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input[type="file"] {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

progress {
  display: block;
  width: 100%;
  height: 10px;
  margin: 12px 0 4px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

/* ---------------------------------------------------------------- */
/* 文件列表                                                          */
/* ---------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

/* 登录后让文件区占据主体，品牌保留为紧凑页头。 */
body.is-authenticated main {
  max-width: 1040px;
  padding-top: 24px;
}

body.is-authenticated header {
  margin-bottom: 12px;
}

body.is-authenticated header h1,
body.is-authenticated header > .muted {
  display: none;
}

.toolbar h2 {
  margin: 0;
}

.toolbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.upload-controls {
  margin: 0;
  width: 112px;
}

.upload-controls button {
  width: 100%;
}

input[type="file"][hidden] {
  display: none;
}

#file-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.file-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.file-item:last-child {
  border-bottom: none;
}

.file-info {
  flex: 1 1 12rem;
  min-width: 0;
}

.file-name {
  margin: 0 0 4px;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.file-meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.file-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.file-actions .button,
.file-actions button {
  min-height: 40px;
  padding: 8px 14px;
}

/* ---------------------------------------------------------------- */
/* 页脚                                                              */
/* ---------------------------------------------------------------- */

footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------- */
/* 无障碍与动效                                                      */
/* ---------------------------------------------------------------- */

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

@media (prefers-reduced-motion: no-preference) {
  button,
  .button {
    transition: filter 120ms ease, background-color 120ms ease;
  }
}

/* 小屏：动作按钮占满整行，避免挤压文件名导致横向溢出。 */
@media (max-width: 460px) {
  main {
    padding: 28px 16px 44px;
  }

  .file-item {
    align-items: stretch;
  }

  .file-actions {
    flex: 1 1 100%;
  }

  .file-actions .button,
  .file-actions button {
    flex: 1 1 auto;
  }

  .card button,
  .card .button {
    width: 100%;
  }
}
