:root {
  --bg0: #d5e0e8;
  --bg1: #eef3f7;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5a6b7a;
  --line: rgba(21, 32, 43, 0.11);
  --accent: #0d7377;
  --accent-soft: rgba(13, 115, 119, 0.12);
  --accent-ink: #ffffff;
  --danger: #c23b2a;
  --ok: #1f8a5b;
  --font: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Syne", "Manrope", sans-serif;
  --radius: 14px;
  --shadow: 0 16px 36px rgba(21, 32, 43, 0.08);
  --shell: 1080px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 560px at 0% 0%, rgba(13, 115, 119, 0.16), transparent 55%),
    radial-gradient(800px 500px at 100% 10%, rgba(47, 111, 168, 0.12), transparent 50%),
    linear-gradient(168deg, #c8d6e0 0%, #e7eef4 45%, #d2dde6 100%);
}
.bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(21, 32, 43, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
  pointer-events: none;
}

.hidden { display: none !important; }
.view { min-height: 100%; }

/* —— Login: brand left, form right —— */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}

.login-shell {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 0;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise 0.65s ease both;
}

.login-hero {
  padding: clamp(36px, 6vw, 64px);
  background:
    linear-gradient(145deg, rgba(13, 115, 119, 0.1), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent);
}

.brand-block .brand {
  font-family: var(--display);
  font-size: clamp(2.8rem, 5.5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  margin: 0 0 22px;
  line-height: 0.92;
}
.brand-block .brand::after {
  content: "";
  display: block;
  width: 52px;
  height: 4px;
  margin-top: 16px;
  background: var(--accent);
  border-radius: 2px;
  animation: grow 0.75s 0.12s ease both;
}

.brand-block h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  line-height: 1.3;
  margin: 0 0 14px;
  max-width: 12em;
  letter-spacing: -0.02em;
}

.lede {
  color: var(--muted);
  margin: 0;
  line-height: 1.65;
  max-width: 28ch;
  font-size: 0.98rem;
}

.login-form {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: clamp(28px, 4vw, 48px);
  background: var(--surface);
  border-left: 1px solid var(--line);
  animation: rise 0.75s 0.08s ease both;
}

.form-kicker {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input:focus {
  border-color: rgba(13, 115, 119, 0.5);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; justify-self: stretch; }

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.primary:hover { background: #0a6063; }

.btn.ghost {
  background: rgba(255, 255, 255, 0.85);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(194, 59, 42, 0.28);
  background: rgba(194, 59, 42, 0.05);
}

.error {
  min-height: 1.2em;
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
}

/* —— App shell —— */
.app-view {
  min-height: 100vh;
  animation: rise 0.4s ease both;
}

.shell-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 248, 251, 0.86);
  backdrop-filter: blur(12px);
}

.shell-bar-inner {
  width: min(var(--shell), calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-mark {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.whoami {
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.shell-main {
  width: min(var(--shell), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
  display: grid;
  gap: 22px;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.section-label {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Upload: split layout */
.upload-panel {
  display: grid;
  grid-template-columns: 1.2fr auto;
  gap: 18px 28px;
  align-items: end;
  padding: 28px 28px 22px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.upload-panel.dragover {
  border-color: rgba(13, 115, 119, 0.45);
  background: linear-gradient(180deg, var(--accent-soft), #fff);
  transform: translateY(-1px);
}

.upload-copy { grid-column: 1; }
.upload-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.upload-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.upload-title {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.25rem, 2.2vw, 1.55rem);
  font-weight: 750;
  letter-spacing: -0.02em;
}

.upload-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: 42ch;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.folder-pick-btn { min-width: 120px; }

.upload-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg1);
  border: 1px solid var(--line);
}

.upload-item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}

.upload-item .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.upload-item .name-input,
.upload-item input[type="text"] {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(21, 32, 43, 0.08);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #0d7377, #2f91a0);
  transition: width 0.15s linear;
}

/* Library */
.library-panel {
  padding: 24px 24px 20px;
}

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.library-head-left { min-width: 0; }

.nav-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.toolbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

#list-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.breadcrumb button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
}
.breadcrumb .sep { opacity: 0.4; }

.folder-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.folder-row {
  display: grid;
  gap: 14px;
  padding: 16px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg1);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  animation: rise 0.35s ease both;
}

.folder-row:hover {
  border-color: rgba(13, 115, 119, 0.35);
  background: #fff;
  transform: translateY(-1px);
}

.folder-row .file-meta { min-width: 0; }
.folder-row .file-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.folder-mark {
  width: 36px;
  height: 28px;
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, #2a9aa0, #0d7377);
  margin-bottom: 10px;
  position: relative;
}
.folder-mark::before {
  content: "";
  position: absolute;
  left: 0;
  top: -6px;
  width: 14px;
  height: 8px;
  border-radius: 3px 3px 0 0;
  background: #0a6063;
}

.file-list {
  display: grid;
  gap: 10px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  animation: rise 0.35s ease both;
}

.file-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.thumb {
  flex: 0 0 112px;
  width: 112px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: #c5d2dc;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-img.broken { display: none; }
.thumb-fallback { color: var(--muted); font-size: 0.95rem; font-weight: 700; }

.file-meta { min-width: 0; }
.file-name {
  font-weight: 700;
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty {
  color: var(--muted);
  padding: 36px 8px;
  text-align: center;
  grid-column: 1 / -1;
}

/* Dialogs */
.action-dialog,
.preview-dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.action-dialog { width: min(420px, calc(100vw - 24px)); }
.preview-dialog { width: min(960px, calc(100vw - 24px)); }

.action-dialog::backdrop,
.preview-dialog::backdrop {
  background: rgba(21, 32, 43, 0.45);
  backdrop-filter: blur(6px);
}

.action-form {
  padding: 16px;
  display: grid;
  gap: 12px;
}
.action-form h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
}
.action-form input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
}

.name-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.name-edit-row input[type="text"] { flex: 1; min-width: 0; }
.name-ext {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 10px 4px;
  user-select: none;
  font-weight: 600;
}

.action-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.action-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pick-list {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}
.pick-item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pick-folder-mark {
  width: 22px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(180deg, #2a9aa0, #0d7377);
  position: relative;
}
.pick-folder-mark::before {
  content: "";
  position: absolute;
  left: 0;
  top: -4px;
  width: 9px;
  height: 5px;
  border-radius: 2px 2px 0 0;
  background: #0a6063;
}
.pick-item:hover,
.pick-item.active {
  border-color: rgba(13, 115, 119, 0.4);
  background: var(--accent-soft);
}
.folder-pick-new { width: 100%; }

.preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.preview-body { padding: 12px; min-height: 200px; }
.preview-body video,
.preview-body img,
.preview-body audio {
  width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  background: #0f1720;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes grow {
  from { width: 0; opacity: 0; }
  to { width: 52px; opacity: 1; }
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .login-form {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .upload-panel {
    grid-template-columns: 1fr;
  }
  .upload-actions {
    grid-column: 1;
    justify-content: flex-start;
  }
  .folder-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell-main { width: calc(100% - 24px); padding-top: 18px; }
  .shell-bar-inner { width: calc(100% - 24px); }
  .upload-panel,
  .library-panel { padding: 18px; }
  .folder-list { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 1fr; }
  .file-actions { justify-content: flex-start; }
  .library-head { flex-direction: column; }
}
