:root {
  --bg: #f5f2ec;
  --bg-deep: #ece7dc;
  --surface: #fffdf9;
  --surface-2: #f9f6ef;
  --ink: #1d2a25;
  --muted: #6c7a73;
  --line: #e4ded1;
  --accent: #1f6f5c;
  --accent-ink: #14503f;
  --accent-soft: #e2efe9;
  --danger: #ae4030;
  --danger-soft: #f8e6e2;
  --warn: #9a640f;
  --warn-soft: #f7eeda;
  --shadow: 0 10px 30px rgba(38, 45, 40, 0.08);
  --radius: 16px;
  --nav-h: 62px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e8f0ea 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 0%, #f3e9d8 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- 登录 / 首启 ---------- */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 22px 24px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-name {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: -2px;
}

.auth h1 {
  font-size: 19px;
  margin: 0 0 6px;
}

.auth p.hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.auth .btn {
  width: 100%;
  margin-top: 6px;
}

.auth-foot {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 应用框架 ---------- */

.shell {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  background: rgba(245, 242, 236, 0.9);
  backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid rgba(228, 222, 209, 0.7);
}

@supports not (backdrop-filter: blur(1px)) {
  .topbar {
    background: var(--bg);
  }
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
}

.topbar-title .brand-mark svg {
  width: 18px;
  height: 18px;
}

.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 650;
  white-space: nowrap;
}

.topbar .who {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.view {
  padding: 16px 16px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom));
  animation: rise 0.22s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 底栏 ---------- */

.bottomnav {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 760px;
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 249, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

@supports not (backdrop-filter: blur(1px)) {
  .bottomnav {
    background: var(--surface);
  }
}

.navitem {
  flex: 1;
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 2px 5px;
  border-radius: 12px;
  font-size: 11px;
  line-height: 1.2;
  min-height: 48px;
}

.navitem svg {
  width: 22px;
  height: 22px;
}

.navitem.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 控件 ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn.small svg {
  width: 16px;
  height: 16px;
}

.btn:active {
  transform: scale(0.985);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-ink);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: #eccfc9;
  background: var(--danger-soft);
}

.btn.small {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
}

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

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > label,
.field-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 550;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.12);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 2px 0 6px;
}

/* ---------- 搜索 / 筛选 ---------- */

.searchbar {
  position: relative;
  margin-bottom: 12px;
}

.searchbar svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.searchbar .input {
  padding-left: 40px;
  background: var(--surface);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  min-height: 34px;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 2px 2px 10px;
}

/* ---------- 资产列表 ---------- */

.asset-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  color: inherit;
}

.asset-card:active {
  background: var(--surface-2);
}

