:root {
  --bg: #0e0f13;
  --surface: #171920;
  --raised: #20232d;
  --line: #2c303c;
  --text: #eceef3;
  --muted: #979cab;
  --accent: #f2a03d;
  --accent-text: #1b1205;
  --danger: #ef6a5b;
  --radius: 12px;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f4f1;
    --surface: #ffffff;
    --raised: #f0eeea;
    --line: #dedbd4;
    --text: #1d1e22;
    --muted: #6c6f7a;
    --accent: #c9730c;
    --accent-text: #ffffff;
    --danger: #c63f31;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 7px 14px;
  white-space: nowrap;
}
button:hover {
  background: var(--raised);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.danger {
  color: var(--danger);
}
button.plain {
  border-color: transparent;
  background: transparent;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
}

/* Sign-in */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login form {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  display: grid;
  gap: 14px;
}
.login h1 {
  margin: 0 0 4px;
  font-size: 22px;
}
.login p {
  margin: 0;
  color: var(--muted);
}
.login label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
}

/* Library */
header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
header .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}
header .brand span {
  color: var(--accent);
}
header .spacer {
  flex: 1;
}
header .who {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34vw;
}
main {
  padding: 16px max(16px, env(safe-area-inset-left)) 64px;
  max-width: 1500px;
  margin: 0 auto;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 200px;
  font-size: 17px;
  font-weight: 600;
}
.crumbs button {
  border: 0;
  background: none;
  padding: 4px 6px;
  font-weight: inherit;
}
.crumbs .sep {
  color: var(--muted);
}
.notice {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  color: var(--muted);
}
.notice.warn {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--text);
}
h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 22px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
@media (max-width: 520px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}
.folder {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius);
  min-width: 0;
}
.folder .icon {
  font-size: 22px;
}
.folder .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: 600;
}
.folder .tag {
  font-size: 12px;
  color: var(--muted);
}
.card {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  display: grid;
  gap: 8px;
  min-width: 0;
  white-space: normal;
}
.card:hover {
  background: none;
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--raised);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 30px;
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s;
}
.card:hover .thumb img {
  transform: scale(1.04);
}
.badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 12px;
  background: rgb(0 0 0 / 0.72);
  color: #fff;
}
.badge.state {
  left: 8px;
  right: auto;
  background: var(--accent);
  color: var(--accent-text);
}
.card .title {
  font-weight: 600;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .meta {
  color: var(--muted);
  font-size: 12px;
}
.card .remove {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 9px;
  background: rgb(0 0 0 / 0.72);
  border: 0;
  color: #fff;
  opacity: 0;
}
.card:hover .remove,
.card .remove:focus-visible {
  opacity: 1;
}
@media (hover: none) {
  .card .remove {
    opacity: 1;
  }
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 64px 16px;
}

/* Player */
.player {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  display: grid;
  grid-template-rows: auto 1fr;
  color: #fff;
}
.player .top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.player .top .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .top button {
  background: rgb(255 255 255 / 0.12);
  border: 0;
  color: #fff;
}
.player .stage {
  min-height: 0;
  display: grid;
  place-items: center;
}
.player video,
.player img {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.player audio {
  width: min(560px, 92vw);
}

/* Dialogs */
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 22px;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}
dialog h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
dialog .hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
}
dialog .rows {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  max-height: 44dvh;
  overflow: auto;
}
dialog .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
dialog .row .grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
dialog .row small {
  color: var(--muted);
  display: block;
}
dialog .fields {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.uploads {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 15;
  width: min(340px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.uploads progress {
  width: 100%;
  accent-color: var(--accent);
}
[hidden] {
  display: none !important;
}
header .brand {
  white-space: nowrap;
}
dialog .rows {
  overflow-x: hidden;
}
@media (max-width: 520px) {
  header .who {
    display: none;
  }
  dialog {
    padding: 16px;
  }
  dialog .row button {
    padding: 6px 9px;
  }
}
