:root {
  --bg0: #0f1412;
  --bg1: #17201c;
  --bg2: #1e2a24;
  --panel: rgba(232, 240, 234, 0.04);
  --line: rgba(232, 240, 234, 0.12);
  --text: #e8f0ea;
  --muted: #8fa396;
  --accent: #3dba8a;
  --accent-dim: rgba(61, 186, 138, 0.16);
  --danger: #e86a5c;
  --warn: #e0b35a;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(61, 186, 138, 0.18), transparent 55%),
    radial-gradient(800px 400px at 90% 0%, rgba(90, 140, 120, 0.12), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, #121916);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  transition: background .15s, border-color .15s, transform .12s;
}
.btn:hover { background: rgba(232, 240, 234, 0.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #062216;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn-danger { border-color: rgba(232, 106, 92, 0.45); color: #ffc7c1; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; border-radius: 8px; }

/* ----- login ----- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-shell { width: min(420px, 100%); }
.login-panel {
  background: rgba(15, 20, 18, 0.72);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.5rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: rise .45s ease both;
}
.brand-mark {
  margin: 0;
  font-family: var(--display);
  font-size: 1.75rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.login-panel h1 {
  margin: 0.35rem 0 0;
  font-size: 1.55rem;
  font-weight: 600;
}
.login-sub { margin: 0.4rem 0 1.4rem; color: var(--muted); font-size: 0.95rem; }
.field { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.field span { color: var(--muted); font-size: 0.85rem; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-msg { color: var(--danger); font-size: 0.9rem; margin: 0.75rem 0 0; }
.login-ver { margin: 1.25rem 0 0; color: var(--muted); font-size: 0.75rem; text-align: center; }

/* ----- shells ----- */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 18, 0.65);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}
.brand span { color: var(--muted); font-size: 0.82rem; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.main {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
}
@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
}

.side {
  border-right: 1px solid var(--line);
  padding: 1rem;
  background: rgba(0, 0, 0, 0.15);
}
.side h2 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.nav-btn {
  width: 100%;
  text-align: left;
  margin-bottom: 0.35rem;
}
.nav-btn.active {
  background: var(--accent-dim);
  border-color: rgba(61, 186, 138, 0.4);
  color: #b8f0d4;
}

.content { padding: 1rem 1.25rem 2rem; min-width: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-right: auto;
}
.crumbs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
}
.crumbs button:hover { color: var(--text); background: var(--panel); }
.crumbs .sep { opacity: 0.4; }

