:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: rgba(255, 255, 255, 0.85);
  --text: #111;
  --subtext: rgba(60, 60, 67, 0.7);
  --separator: rgba(60, 60, 67, 0.18);
  --primary: #0a84ff;
  --danger: #ff3b30;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: rgba(28, 28, 30, 0.9);
    --text: #fff;
    --subtext: rgba(235, 235, 245, 0.65);
    --separator: rgba(84, 84, 88, 0.65);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

.app {
  min-height: 100%;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  height: calc(52px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  border-bottom: 0.5px solid var(--separator);
  background: rgba(250, 250, 250, 0.75);
  backdrop-filter: blur(20px);
}

@media (prefers-color-scheme: dark) {
  .nav {
    background: rgba(0, 0, 0, 0.7);
  }
}

.nav--sub {
  grid-template-columns: 72px 1fr 72px;
}

.nav__title {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav__btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 15px;
  padding: 8px 10px;
  text-align: left;
}

.nav__btn:disabled {
  opacity: 0.55;
}

.nav__btn:last-child {
  text-align: right;
}

.screen {
  display: none;
  padding: 16px 16px 0;
}

.screen--active {
  display: block;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--separator);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 600;
  min-height: 48px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.55;
}

.btn--primary {
  border-color: rgba(10, 132, 255, 0.25);
  background: linear-gradient(180deg, rgba(10, 132, 255, 1), rgba(10, 122, 255, 1));
  color: white;
  box-shadow: 0 10px 24px rgba(10, 132, 255, 0.28);
}

.hint {
  margin: 14px 0 0;
  border: 1px dashed var(--separator);
  border-radius: 14px;
  padding: 12px 12px;
  background: rgba(142, 142, 147, 0.08);
}

.hint--warn {
  border-style: solid;
  border-color: rgba(255, 149, 0, 0.35);
  background: rgba(255, 149, 0, 0.08);
}

.hint__title {
  font-weight: 700;
  margin-bottom: 6px;
}

.hint__text {
  color: var(--subtext);
  font-size: 13px;
  line-height: 1.4;
}

.card {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 0.5px solid var(--separator);
}

.card__title {
  font-weight: 700;
}

.empty {
  padding: 16px 12px;
}

.empty__title {
  font-weight: 800;
  margin-bottom: 6px;
}

.empty__desc {
  color: var(--subtext);
  font-size: 14px;
  line-height: 1.4;
}

.list {
  display: grid;
}

.row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 12px;
  padding: 12px 12px;
  align-items: center;
  border-bottom: 0.5px solid var(--separator);
}

.row:last-child {
  border-bottom: none;
}

.thumb {
  width: 76px;
  height: 76px;
  border-radius: 14px;
  object-fit: cover;
  border: 0.5px solid var(--separator);
  background: rgba(142, 142, 147, 0.15);
}

.meta__time {
  font-size: 14px;
  font-weight: 650;
}

.meta__size {
  margin-top: 6px;
  font-size: 12px;
  color: var(--subtext);
}

.row__actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.iconBtn {
  appearance: none;
  border: none;
  background: rgba(255, 59, 48, 0.08);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 10px;
  font-weight: 700;
}

.link {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  color: var(--primary);
}

.link.danger {
  color: var(--danger);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 24px;
}

.overlay[hidden] {
  display: none !important;
}

.overlay__card {
  width: min(360px, 100%);
  border-radius: 16px;
  padding: 18px 16px;
  background: rgba(40, 40, 42, 0.7);
  backdrop-filter: blur(18px);
  color: white;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.overlay__title {
  margin-top: 12px;
  font-weight: 800;
}

.overlay__subtitle {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.86;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.95);
  margin: 0 auto;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] {
  display: none !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 0;
}

.modal__card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  border-radius: 18px;
  padding: 16px 14px;
  background: var(--card);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow);
}

button,
.btn,
.nav__btn,
.iconBtn,
.link {
  touch-action: manipulation;
}

.modal__title {
  font-weight: 800;
  margin-bottom: 10px;
}

.modal__text {
  color: var(--subtext);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal__actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field__label {
  font-weight: 700;
  font-size: 14px;
}

.field__input {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  padding: 10px 12px;
  font-size: 15px;
  background: rgba(142, 142, 147, 0.08);
  color: var(--text);
}

.field__help {
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.4;
}

.pdfActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.pdfFrameWrap {
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--separator);
  box-shadow: var(--shadow);
  background: rgba(142, 142, 147, 0.12);
  height: calc(100vh - 220px - env(safe-area-inset-top));
}

.pdfFrame {
  width: 100%;
  height: 100%;
  border: 0;
}