.thumb {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

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

.thumb svg {
  width: 24px;
  height: 24px;
}

.asset-main {
  min-width: 0;
  flex: 1;
}

.asset-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-desc {
  display: block;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.asset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 6px;
  align-items: center;
}

.taglist {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.badge.gray {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge.red {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.amber {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty .empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.empty .empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 15px;
}

.empty p {
  margin: 0;
  font-size: 13px;
}

.load-more {
  width: 100%;
  margin-top: 14px;
}

.loading-line {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 14px;
}

.skeleton {
  height: 84px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #efeae0 25%, #f7f4ed 37%, #efeae0 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s infinite;
  border: 1px solid var(--line);
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ---------- 详情 ---------- */

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 10px;
}

.backlink svg {
  width: 16px;
  height: 16px;
}

.detail-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.detail-head .thumb {
  width: 46px;
  height: 46px;
}

.detail-title {
  font-size: 19px;
  font-weight: 650;
  line-height: 1.35;
  word-break: break-word;
}

.detail-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.preview {
  background: #111815;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 16px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview img {
  max-width: 100%;
  max-height: 62vh;
  display: block;
  object-fit: contain;
}

.preview iframe {
  width: 100%;
  height: 62vh;
  border: 0;
  background: #fff;
}

.preview pre {
  width: 100%;
  margin: 0;
  padding: 16px;
  max-height: 60vh;
  overflow: auto;
  color: #e9efe9;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.preview .file-fallback {
  padding: 34px 20px;
  text-align: center;
  color: #cfd8d1;
  font-size: 13px;
}

.preview .file-fallback svg {
  width: 46px;
  height: 46px;
  margin-bottom: 8px;
  opacity: 0.8;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 12px;
}

.panel h2 {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.detail-desc {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

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

.kv {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}

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

.kv dd {
  margin: 0;
  word-break: break-all;
}

.kv dd svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 3px;
}

.actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.actions .btn {
  flex: 1 1 auto;
}

/* ---------- 上传 ---------- */

.dropzone {
  border: 1.5px dashed #cfc7b6;
  background: var(--surface);
  border-radius: 18px;
  padding: 30px 18px;
  text-align: center;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:active,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
  margin-bottom: 8px;
}

.dropzone .dz-title {
  font-weight: 600;
}

.dropzone .dz-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.file-picked {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.file-picked .fp-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.file-picked .fp-size {
  color: var(--muted);
  flex: none;
}

.progress {
  height: 7px;
  background: var(--bg-deep);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 14px;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.18s ease;
}

/* ---------- 管理 ---------- */

.seg {
  display: flex;
  background: var(--bg-deep);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 14px;
}

.seg button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 8px;
  font-size: 13px;
  min-height: 38px;
}

.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(38, 45, 40, 0.08);
  font-weight: 600;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 10px;
}

.section-head h2 {
  font-size: 15px;
  margin: 0;
}

.identity-card,
.log-row,
.trash-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 10px;
}

.identity-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.identity-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.identity-remark {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.identity-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

.identity-controls .select {
  width: auto;
  min-width: 108px;
  padding: 7px 32px 7px 10px;
  font-size: 13px;
  border-radius: 9px;
  min-height: 34px;
}

.identity-controls .spacer {
  flex: 1;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.switch input {
  width: 34px;
  height: 20px;
  appearance: none;
  background: #d8d2c5;
  border-radius: 999px;
  position: relative;
  transition: background 0.15s ease;
  margin: 0;
}

.switch input::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked {
  background: var(--accent);
}

.switch input:checked::after {
  transform: translateX(14px);
}

.log-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
}

.log-main {
  flex: 1;
  min-width: 0;
}

.log-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.log-time {
  color: var(--muted);
  font-size: 11px;
}

.log-content {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  word-break: break-word;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.filters .select {
  flex: 1;
  font-size: 13px;
  padding: 9px 32px 9px 10px;
  min-height: 38px;
}

/* ---------- 底部弹层 ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 24, 21, 0.42);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fade 0.16s ease;
}

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

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow: auto;
  animation: sheet-up 0.22s ease;
}

@keyframes sheet-up {
  from {
    transform: translateY(16px);
  }
  to {
    transform: none;
  }
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.sheet .sheet-sub {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 16px;
}

.sheet .btn-row {
  margin-top: 6px;
}

.sheet .btn-row .btn {
  flex: 1;
}

.secret-box {
  background: #111815;
  color: #dcefe4;
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
  margin-bottom: 12px;
}

@media (min-width: 560px) {
  .sheet-backdrop {
    align-items: center;
    padding: 20px;
  }

  .sheet {
    border-radius: 22px;
    max-height: 84vh;
    padding-bottom: 22px;
  }
}

/* ---------- 我的 ---------- */

.profile {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 650;
  flex: none;
}

.profile-name {
  font-size: 18px;
  font-weight: 650;
}

.profile-sub {
  color: var(--muted);
  font-size: 12px;
}

.note {
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px;
  line-height: 1.7;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  background: #1d2a25;
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 80;
  max-width: calc(100% - 40px);
  text-align: center;
  box-shadow: var(--shadow);
}

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

.toast.error {
  background: #7d2b21;
}
