/* 私人放映室 —— 纸张 / 衬线 / 朱红印章的编辑式视觉 */

:root {
  --paper: #f6f1e7;
  --paper-bright: #fffdf8;
  --ink: #17140f;
  --muted: #7a7264;
  --line: #ded5c4;
  --line-strong: #c9bda9;
  --accent: #d1502a;
  --accent-deep: #a83a1c;
  --accent-soft: #f6e2d9;
  --ok: #3f7d55;
  --shadow: 6px 8px 0 rgba(23, 20, 15, 0.055);
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 70% at 10% -10%, #fffdf8 0%, rgba(255, 253, 248, 0) 55%),
    repeating-linear-gradient(0deg, rgba(23, 20, 15, 0.016) 0 1px, transparent 1px 4px),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* 纸张颗粒 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E");
}

[hidden] {
  display: none !important;
}

em {
  font-style: normal;
  color: var(--accent);
}

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

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.02em;
}

h1 {
  margin: 6px 0 0;
  font-size: 25px;
  line-height: 1.2;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ---------- 登录 ---------- */
.gate {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.gate-card {
  width: min(396px, 100%);
  padding: 34px 26px 26px;
  background: var(--paper-bright);
  border: 1px solid var(--line-strong);
  box-shadow: 8px 10px 0 rgba(23, 20, 15, 0.06);
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.gate-card h1 {
  font-size: 32px;
  margin-bottom: 10px;
}

.gate-desc {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

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

.field span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary {
  width: 100%;
  padding: 13px 16px;
  background: var(--ink);
  color: var(--paper-bright);
  border: 0;
  border-radius: var(--radius);
  letter-spacing: 0.06em;
  transition: transform 0.15s, background 0.2s;
}

.primary:hover {
  background: #000;
}

.primary:active {
  transform: translateY(1px);
}

.primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.form-error {
  margin: 12px 0 0;
  min-height: 18px;
  color: var(--accent-deep);
  font-size: 12.5px;
}

/* ---------- 主框架 ---------- */
.shell {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 22px 18px 40px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-strong);
  animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.mast-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}

.stat {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

.ghost {
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}

.ghost:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* ---------- 上传 ---------- */
.drop {
  margin-top: 22px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 253, 248, 0.66);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  animation: rise 0.55s 0.05s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.drop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(0.995);
}

.drop-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 20px;
  cursor: pointer;
}

.drop-mark {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s, color 0.2s;
}

.drop.is-over .drop-mark,
.drop-inner:hover .drop-mark {
  background: var(--ink);
  color: var(--paper-bright);
  transform: rotate(90deg);
}

.drop-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
}

.drop-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 上传队列 ---------- */
.queue {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.queue:empty {
  display: none;
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px 14px;
  background: var(--paper-bright);
  border: 1px solid var(--line);
  animation: rise 0.35s both;
}

.queue-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-status {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.queue-status.is-error {
  color: var(--accent-deep);
}

.queue-status.is-done {
  color: var(--ok);
}

.queue-bar {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--line);
  overflow: hidden;
}

.queue-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s ease;
}

.queue-cancel {
  padding: 2px 6px;
  background: transparent;
  border: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
}

/* ---------- 档案库 ---------- */
.library {
  margin-top: 34px;
}

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

.lib-head h2 {
  margin: 0;
  font-size: 20px;
}

.chips {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(23, 20, 15, 0.045);
  border-radius: 999px;
}

.chip {
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}

.chip:hover {
  color: var(--ink);
}

.chip.is-active {
  background: var(--paper-bright);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(23, 20, 15, 0.12);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 0 16px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--paper-bright);
}

.search-row svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.search-row input {
  flex: 1;
  padding: 11px 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  background: var(--paper-bright);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.45s both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 9px 12px 0 rgba(23, 20, 15, 0.07);
}

.card-body {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #1b1712;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb.is-audio {
  display: grid;
  place-items: center;
  background:
    repeating-radial-gradient(circle at 50% 50%, #221c16 0 2px, #2d251d 2px 5px);
}

.thumb.is-audio::before {
  content: "";
  width: 46%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--paper-bright) 0 13%, transparent 14%),
    repeating-radial-gradient(circle at center, var(--ink) 0 2px, #2f271f 2px 5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.thumb.is-other {
  display: grid;
  place-items: center;
  background: #efe8db;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 26px;
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  background: rgba(23, 20, 15, 0.78);
  color: var(--paper-bright);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
}

.play-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--paper-bright);
  font-size: 13px;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.42));
  opacity: 0;
  transition: opacity 0.25s;
}

.card:hover .play-mark {
  opacity: 1;
}

.card-info {
  padding: 10px 11px 12px;
  border-top: 1px solid var(--line);
}

.card-title {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.card-meta {
  margin: 5px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.more {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 20, 15, 0.62);
  color: var(--paper-bright);
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover .more,
.more:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .more,
  .play-mark {
    opacity: 1;
  }
}

/* 空状态与加载 */
.empty {
  padding: 54px 10px;
  text-align: center;
  color: var(--muted);
}

.empty-frame {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border: 1px solid var(--line-strong);
  transform: rotate(-4deg);
}

.empty p {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
}

.empty span {
  font-size: 12px;
}

.loading {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 40px 0;
}

.loading span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  animation: pulse 1s infinite ease-in-out;
}

.loading span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading span:nth-child(3) {
  animation-delay: 0.3s;
}

.colophon {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 44px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- 预览 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(14, 12, 9, 0.94);
  padding: max(14px, env(safe-area-inset-top)) 0 env(safe-area-inset-bottom);
  animation: fade 0.25s both;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px 12px;
  color: rgba(255, 253, 248, 0.82);
  font-size: 12px;
}

.preview-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.28);
  border-radius: 50%;
  background: transparent;
}

.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.preview-stage {
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 0 12px 18px;
}

.preview-stage video,
.preview-stage img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
}

.preview-stage audio {
  width: min(520px, 100%);
}

/* ---------- 底部操作面板 ---------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(14, 12, 9, 0.42);
  animation: fade 0.2s both;
}

.sheet {
  width: min(460px, 100%);
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: var(--paper-bright);
  border-top: 1px solid var(--line-strong);
  animation: sheet-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.sheet-title {
  margin: 6px 8px 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet button {
  width: 100%;
  padding: 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-size: 14px;
}

.sheet button:active {
  background: var(--accent-soft);
}

.sheet .danger {
  color: var(--accent-deep);
}

.sheet .cancel {
  margin-top: 8px;
  border-top: 1px solid var(--line-strong);
  text-align: center;
  color: var(--muted);
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  max-width: min(440px, calc(100vw - 40px));
  background: var(--ink);
  color: var(--paper-bright);
  font-size: 12.5px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 动效 ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 桌面 ---------- */
@media (min-width: 620px) {
  .shell {
    padding: 34px 26px 48px;
  }

  h1 {
    font-size: 30px;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .drop-inner {
    padding: 30px 28px;
  }

  .drop-mark {
    width: 54px;
    height: 54px;
    font-size: 30px;
  }

  .drop-title {
    font-size: 19px;
  }
}

@media (min-width: 960px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
