:root {
  --paper: #f3eee6;
  --paper-deep: #e7e0d4;
  --card: #fbf8f3;
  --ink: #1c1916;
  --muted: #6f675e;
  --line: rgba(48, 36, 22, 0.14);
  --seal: #c4352b;
  --seal-dark: #8e241c;
  --moss: #1f6b4a;
  --shadow: 0 24px 60px rgba(62, 42, 20, 0.1);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(196, 53, 43, 0.09), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(31, 107, 74, 0.07), transparent 50%),
    var(--paper);
}

button, input { font: inherit; color: inherit; }

::selection { background: #f0c8c3; }

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 72px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.seal {
  flex: none;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--seal);
  border-radius: 8px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28), 0 10px 24px rgba(142, 36, 28, 0.25);
  font-family: "Songti SC", "STSong", "STZhongsong", "SimSun", serif;
  font-size: 40px;
  line-height: 1;
  transform: rotate(-8deg);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--seal-dark);
  font-size: 13px;
  letter-spacing: 0.18em;
}

h1, h2, .plate {
  font-family: "Songti SC", "STSong", "STZhongsong", "SimSun", serif;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.lede {
  max-width: 46em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.stats {
  display: flex;
  gap: 18px;
  margin: 0;
}

.stats div {
  min-width: 112px;
  padding: 14px 16px 12px;
  background: rgba(255, 252, 247, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.stats dd {
  margin: 4px 0 0;
  font-family: "Songti SC", "STSong", "STZhongsong", "SimSun", serif;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.drop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  border: 1.5px dashed rgba(28, 25, 22, 0.28);
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.66);
}

.drop.is-over {
  border-color: var(--seal);
  background: rgba(196, 53, 43, 0.07);
}

.drop h2 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
}

.drop p {
  margin: 0;
  max-width: 46em;
  color: var(--muted);
  line-height: 1.6;
}

.composer {
  margin-top: 16px;
  padding: 22px 24px 18px;
  background: rgba(255, 252, 247, 0.8);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.composer h2 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
}

.composer p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.field input,
.field textarea {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  outline: none;
}

.field textarea {
  min-height: 168px;
  resize: vertical;
  line-height: 1.65;
}

.field input:focus,
.field textarea:focus { border-color: rgba(28, 25, 22, 0.45); }

.composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

#note-count { color: var(--muted); font-size: 13px; }

.btn, .chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}

.btn:hover, .chip:hover { border-color: rgba(28, 25, 22, 0.35); }

.btn.primary {
  background: var(--ink);
  color: #f7f3ec;
  border-color: var(--ink);
}

.btn.primary:hover { background: #000; }

.btn.danger {
  color: var(--seal-dark);
  background: #fff;
}

.btn:disabled { opacity: 0.55; cursor: default; }

.queue {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.queue li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.queue .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue .state { color: var(--muted); font-size: 13px; }
.queue .state.ok { color: var(--moss); }
.queue .state.bad { color: var(--seal-dark); }

.queue progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  appearance: none;
  background: var(--paper-deep);
}

.queue progress::-webkit-progress-bar {
  background: var(--paper-deep);
  border-radius: 99px;
}

.queue progress::-webkit-progress-value {
  background: var(--seal);
  border-radius: 99px;
}

.queue progress::-moz-progress-bar {
  background: var(--seal);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip[aria-selected="true"] {
  background: var(--ink);
  color: #f7f3ec;
  border-color: var(--ink);
}

.search input {
  width: min(280px, 70vw);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.9);
  outline: none;
}

.search input:focus { border-color: rgba(28, 25, 22, 0.45); }

.result-line {
  min-height: 1.2em;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  cursor: pointer;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.thumb {
  height: 168px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.4), rgba(231, 224, 212, 0.85));
}

.thumb img {
  width: 100%;
  height: 168px;
  object-fit: contain;
  background: #f6f1e8;
}

.plate {
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 28px;
  letter-spacing: 0.06em;
}

.kind-image { background: #8c4a32; }
.kind-video { background: #243044; }
.kind-audio { background: #1f6b4a; }
.kind-pdf { background: #9d241c; }
.kind-doc { background: #7a4b2a; }
.kind-text { background: #4d463e; }
.kind-archive { background: #5c4a32; }
.kind-other { background: #3f3a34; }

body.modal-open { overflow: hidden; }

.offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
}

.card-body { padding: 12px 14px 14px; }

.card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 14px;
}

.card-actions .btn { padding: 7px 12px; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.more-row { display: flex; justify-content: center; margin-top: 18px; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 24, 20, 0.58);
}

.modal[hidden] { display: none; }

.dialog {
  width: min(920px, 100%);
  max-height: min(90vh, 920px);
  overflow: auto;
  padding: 18px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.dialog-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.dialog-heading { min-width: 0; }

.dialog h2 {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 22px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.stage {
  margin-top: 14px;
  border-radius: 16px;
  background: #f6f1e8;
  overflow: hidden;
}

.stage img, .stage video {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  background: #111;
}

.stage img { background: #f6f1e8; }

.stage audio { width: calc(100% - 24px); margin: 28px 12px; }

.stage iframe {
  width: 100%;
  height: 62vh;
  border: 0;
  background: #fff;
}

.stage pre {
  margin: 0;
  max-height: 52vh;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Mono", Consolas, "Sarasa Mono SC", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.stage .fallback {
  padding: 42px 16px;
  text-align: center;
}

.stage .fallback .plate {
  display: inline-grid;
  place-items: center;
  min-width: 92px;
  height: 72px;
  padding: 0 16px;
  border-radius: 12px;
}

.link-row {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.link-row input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translateX(-50%);
  padding: 10px 16px;
  color: #f7f3ec;
  background: var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.toast[hidden] { display: none; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.queue[hidden], #more[hidden] { display: none; }

@media (max-width: 760px) {
  .top, .drop, .toolbar { flex-direction: column; align-items: stretch; }
  .stats { width: 100%; }
  .stats div { flex: 1; }
  .search input { width: 100%; }
  h1 { font-size: 44px; }
}
