:root {
  color-scheme: dark;
  --bg: #101c30;
  --card: #172740;
  --ink: #f4f7fc;
  --mute: #bccce2;
  --line: #526582;
  --soft: #233752;
  --softink: #e3edfb;
  --pri: #a5c7ff;
  --acc: #a5c7ff;
  --ok: #7cddb0;
  --warn: #ffcd7a;
  --bad: #ffb3b3;
  --hero: #101c30;
}

body {
  min-height: 100svh;
}

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

body.account-gate {
  background: radial-gradient(ellipse at top, #23385b, #101c30 62%);
}

.account-gate .gate { margin: 2vh auto; box-shadow: 0 12px 48px #070d1c50; }
.pri { background: #3c67d4; color: #fff; border: 0; }
.danger { color: #101c30; }
.account-gate .sec { background: #233752; border: 1px solid #526582; }
.account-gate label { color: #e3edfb; }
.account-gate .gate form .pri { margin-top: 8px; }
.account-gate .gate > button { margin-top: 10px; }
.account-gate .err:empty { min-height: 0; }
.account-gate .password-field { display: flex; gap: 6px; align-items: center; }
.account-gate .password-field button { width: auto; margin: 0; flex: none; padding-inline: 8px; }
.account-gate .login-links button { min-height: 38px; margin-top: 0; font-size: 14px; }
#login #lCreate { color: var(--pri); text-decoration: underline; text-underline-offset: 3px; }

body.vault-shell main, body.vault-shell header .row { max-width: 1180px; }
#lockBtn, #gearBtn { width: auto; min-width: 44px; padding-inline: 9px; white-space: nowrap; }
.vault-title { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.vault-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; margin-bottom: 8px; }
.vault-meta .sum { margin: 0; font-size: 13px; }
.vault-meta #syncSt { font-weight: 600; }
.vault-toolbar, .admin-heading { display: flex; align-items: center; gap: 12px; }
.vault-toolbar input, .admin-heading h2 { flex: 1; min-width: 0; }
.vault-toolbar button { flex: none; }
#addBtn { padding-inline: 18px; font-weight: 700; }
#entryWorkspace.has-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
#entryDetail { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; overflow-wrap: anywhere; }
#entryDetail .detail-heading { display: flex; align-items: center; gap: 10px; }
#entryDetail h3 { flex: 1; margin: 0; }
.entry-star[aria-pressed="true"] { color: var(--warn); }
.entry-star { font-size: 21px; }

#adminNav { display: flex; flex-wrap: wrap; gap: 8px; }
#adminNav button[aria-current="page"] { background: var(--line); }
#adminContent { overflow-wrap: anywhere; }
.admin-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.admin-table th, .admin-table td { text-align: left; vertical-align: middle; padding: 10px; border-bottom: 1px solid var(--line); }
.admin-record { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.admin-record p { white-space: pre-wrap; }
.admin-form { max-width: 460px; }
.admin-form button, .admin-record button { margin: 10px 8px 0 0; }
.admin-form label:has([type="checkbox"]) { display: flex; align-items: center; gap: 8px; }
.admin-form input[type="checkbox"] { width: 20px; min-height: 20px; }

@media (max-width: 680px) {
  header .row { gap: 6px; }
  header .row > svg { display: none; }
  #lockBtn, #gearBtn { padding-inline: 5px; font-size: 14px; }
  #entryWorkspace.has-detail { display: block; }
  body.entry-open #list, body.entry-open #vault > :not(#entryWorkspace) { display: none !important; }
  #entryDetail { min-height: 55vh; }
  .vault-toolbar { gap: 8px; }
  #addBtn { padding-inline: 10px; font-size: 14px; }
  .admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .admin-table, .admin-table tbody { display: block; }
  .admin-table tr { display: block; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; padding: 8px; }
  .admin-table td { display: block; padding: 4px 6px; border: 0; }
}
.share-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.share-list { flex-direction: column; }
.share-list button { overflow-wrap: anywhere; text-align: left; }
.share-fields { margin: 12px 0; }
.share-fields dt { font-weight: 700; margin-top: 10px; }
.share-fields dd { margin: 2px 0; overflow-wrap: anywhere; }
.share-fields dd span { white-space: pre-wrap; }
.share-fields .ghost { width: auto; }

#tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0;
  padding: 5px;
  background: var(--card);
  border-radius: 14px;
}
#tabs button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-weight: 700;
  border-radius: 9px;
}
#tabs button:hover { background: var(--soft); color: var(--pri); }
#tabs button[aria-pressed="true"] { background: #3c67d4; color: #fff; }
#vaultPath { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#vaultPath #crumbs { min-width: 0; }
.category-home #vaultPath, .search-active #vaultPath, .search-active #kidChips { display: none; }
.folder-actions { position: relative; }
.folder-actions summary { min-width: 44px; min-height: 44px; display: grid; place-items: center; list-style: none; color: var(--pri); cursor: pointer; font-weight: 700; font-size: 20px; }
.folder-actions summary::-webkit-details-marker { display: none; }
.folder-actions[open] > div { position: absolute; inset-inline-end: 0; top: 100%; width: max-content; max-width: min(78vw, 270px); padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 10px 24px #0006; z-index: 2; }
.folder-actions button { min-height: 44px; }
#categoryHint { margin: 0 0 12px; color: var(--mute); font-size: 14px; }
.category-home #kidChips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(245px, 100%), 1fr));
  gap: 12px;
  margin: 16px 0 10px;
}
.category-home #kidChips .chip {
  display: flex;
  width: 100%;
  min-height: 76px;
  padding: 12px;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: left;
  font-size: 17px;
}
.category-home #kidChips .chip:hover { background: var(--soft); }
.category-icon {
  display: grid;
  flex: none;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  color: color-mix(in srgb, var(--category-color) 42%, white);
  background: color-mix(in srgb, var(--category-color) 20%, var(--soft));
}
.category-arrow { margin-inline-start: auto; padding-inline: 4px; color: var(--pri); font-size: 23px; }
.search-total, .share-empty { color: var(--mute); }
.share-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  margin: 0 0 8px;
  padding: 13px;
  text-align: start;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.share-card:hover { background: var(--soft); }
.share-card strong, .share-contact { overflow-wrap: anywhere; }
.share-contact { grid-column: 1 / -1; color: var(--mute); font-size: 14px; }
.share-badge { justify-self: start; align-self: start; padding: 4px 8px; background: var(--soft); color: var(--pri); border-radius: 8px; font-size: 12px; font-weight: 700; }
.share-badge.accepted { background: #1b473f; color: var(--ok); }
.share-badge.pending { background: #503f2f; color: var(--warn); }
.share-badge.ended { background: #532e3f; color: var(--bad); }
.entry-location, .entry-extras { margin-top: 16px; }
.entry-location { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.entry-location[open], .entry-extras[open] { padding-bottom: 12px; }
.entry-location summary, .entry-extras summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 50px; cursor: pointer; }
.entry-location small, .entry-location strong { display: block; overflow-wrap: anywhere; }
.entry-location small { color: var(--mute); }
.entry-extras summary, .location-change { color: var(--pri); font-weight: 700; }
.entry-extras summary::after { content: "›"; font-size: 21px; }
.entry-extras[open] summary::after { transform: rotate(90deg); }
.entry-location summary::-webkit-details-marker, .entry-extras summary::-webkit-details-marker { display: none; }
.entry-location label:first-of-type { margin-top: 6px; }
.card { margin-bottom: 8px; }
.card .body { display: flex; flex: 1; min-width: 0; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; }
.card .top { flex: 1; min-width: 0; }
.card .entry-star { width: 44px; height: 44px; min-height: 44px; flex: none; }
#list .card .chev { display: none; }
.card:has(.top[aria-expanded="true"]) { border-color: #5b8cff; box-shadow: 0 0 0 2px #5b8cff55; }
#list { padding-bottom: 20px; }
#lockBtn, #gearBtn { align-items: center; justify-content: center; gap: 6px; }
#lockBtn:not(.hide), #gearBtn:not(.hide) { display: inline-flex; }
#lockBtn::before, #gearBtn::before { content: ""; width: 21px; height: 21px; flex: none; background: currentColor; mask: var(--header-icon) center / contain no-repeat; }
#lockBtn { --header-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E"); }
#gearBtn { --header-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.5-4 4.5-6 8-6s6.5 2 8 6'/%3E%3C/svg%3E"); }

@media (min-width: 681px) {
  #entryDetail { position: sticky; top: 84px; }
}
@media (min-width: 1000px) {
  body.vault-shell:has(#vault:not(.hide)) { padding-left: 280px; }
  body.vault-shell:has(#vault:not(.hide)) #navBtn { display: none; }
  #drawer.on { width: 280px; box-shadow: none; border-right: 1px solid var(--line); }
  #drawer .drawer-hint, #drawer #dClose { display: none; }
}

@media (max-width: 680px) {
  #lockBtn, #gearBtn { font-size: 0; gap: 0; }
  #tabs button { font-size: 14px; }
  .category-home #kidChips { grid-template-columns: 1fr; margin-top: 16px; }
  #entryDetail .acts [data-del] {
    flex: 1 0 100%;
    margin-top: 10px;
    border: 1px solid var(--bad);
    color: var(--bad);
  }
}
