:root {
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --blue: #0071e3;
  --red: #ff3b30;
  --glass: rgba(255, 255, 255, 0.52);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --stroke: rgba(255, 255, 255, 0.65);
  --shadow: 0 18px 50px rgba(31, 38, 80, 0.14);
  --radius: 28px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
}

body {
  background:
    radial-gradient(1200px 700px at 12% -10%, #c9e7ff 0%, transparent 55%),
    radial-gradient(900px 600px at 95% 8%, #ffd6e8 0%, transparent 50%),
    radial-gradient(800px 700px at 80% 100%, #d8ccff 0%, transparent 55%),
    radial-gradient(700px 500px at 0% 90%, #d6f5e8 0%, transparent 50%),
    #eef1f6;
}

body.admin-body {
  background:
    radial-gradient(1000px 600px at 8% 0%, #d7e8ff 0%, transparent 50%),
    radial-gradient(800px 500px at 100% 20%, #ead9ff 0%, transparent 48%),
    #eef1f6;
}

a { color: inherit; }

.bg-orb {
  position: fixed;
  z-index: 0;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.55;
  pointer-events: none;
}

.orb-1 { top: 8%; left: -60px; background: #9ad4ff; }
.orb-2 { top: 40%; right: -80px; background: #ffb7d5; }
.orb-3 { bottom: -40px; left: 20%; background: #c9b8ff; }

.app {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
}

.h5-app {
  max-width: none;
  width: 100%;
  padding: 0 0 calc(28px + var(--safe-bottom));
}

.h5-app .hero {
  width: 100%;
  border-radius: 0;
  margin: 0 0 16px;
  padding: calc(14px + var(--safe-top)) 16px 14px;
}

.h5-app .topbar {
  padding: 0 2px 12px;
  margin: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.h5-app .search {
  margin: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.h5-app .list,
.h5-app .dl-tip {
  margin-left: 18px;
  margin-right: 18px;
}

.admin-app {
  max-width: 1080px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-radius: 22px;
  margin-bottom: 16px;
}

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

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #5ac8fa, #007aff 55%, #5856d6);
  box-shadow: 0 8px 18px rgba(0, 122, 255, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: 12px;
}

.icon-btn, .btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255,255,255,0.45);
  color: var(--text);
}

.btn {
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.45;
}

.btn.ghost {
  background: rgba(255,255,255,0.5);
  color: var(--text);
}

.btn.danger {
  background: var(--red);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  margin-bottom: 14px;
}

.search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
}

.list {
  border-radius: var(--radius);
  overflow: hidden;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.35);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  flex-wrap: wrap;
}

.file-row:last-child { border-bottom: 0; }
.file-row:active { background: rgba(255,255,255,0.35); }

.file-row.h5 {
  flex-wrap: nowrap;
  cursor: pointer;
}

.file-row.h5:active {
  background: rgba(255, 255, 255, 0.35);
}

.h5-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  text-decoration: none;
}

.pill.view {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.pill.dl {
  background: var(--blue);
  color: #fff;
}

.dl-tip {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}

.file-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.file-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  background: #ececf0;
}

.file-thumb.is-on {
  opacity: 1;
}

.file-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.file-avatar .file-icon {
  width: 100%;
  height: 100%;
}

.file-icon.pdf { background: linear-gradient(180deg, #ff6b6b, #e03131); }
.file-icon.img { background: linear-gradient(180deg, #69db7c, #2f9e44); }
.file-icon.doc { background: linear-gradient(180deg, #74c0fc, #1c7ed6); }
.file-icon.zip { background: linear-gradient(180deg, #ffd43b, #f08c00); }
.file-icon.vid { background: linear-gradient(180deg, #b197fc, #7048e8); }
.file-icon.def { background: linear-gradient(180deg, #868e96, #495057); }

.file-meta { min-width: 0; flex: 1; }
.file-meta strong {
  display: block;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta span {
  display: block;
  margin-top: 3px;
  color: var(--text-2);
  font-size: 12px;
}

.chev {
  color: #c7c7cc;
  font-size: 18px;
}

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

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(236, 240, 247, 0.28);
  backdrop-filter: blur(22px);
}

.gate-card {
  width: min(420px, 100%);
  padding: 28px 24px 24px;
  border-radius: 32px;
  text-align: center;
}

.lock {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #5ac8fa, #007aff);
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 122, 255, 0.28);
}

.gate-card h2 { margin: 0 0 6px; font-size: 24px; }
.gate-card p { margin: 0 0 20px; color: var(--text-2); }

.field {
  width: 100%;
  border: 0;
  outline: none;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  background: rgba(255,255,255,0.7);
  margin-bottom: 12px;
}

.hint { color: var(--red); min-height: 18px; font-size: 13px; margin: 0 0 8px; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.28);
}

.sheet.open { display: flex; }

.sheet-card {
  width: min(430px, 100%);
  border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(20px + var(--safe-bottom));
}

.handle {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: rgba(0,0,0,0.16);
  margin: 0 auto 16px;
}

.sheet-title {
  margin: 0 0 6px;
  font-size: 20px;
  word-break: break-all;
}

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

.admin-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}

.admin-settings-save {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-settings-save .hint {
  flex: 1;
  margin: 0;
  min-height: 0;
}

.admin-settings-save .btn {
  min-width: 140px;
}

.panel {
  padding: 14px 16px;
  border-radius: 20px;
}

.admin-app .field {
  margin-bottom: 8px;
  padding: 10px 12px;
}

.admin-app .hint {
  min-height: 14px;
  margin: 0 0 6px;
}

.admin-app .btn {
  padding: 10px 14px;
}

.drop {
  border: 1.5px dashed rgba(0,0,0,0.12);
  border-radius: 14px;
  padding: 18px 12px;
  text-align: center;
  color: var(--text-2);
  background: rgba(255,255,255,0.28);
}

.drop.over {
  border-color: var(--blue);
  background: rgba(0, 113, 227, 0.08);
}

.admin-list .file-row { cursor: pointer; }

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

.tiny {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.hidden { display: none !important; }

.preview {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: rgba(18, 20, 28, 0.48);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: calc(10px + var(--safe-top)) 12px 0;
  padding: 8px 10px;
  border-radius: 18px;
}

.preview-bar strong {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-body {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px 12px calc(16px + var(--safe-bottom));
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  background: #111;
}

.preview-body video,
.preview-body audio {
  width: min(100%, 720px);
}

.preview-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 18px;
  background: #fff;
}

.preview-text {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.55;
}

.preview-empty {
  max-width: 280px;
  text-align: center;
  color: #fff;
  line-height: 1.6;
}

@media (max-width: 860px) {
  .admin-settings { grid-template-columns: 1fr; }
}