.panel {
  border: 1px solid var(--line);
  background: rgba(15, 20, 18, 0.45);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-table { width: 100%; border-collapse: collapse; }
.file-table th, .file-table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.file-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.2);
}
.file-table tr:last-child td { border-bottom: 0; }
.file-table tr:hover td { background: rgba(232, 240, 234, 0.03); }
.file-table .name-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.file-table .name-cell button.linkish,
.file-table .name-cell .linkish {
  border: 0;
  background: none;
  color: var(--text);
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.file-table .name-cell button.linkish:hover { color: var(--accent); text-decoration: underline; }
.icon-pill {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg2);
  color: var(--muted);
}
.icon-pill.folder { color: #e0b35a; background: rgba(224, 179, 90, 0.12); }
.icon-pill.image { color: #7ec8ff; background: rgba(126, 200, 255, 0.12); }
.icon-pill.video { color: #c79bff; background: rgba(199, 155, 255, 0.12); }
.icon-pill.audio { color: #3dba8a; background: var(--accent-dim); }
.icon-pill.pdf { color: #e86a5c; background: rgba(232, 106, 92, 0.12); }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  background: #102019;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .2s ease;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: rgba(232, 106, 92, 0.5); color: #ffc7c1; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 60;
  animation: fade .15s ease;
}
.modal {
  width: min(960px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #121a16;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: rise .2s ease;
}
.modal.sm { width: min(420px, 100%); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #121a16;
  z-index: 1;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 1rem; }
.modal-body video,
.modal-body img,
.modal-body audio,
.modal-body iframe {
  width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  background: #000;
}
.modal-body img { object-fit: contain; background: #0a0f0c; }
.modal-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #d5e4da;
  max-height: 65vh;
  overflow: auto;
}
.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }

.upload-zone {
  border: 1.5px dashed rgba(61, 186, 138, 0.45);
  background: var(--accent-dim);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  margin-bottom: 0.9rem;
  transition: border-color .15s, background .15s;
}
.upload-zone.drag { border-color: var(--accent); background: rgba(61, 186, 138, 0.22); color: var(--text); }
.upload-zone strong { color: var(--text); }
.progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.6rem;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .15s;
}

.share-list { display: grid; gap: 0.65rem; }
.share-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: var(--panel);
  display: grid;
  gap: 0.35rem;
}
.share-card .meta { color: var(--muted); font-size: 0.85rem; }
.share-card .url { font-size: 0.88rem; word-break: break-all; }

.share-home {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(1120px, 100%);
  margin: 0 auto;
}
.share-home > .content {
  padding: 0.85rem 1.25rem 2.5rem;
}
.share-hero {
  padding: 1.35rem 1.25rem 0.35rem;
}
.share-hero .brand-mark {
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}
.share-hero h1 {
  margin: 0.15rem 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.65rem, 3.2vw, 2.15rem);
  line-height: 1.15;
}
.share-hero p { margin: 0; color: var(--muted); }
.share-hero #share-sub { margin-top: 0.2rem; font-size: 0.92rem; }

/* ----- share media grid ----- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
}
@media (min-width: 960px) {
  .share-hero { padding: 1.75rem 1.5rem 0.5rem; }
  .share-home > .content { padding: 0.75rem 1.5rem 3rem; }
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.15rem;
  }
  .media-card.is-folder .media-thumb { aspect-ratio: 16 / 10; }
  .media-card.is-folder .media-name { font-size: 1.02rem; }
  .media-card:not(.is-folder) .media-thumb { aspect-ratio: 1; }
}
@media (max-width: 420px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .share-home > .content { padding: 0.65rem 0.85rem 1.75rem; }
  .share-hero { padding: 1rem 0.85rem 0.25rem; }
}

.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: rgba(15, 20, 18, 0.55);
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  text-align: left;
  color: inherit;
  width: 100%;
  cursor: pointer;
  transition: border-color .15s, transform .18s, background .15s, box-shadow .18s;
  animation: rise .35s ease both;
}
.media-card:hover,
.media-card:focus-visible {
  border-color: rgba(61, 186, 138, 0.45);
  background: rgba(232, 240, 234, 0.05);
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}
.media-card:active { transform: scale(0.985); }
.media-card:nth-child(1) { animation-delay: 0.02s; }
.media-card:nth-child(2) { animation-delay: 0.05s; }
.media-card:nth-child(3) { animation-delay: 0.08s; }
.media-card:nth-child(4) { animation-delay: 0.11s; }
.media-card:nth-child(5) { animation-delay: 0.14s; }
.media-card:nth-child(6) { animation-delay: 0.17s; }

.media-thumb {
  position: relative;
  aspect-ratio: 1;
  background:
    linear-gradient(145deg, rgba(30, 42, 36, 0.9), rgba(12, 16, 14, 0.95));
  overflow: hidden;
}
.media-card.is-folder .media-thumb {
  aspect-ratio: 4 / 3;
}
.media-card.is-folder .media-thumb.has-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08) 35%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}
.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #0a0f0c;
}
.media-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: 0.35rem;
  color: var(--muted);
  background:
    radial-gradient(120% 80% at 20% 10%, rgba(61, 186, 138, 0.16), transparent 55%),
    linear-gradient(155deg, #1a2620, #101613 60%, #0c1210);
}
.media-thumb-fallback .icon-pill {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 12px;
  font-size: 0.95rem;
}
.media-badge {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.55);
  color: #dce8e0;
  backdrop-filter: blur(6px);
}
.media-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
}
.media-play::before {
  content: "";
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(6, 34, 22, 0.72);
  border: 1px solid rgba(61, 186, 138, 0.55);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233dba8a'%3E%3Cpath d='M9 7.5v9l7.5-4.5L9 7.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 55% 50%;
  background-size: 1.15rem;
}
.media-meta {
  padding: 0.7rem 0.8rem 0.8rem;
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}
.media-name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

@media (max-width: 640px) {
  .modal { width: 100%; max-height: 92vh; border-radius: 14px 14px 10px 10px; }
  .modal-head { padding: 0.75rem 0.85rem; }
  .modal-head h3 {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .modal-body { padding: 0.75rem; }
  .modal-body video,
  .modal-body img { max-height: 62vh; }
}

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