/* Midnight: presentation-only theme. Original application logic is unchanged. */
:root {
  color-scheme: dark;
  --ink: #f5f5f7;
  --paper: #0c0d10;
  --line: rgba(255,255,255,.09);
  --accent: #78b6ff;
  --mint: #23354b;
  --nav-secondary: #979ba7;
  --nav-surface: #191b21;
  --nav-font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
html { background: var(--paper); }
body {
  background: radial-gradient(ellipse at 50% -360px, #202d46 0, transparent 68%), #0c0d10;
  background-size: 100% 1000px;
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--nav-font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
::selection { background: #356496; color: white; }
button, input, select, textarea { font-family: var(--nav-font); }
button { font-weight: 500; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:is(button,a,input,select,textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.site-shell { min-height: 100svh; }
.topbar, .hero, .directory, .file-shell, footer { width: min(1200px, calc(100% - 80px)); }
.topbar {
  height: 88px;
  min-height: 88px;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.topbar nav { gap: 10px; }
.topbar-identity { gap: 16px; }
.brand { font-weight: 600; letter-spacing: -.03em; }
.brand-mark { background: #252a35; color: var(--ink); border-radius: 12px; }
.brand-ip-list { gap: 16px; }
.brand-ip-list > span {
  width: auto;
  max-width: 190px;
  padding: 0 2px;
  height: 30px;
  font: 500 12px/1 var(--nav-font);
  font-variant-numeric: tabular-nums;
  letter-spacing: .025em;
  color: #b2b8c5;
  gap: 8px;
}
.brand-ip-list > span::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex: 0 0 5px;
  background: #8794aa;
}
.account-button, .bookmark-import-button, .upload-button, .unlock-form button,
.save-button, .cancel-button, .delete-button, .gate-button, .empty-state button {
  border-radius: 12px;
  border: 1px solid var(--line);
  font-weight: 600;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.account-button { padding: 9px 19px; background: #24272f; color: #e8eaf0; }
.login-button, .save-button, .upload-button, .unlock-form button, .empty-state button {
  background: #3086ef;
  color: #fff;
  border-color: #4194f7;
  box-shadow: inset 0 1px 0 #ffffff1f;
}
.login-button:hover, .save-button:hover, .upload-button:hover, .unlock-form button:hover {
  background: #4698fa;
  border-color: #67aaff;
  color: #fff;
}
.account-button:not(.login-button):hover { background: #303540; color: #fff; }
.text-button, .nav-link, .speed-button { color: #b0b5c1; font-weight: 500; }
.text-button:hover, .nav-link:hover, .nav-link.active, .speed-button:hover { color: var(--accent); }
.local-note { color: var(--nav-secondary); }
.directory-compact { padding-top: 30px; padding-bottom: 80px; }
.directory-tools { gap: 16px; min-height: 64px; margin-bottom: 24px; }
.bookmark-drop-zone {
  height: 64px;
  padding: 0 20px;
  background: #ffffff02;
  border: 1px dashed #ffffff24;
  border-radius: 16px;
  color: var(--nav-secondary);
}
.bookmark-drop-zone > span {
  background: #252a34;
  border: 1px solid #ffffff07;
  border-radius: 11px;
  color: #b0c8eb;
  font-size: 23px;
}
.bookmark-drop-zone strong { font-size: 13px; font-weight: 500; color: #cbd0db; }
.bookmark-drop-zone small { font-size: 11px; color: #8c93a3; }
.bookmark-drop-zone.active { background: #173052; border-color: var(--accent); }
.compact-search, .search-box {
  height: 64px;
  width: min(400px, 100%);
  background: linear-gradient(130deg,#ffffff09,#ffffff03), #1a1d25;
  border: 1px solid #ffffff16;
  border-radius: 16px;
  padding: 0 22px;
  gap: 13px;
  box-shadow: inset 0 1px 0 #ffffff06, 0 8px 28px #00000010;
  transition: border-color .2s, box-shadow .2s;
}
.compact-search:focus-within, .search-box:focus-within {
  border-color: #78b6ff99;
  box-shadow: 0 0 0 3px #78b6ff14;
}
.compact-search > span, .search-box > span { color: #99abc8; }
.compact-search input, .search-box input { font-size: 14px; color: var(--ink); }
.compact-search input::placeholder, .search-box input::placeholder { color: #9299a9; }
.search-box kbd { border-radius: 5px; color: #9da4b4; background: #ffffff09; }
.bookmark-import-button { height: 64px; background: #20242d; color: #cbd6e9; padding: 0 18px; }
.bookmark-import-button:hover { background: #2b3545; }
.directory-head { border: 0; min-height: 52px; gap: 20px; margin-bottom: 16px; }
.directory-head p { color: #8b919f; font-size: 11px; }
.tabs {
  gap: 4px;
  padding: 5px;
  background: #ffffff05;
  border: 1px solid #ffffff0b;
  border-radius: 14px;
  flex-wrap: wrap;
}
.tabs button {
  height: 36px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #a0a6b3;
  font-size: 13px;
  font-weight: 500;
  transition: background .18s, color .18s;
}
.tabs button:hover { background: #ffffff07; color: #fff; }
.tabs button.active {
  background: #333945;
  border-color: #ffffff12;
  color: #fff;
  box-shadow: 0 2px 5px #0003, inset 0 1px 0 #ffffff08;
}
.link-group {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 18px;
  padding: 26px 0 30px;
  border-bottom: 1px solid #ffffff07;
}
.group-title { gap: 10px; align-items: center; min-height: 28px; }
.group-title h2 {
  font: 600 18px/1.4 var(--nav-font);
  letter-spacing: -.025em;
  color: #dedfe6;
}
.link-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.link-card, .add-card {
  min-height: 88px;
  border: 1px solid #ffffff0c;
  border-radius: 18px;
  background: linear-gradient(135deg,#ffffff04,transparent), var(--nav-surface);
  padding: 18px;
  gap: 12px;
  box-shadow: 0 2px 8px #0000000d, inset 0 1px 0 #ffffff03;
  transition: transform .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.link-card:hover {
  background: #242831;
  border-color: #ffffff23;
  box-shadow: 0 12px 28px #0003, inset 0 1px 0 #ffffff08;
  transform: translateY(-2px);
}
.link-card-link { gap: 13px; }
.favicon-shell, .letter-icon {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 12px;
  background: #f4f5f7;
  border: 1px solid #ffffff0a;
  overflow: hidden;
}
.favicon-shell img { width: 27px; height: 27px; }
.letter-icon { color: #e7ecf5; font: 600 18px/1 var(--nav-font); }
.tone-0 { background: #503832; }
.tone-1 { background: #2c433e; }
.tone-2 { background: #4a422c; }
.tone-3 { background: #2d4057; }
.tone-4 { background: #443652; }
.link-copy { gap: 6px; }
.link-copy strong { font-size: 13px; font-weight: 600; letter-spacing: -.01em; color: #eef0f5; }
.link-copy small { color: #8e95a4; font: 400 11px/1.3 var(--nav-font); }
.arrow { color: #737c8b; font-size: 15px; }
.mobile-badge { color: #94a6c4; font-size: 15px; flex-basis: 18px; width: 18px; }
.add-card { border: 1px dashed #ffffff26; background: #ffffff02; color: #939cad; font-size: 13px; }
.add-card:hover { background: #18283a; }
.drag-handle, .group-drag-handle, .group-delete-button { color: #7c8698; border-radius: 8px; }
.group-delete-button:hover, .context-menu button.danger, .delete-button, .file-actions .danger { color: #ff817e; }
.link-group.drag-target { background: #152537; border-radius: 16px; }
.modal-backdrop { background: #030508b3; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.modal, .context-menu {
  background: #20232af5;
  color: var(--ink);
  border: 1px solid #ffffff20;
  border-radius: 24px;
  box-shadow: 0 32px 100px #0009, inset 0 1px 0 #ffffff0a;
}
.modal { padding: 32px; }
.modal-heading h2, .empty-state h2, .mobile-empty h2, .file-heading h1, .locked-view h1,
.server-speed-heading h3 { font-family: var(--nav-font); letter-spacing: -.035em; font-weight: 600; }
.modal-heading h2 { font-size: 27px; line-height: 1.3; }
.modal-heading p { color: #9fb7dc; font: 600 10px/1.4 var(--nav-font); letter-spacing: .14em; }
.modal-heading > button { border-radius: 50%; background: #ffffff08; color: #aeb6c5; }
.modal input:not([type=checkbox]):not([type=file]), .modal select, .modal textarea,
.auth-form input, .icon-form > label input, .unlock-form input {
  background: #13161c;
  border: 1px solid #ffffff19;
  border-radius: 12px;
  color: #f0f1f5;
  font-size: 16px;
}
.modal input:focus, .modal select:focus, .modal textarea:focus, .auth-form input:focus {
  border-color: #78b6ff99; box-shadow: 0 0 0 3px #78b6ff14;
}
.modal label { color: #d3d7df; font-weight: 500; }
.modal input::placeholder, .modal textarea::placeholder { color: #7f8797; }
.modal label small, .auth-help, .locked-copy, .recovery-panel > p, .auth-form details,
.icon-tip, .speed-help, .server-speed-heading p, .server-speed-location,
.empty-state p, .mobile-empty p { color: #a3aab8; }
.cancel-button { background: #ffffff07; color: #d2d6df; }
.cancel-button:hover { background: #ffffff10; }
.context-menu { border-radius: 14px; padding: 6px; backdrop-filter: blur(22px); }
.context-menu button { border-radius: 8px; font-size: 13px; color: #e1e5ed; }
.context-menu button:hover { background: #327cce; color: white; }
.secret-code, .recovery-grid code, .icon-preview { background: #17202d; border-radius: 12px; color: #d5e6ff; }
.icon-upload-button { border-color: #69768c; border-radius: 12px; }
.totp-qr { background: white; border-radius: 12px; }
.speed-options button { background: #ffffff05; border-radius: 10px; }
.speed-options button.active { background: #253c59; border-color: #78b6ff55; color: #b4d6ff; }
.speed-result { background: #111925; color: #f5f5f7; border: 1px solid #78b6ff22; border-radius: 18px; }
.speed-result strong { font-family: var(--nav-font); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.speed-result span { color: #99bce9; }
.speed-result small, .server-speed-results span { color: #9ca9bb; }
.server-speed-results > div { background: #ffffff04; border-radius: 12px; }
.speed-track { background: #ffffff0c; border-radius: 10px; }
.storage-card, .upload-zone { background: #191e27; border-color: var(--line); border-radius: 18px; }
.storage-copy p, .file-name small, .file-size, .no-files { color: var(--nav-secondary); }
.storage-track { background: #ffffff0d; border-radius: 10px; overflow: hidden; }
.upload-mark, .file-type { background: #25344a; color: #b7d8ff; border-radius: 10px; }
.file-list-head { border-color: var(--line); }
.file-row { border-color: #ffffff08; border-radius: 12px; }
.file-row:hover { background: #ffffff05; }
.file-actions a, .file-actions button { border-radius: 8px; }
.unlock-form > div { border: 0; gap: 10px; }
.unlock-form input { padding: 0 16px; }
.hero::after { color: var(--accent); }
.hero h1 { font-family: var(--nav-font); font-weight: 600; }
footer { border-color: var(--line); color: #80899a; font-family: var(--nav-font); letter-spacing: .02em; }
::-webkit-scrollbar { width: 8px; height: 6px; }
::-webkit-scrollbar-track { background: #0c0d10; }
::-webkit-scrollbar-thumb { background: #383d48; border: 2px solid #0c0d10; border-radius: 8px; }
@media (max-width: 1100px) {
  .link-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .directory-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .directory-head p { margin-left: 5px; }
}
@media (max-width: 760px) {
  .topbar, .hero, .directory, .file-shell, footer { width: calc(100% - 40px); }
  .topbar { min-height: 76px; height: auto; padding: 16px 0; }
  .brand-ip-list { display: grid; gap: 5px; }
  .brand-ip-list > span { height: 18px; max-width: 145px; font-size: 10px; justify-content: flex-start; }
  .directory-compact { padding-top: 22px; }
  .directory-tools { flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
  .compact-search { flex: 1 1 100%; width: 100%; height: 56px; }
  .bookmark-drop-zone { display: none; }
  .bookmark-import-button { height: 44px; width: 100%; }
  .tabs { flex-wrap: nowrap; width: 100%; overflow-x: auto; }
  .tabs button { flex: 0 0 auto; padding: 0 15px; }
  .directory-head { display: block; overflow: visible; }
  .directory-head p { display: none; }
  .link-group { padding: 22px 0 26px; gap: 14px; }
  .group-title { margin-bottom: 0; }
  .group-title h2 { font-size: 17px; }
  .link-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .link-card, .add-card { padding: 14px; min-height: 84px; border-radius: 16px; }
  .link-card-link { gap: 10px; }
  .favicon-shell, .letter-icon { width: 36px; height: 36px; flex-basis: 36px; border-radius: 10px; }
  .favicon-shell img { width: 24px; height: 24px; }
  .arrow { display: none; }
  .link-copy strong { font-size: 12px; }
  .link-copy small { font-size: 10px; }
  .modal { padding: 24px; border-radius: 20px; }
}
@media (max-width: 420px) {
  .topbar, .directory, .hero, .file-shell, footer { width: calc(100% - 28px); }
  .link-grid { grid-template-columns: 1fr; }
  .link-card, .add-card { min-height: 76px; }
  .link-copy strong { font-size: 14px; }
  .link-copy small { font-size: 11px; }
  .topbar nav { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}


/* Header navigation refinement: desktop and mobile share the same content order. */
.topbar {
  gap: 22px;
  height: auto;
  min-height: 88px;
}
.topbar-identity {
  flex: 1 1 auto;
  min-width: 0;
  gap: 18px;
}
.topbar-identity > .tabs {
  flex: 0 1 auto;
  min-width: 0;
}
.topbar nav {
  flex: 0 0 auto;
  gap: 17px;
  white-space: nowrap;
}
.topbar-action,
.topbar nav .nav-link,
.topbar nav .speed-button {
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  color: #b0b5c1;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font: 500 13px/1.35 var(--nav-font);
  letter-spacing: 0;
  cursor: pointer;
  transition: color .16s ease;
}
.topbar-action:hover,
.topbar nav .nav-link:hover,
.topbar nav .nav-link.active,
.topbar nav .speed-button:hover {
  color: var(--accent);
  background: transparent;
  border-color: transparent;
}
.topbar-action:focus-visible,
.topbar nav .nav-link:focus-visible,
.topbar nav .speed-button:focus-visible {
  outline-offset: 4px;
}
.directory-head { display: none; }
@media (max-width: 1160px) {
  .topbar { flex-wrap: wrap; align-content: center; padding: 14px 0; }
  .topbar-identity { flex: 1 1 100%; }
  .topbar nav { margin-left: auto; }
}
@media (max-width: 760px) {
  .topbar { gap: 12px; }
  .topbar-identity { align-items: flex-start; flex-direction: column; gap: 10px; }
  .brand-ip-list { display: flex; flex-wrap: wrap; gap: 5px 12px; }
  .brand-ip-list > span { width: auto; max-width: 155px; }
  .topbar-identity > .tabs { width: 100%; max-width: none; overflow-x: auto; flex-wrap: nowrap; }
  .topbar nav { flex: 1 1 100%; justify-content: flex-end; gap: 15px; padding-top: 2px; }
  .topbar-action,
  .topbar nav .nav-link,
  .topbar nav .speed-button { font-size: 13px; }
}
@media (max-width: 430px) {
  .topbar nav { justify-content: space-between; gap: 8px; }
  .topbar-action,
  .topbar nav .nav-link,
  .topbar nav .speed-button { font-size: 12px; }
}


/* Compact authenticated bookmark import in the top bar. */
.topbar-import-drop {
  display: flex;
  align-items: center;
  flex: 0 1 195px;
  min-width: 174px;
  height: 36px;
  gap: 8px;
  padding: 0 10px;
  color: #aeb6c4;
  background: rgba(255, 255, 255, .025);
  border: 1px dashed rgba(255, 255, 255, .16);
  border-radius: 10px;
  cursor: copy;
  transition: border-color .16s ease, background .16s ease;
}
.topbar-import-drop:hover,
.topbar-import-drop.active {
  background: rgba(54, 125, 222, .13);
  border-color: rgba(120, 177, 255, .72);
}
.topbar-import-drop > span {
  flex: 0 0 auto;
  color: #9dc7ff;
  font-size: 17px;
  font-weight: 300;
  line-height: 1;
}
.topbar-import-drop > div {
  min-width: 0;
  overflow: hidden;
}
.topbar-import-drop strong,
.topbar-import-drop small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-import-drop strong {
  color: #d8dce5;
  font: 500 12px/1.25 var(--nav-font);
}
.topbar-import-drop small {
  margin-top: 1px;
  color: #747d8d;
  font: 400 10px/1.25 var(--nav-font);
}
.topbar-action:disabled {
  color: #6e7480;
  cursor: wait;
}
@media (max-width: 760px) {
  .topbar-import-drop {
    width: 100%;
    max-width: none;
    flex-basis: auto;
  }
}


/* Keep the desktop category selector compact and on one row. */
@media (min-width: 761px) {
  .topbar-identity {
    gap: 14px;
  }
  .topbar-identity > .tabs {
    flex: 0 1 auto;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 4px;
    white-space: nowrap;
  }
  .topbar-identity > .tabs button {
    flex: 0 0 auto;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .topbar-import-drop {
    flex: 0 0 195px;
  }
}
