/* 家庭相册 web: the Android app's design tokens (values/colors.xml, values-night). Calm,
   big text and tap targets for older family members. 360 px phone width up to a PC. */
:root {
  --bg: #F7F6F3; --card: #FFFFFF; --text: #1C1B19; --text2: #6B6862; --text3: #4A4843;
  --accent: #0F766E; --accent-pressed: #115E59; --on-accent: #FFFFFF; --tile: #E6F2F0;
  --outline: #8F8A81; --border: #D6D3CC; --divider: #EEECE7; --warn-bg: #FEF3C7; --warn-text: #78350F;
  --viewer: #121211; --viewer-text: #F2F1EE; --viewer-text2: #B9B6AF; --viewer-panel: #2A2927;
  --ph: #E7E5E0; --danger: #B91C1C; --heart: #D64545; --heart-viewer: #FF7A7A;
  --ok-bg: #DCFCE7; --ok: #15803D; --snack-bg: #2E2C28; --snack-text: #F2F1EE; --snack-action: #5EEAD4;
  --scrim: rgba(0, 0, 0, .4);
  --top: 56px; --tabs: 64px; --side: 212px;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --card: #1F1E1C; --text: #EDEBE6; --text2: #A9A59D; --text3: #C9C5BD;
    --accent: #2DD4BF; --accent-pressed: #5EEAD4; --on-accent: #062421; --tile: #173A35;
    --outline: #807B73; --border: #3A3833; --divider: #2A2926; --warn-bg: #3B2F12; --warn-text: #FCD34D;
    --ph: #2A2926; --danger: #F87171; --heart: #FF7A7A; --ok-bg: #12301E; --ok: #4ADE80;
    --snack-bg: #EDEBE6; --snack-text: #1C1B19; --snack-action: #0F766E;
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
}
body.noscroll { overflow: hidden; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.big { width: 40px; height: 40px; }
.ic.huge { width: 64px; height: 64px; stroke-width: 1.5; }
.muted { color: var(--text2); }
.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-msg { color: var(--text2); text-align: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- buttons, fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 24px; border: 1px solid var(--outline);
  background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-pressed); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.dlg .btn.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 16px; }
.btn.small .ic { width: 20px; height: 20px; }
.btn.big { min-height: 56px; font-size: 19px; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 8px 4px; color: var(--accent); cursor: pointer; text-decoration: underline; min-height: 44px; }
.link.light { color: var(--snack-action); }
.field {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--outline);
  background: var(--card); color: var(--text); font-size: 18px;
}
.field:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field.code { font-size: 30px; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px; text-align: center; }
.auth-logo img { width: 64px; height: 64px; }
.auth-title { margin: 8px 0 18px; font-size: 26px; font-weight: 600; }
.auth-lead { margin: 0 0 18px; color: var(--text3); }
.auth-form { display: grid; gap: 12px; text-align: left; }
.auth-label { font-weight: 600; font-size: 18px; }
.auth-form .muted { margin: -6px 0 0; font-size: 15px; }
.auth-form .link { justify-self: center; }
.auth-msg { min-height: 1.5em; margin: 14px 0 0; }
.auth-msg.bad { color: var(--danger); font-weight: 600; }
.auth-msg.info { color: var(--text2); }
.auth-foot { margin: 18px 0 0; font-size: 15px; color: var(--text2); }
.auth-ok { color: var(--ok); }
.ic.ok { stroke: var(--ok); }

/* ---------------------------------------------------------------- shell */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 4px;
  padding: 0 8px 0 16px; background: var(--bg); border-bottom: 1px solid var(--divider);
}
.top-title { flex: 1; margin: 0; font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-back { display: inline-flex; align-items: center; gap: 2px; min-height: 48px; padding: 0 8px 0 0; margin-left: -8px; color: var(--text); text-decoration: none; }
.top-back-t { display: none; }
.top-actions { display: flex; gap: 2px; }
.top-btn { display: inline-flex; align-items: center; gap: 6px; min-width: 48px; min-height: 48px; justify-content: center; padding: 0 8px; background: none; border: 0; border-radius: 24px; color: var(--text); cursor: pointer; text-decoration: none; }
.top-btn:hover { background: var(--divider); }
.top-btn-t { display: none; font-size: 16px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--tabs); display: flex;
  background: var(--card); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text2); text-decoration: none; font-size: 14px; min-width: 0; }
.tab.on { color: var(--accent); font-weight: 600; }
.side-extra { display: none; }
.main { padding: 0 0 calc(var(--tabs) + 24px); min-height: calc(100vh - var(--top)); }
.page { padding: 12px 12px 0; }

@media (min-width: 900px) {
  .tabs { top: 0; bottom: 0; right: auto; width: var(--side); height: auto; flex-direction: column; justify-content: flex-start; gap: 2px; padding: 72px 12px 12px; border-top: 0; border-right: 1px solid var(--border); }
  .tab, .side-link { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 24px; font-size: 17px; color: var(--text); }
  .tab.on { background: var(--tile); color: var(--accent); }
  .tab:hover, .side-link:hover { background: var(--divider); }
  .side-extra { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--divider); }
  .side-link { display: flex; align-items: center; text-decoration: none; }
  .topbar, .main { margin-left: var(--side); }
  .topbar { padding: 0 16px 0 24px; }
  .main { padding-bottom: 32px; }
  .page { padding: 16px 24px 0; }
  .top-btn-t, .top-back-t { display: inline; }
  .top-back { margin-left: 0; padding-right: 12px; }
}

/* ---------------------------------------------------------------- common blocks */
.toolrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; margin: 0 0 12px; }
.seg { display: inline-flex; background: var(--divider); border-radius: 24px; padding: 3px; margin: 0 0 12px; max-width: 100%; }
.toolrow .seg { margin: 0; }
.seg-b { min-height: 44px; min-width: 64px; padding: 0 16px; border: 0; border-radius: 22px; background: none; cursor: pointer; color: var(--text3); font-size: 17px; }
.seg-b.on { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.sect { font-size: 19px; font-weight: 600; margin: 20px 0 10px; }
.sub { font-size: 16px; color: var(--text2); font-weight: 600; margin: 12px 0 8px; }
.empty { padding: 48px 16px; text-align: center; color: var(--text2); list-style: none; }
.note { background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; font-size: 16px; }
.lead { color: var(--text3); margin: 4px 0 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 13px; background: var(--divider); color: var(--text3); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.badge.share { background: var(--tile); color: var(--accent); }
.warn-text { color: var(--danger); }

/* cards: albums, years, months, places, people */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; } }
.card { display: block; text-align: left; padding: 0; border: 0; background: none; cursor: pointer; min-width: 0; color: var(--text); }
.card-pic { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--ph); }
.card-img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .15s; }
.card-img.ok { opacity: 1; }
.card-icon { width: 100%; height: 100%; display: grid; place-items: center; background: var(--tile); color: var(--accent); }
.card-t { margin-top: 6px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-s { font-size: 14px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card:hover .card-pic { outline: 2px solid var(--accent); outline-offset: 2px; }

.memory { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--card); cursor: pointer; text-align: left; color: var(--text); }
.memory .card-img { width: 84px; height: 84px; border-radius: 10px; flex: none; background: var(--ph); }
.memory-k { color: var(--accent); font-weight: 600; font-size: 18px; }
.memory-l { color: var(--text2); font-size: 15px; }
.album-head { min-width: 0; }
.album-desc { margin: 4px 0 0; color: var(--text3); }

/* ---------------------------------------------------------------- photo grid */
.grid { position: relative; width: 100%; }
.grid-h { position: absolute; left: 0; right: 0; height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 17px; padding: 0 2px; }
.grid-h .link { font-weight: 400; font-size: 15px; }
.grid-r { position: absolute; left: 0; right: 0; display: flex; gap: 3px; }
.tile { position: relative; padding: 0; border: 0; background: var(--ph); cursor: pointer; overflow: hidden; flex: none; border-radius: 2px; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; }
.tile img.ok { opacity: 1; }
.tile-video, .tile-fav, .tile-shared { position: absolute; display: grid; place-items: center; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.tile-video { left: 4px; bottom: 4px; }
.tile-video .ic { fill: #fff; stroke: none; width: 20px; height: 20px; }
.tile-fav { right: 4px; bottom: 4px; }
.tile-fav .ic { fill: var(--heart-viewer); stroke: none; width: 18px; height: 18px; }
.tile-shared { left: 4px; top: 4px; }
.tile-shared .ic { width: 18px; height: 18px; }
.tile-badge { position: absolute; left: 3px; bottom: 3px; padding: 0 5px; border-radius: 8px; font-size: 11px; line-height: 18px; background: rgba(21, 128, 61, .92); color: #fff; white-space: nowrap; max-width: calc(100% - 6px); overflow: hidden; }
.tile-check { position: absolute; right: 5px; top: 5px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); display: grid; place-items: center; }
.tile-check .ic { width: 18px; height: 18px; stroke: #fff; stroke-width: 3; opacity: 0; }
.tile.sel img { transform: scale(.9); border-radius: 6px; }
.tile.sel { background: var(--tile); }
.tile.sel .tile-check { background: var(--accent); border-color: #fff; }
.tile.sel .tile-check .ic { opacity: 1; }
.tile:focus-visible { outline-offset: -3px; }

.selbar {
  position: fixed; z-index: 25; left: 8px; right: 8px; bottom: calc(var(--tabs) + 8px); display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.selbar-n { font-weight: 600; flex: 1 0 100%; }
.selbar .btn { min-height: 44px; padding: 0 12px; font-size: 16px; }
@media (min-width: 900px) { .selbar { left: calc(var(--side) + 24px); right: 24px; bottom: 16px; } .selbar-n { flex: 0 0 auto; margin-right: 8px; } }

/* ---------------------------------------------------------------- viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--viewer); color: var(--viewer-text); display: flex; flex-direction: column; }
.v-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: pan-y pinch-zoom; }
.v-media { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
video.v-media { width: 100%; height: 100%; }
.v-file { display: grid; place-items: center; gap: 12px; color: var(--viewer-text2); }
.v-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.v-title { flex: 1; text-align: center; min-width: 0; padding-right: 64px; }
.v-date { font-weight: 600; }
.v-pos { font-size: 14px; color: var(--viewer-text2); }
.v-foot { background: var(--viewer-panel); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.v-line { min-height: 1.4em; text-align: center; font-size: 14px; color: var(--viewer-text2); padding: 2px 8px; }
.v-bottom { display: flex; justify-content: space-around; gap: 4px; }
.v-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 64px; min-height: 56px; padding: 4px 8px; border: 0; border-radius: 12px; background: none; color: var(--viewer-text); cursor: pointer; text-decoration: none; font-size: 14px; }
.v-btn:hover { background: rgba(255,255,255,.08); }
.v-btn.on .ic { fill: var(--heart-viewer); stroke: var(--heart-viewer); }
.v-btn.danger { color: #FCA5A5; }
.v-btn.accent { color: var(--snack-action); font-weight: 600; }
.v-back { flex-direction: row; min-width: 0; font-size: 16px; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 72px; border: 0; border-radius: 12px; background: rgba(0,0,0,.35); color: #fff; cursor: pointer; display: none; place-items: center; }
.v-nav:disabled { opacity: .25; cursor: default; }
.v-prev { left: 12px; } .v-next { right: 12px; }
@media (min-width: 700px) and (hover: hover) { .v-nav { display: grid; } }

/* ---------------------------------------------------------------- dialogs, toast */
.dlg { border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
.dlg::backdrop { background: var(--scrim); }
.dlg form { padding: 22px 20px 16px; display: grid; gap: 12px; }
.dlg-title { margin: 0; font-size: 20px; }
.dlg-text { margin: 0; color: var(--text3); }
.dlg-buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.info dt { color: var(--text2); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabs) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--snack-bg); color: var(--snack-text); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-act { background: none; border: 0; color: var(--snack-action); font-weight: 600; cursor: pointer; min-height: 40px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---------------------------------------------------------------- upload */
.drop { border: 2px dashed var(--outline); border-radius: 16px; padding: 24px 16px; text-align: center; background: var(--card); color: var(--text2); }
.drop.over { border-color: var(--accent); background: var(--tile); color: var(--accent); }
.drop-text { margin: 8px 0 14px; }
.drop-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.uq { margin: 16px 0; }
.uq-sum { margin: 0 0 8px; }
.uq-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.uq-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.uq-name { font-weight: 600; overflow-wrap: anywhere; }
.uq-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 15px; color: var(--text2); }
.uq-bar { height: 6px; background: var(--divider); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.uq-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.uq-item.ok .uq-st { color: var(--ok); font-weight: 600; }
.uq-item.fail .uq-st { color: var(--danger); }
.uq-item.skip .uq-st { color: var(--warn-text); }

/* ---------------------------------------------------------------- 我的 */
.locked { text-align: center; padding: 48px 16px; max-width: 460px; margin: 0 auto; color: var(--text2); }
.locked .ic { color: var(--accent); }
.locked-t { color: var(--text); font-size: 22px; margin: 12px 0 8px; }
.locked-note { color: var(--warn-text); background: var(--warn-bg); border-radius: 10px; padding: 10px; }
.locked .btn { margin-top: 12px; min-width: 200px; }
.mine-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px; margin: 0 0 12px; border-radius: 12px; background: var(--tile); color: var(--accent); }
.mine-bar-t { flex: 1; min-width: 160px; font-size: 15px; }
.mine-bar.warn { background: var(--warn-bg); color: var(--warn-text); }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0 0 10px; font-size: 18px; }
.crumbs a { padding: 6px 2px; }
.crumb-sep { color: var(--text2); }
.files { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px solid var(--divider); }
.frow { display: flex; align-items: stretch; border-bottom: 1px solid var(--divider); }
.frow-sel { display: grid; place-items: center; width: 52px; flex: none; cursor: pointer; }
.frow-check { width: 24px; height: 24px; accent-color: var(--accent); cursor: pointer; }
.frow.folder .frow-main { padding-left: 52px; }
.frow-main {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 10px 8px 10px 0; background: none; border: 0; text-align: left; color: var(--text); text-decoration: none; cursor: pointer; min-height: 64px;
}
.frow-ic { grid-row: span 2; width: 48px; height: 48px; border-radius: 8px; background: var(--tile); color: var(--accent); display: grid; place-items: center; overflow: hidden; }
.frow-ic img { width: 100%; height: 100%; object-fit: cover; }
.frow-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow-meta { font-size: 14px; color: var(--text2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.frow-badges { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.frow.folder .frow-meta { grid-column: 2; }
.frow-main:hover .frow-name { color: var(--accent); }
.mine .drop { margin-top: 4px; }

/* ---------------------------------------------------------------- map, search */
.map-page { padding: 0; position: relative; }
.map-box { height: calc(100vh - var(--top) - var(--tabs)); width: 100%; background: var(--ph); }
@media (min-width: 900px) { .map-box { height: calc(100vh - var(--top)); } }
.map-page + * { display: none; }
body[data-route="map"] .main { padding-bottom: 0; }
.map-status { position: absolute; top: 12px; left: 12px; right: 12px; margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--card); color: var(--text2); text-align: center; }
.map-status.bad { color: var(--danger); }
.map-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 55%; overflow: auto; background: var(--bg); border-radius: 16px 16px 0 0; padding: 8px 10px 12px; box-shadow: 0 -6px 24px rgba(0,0,0,.2); z-index: 5; }
.map-sheet-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 8px; }
.search-form { display: flex; gap: 8px; margin: 0 0 8px; }
.search-form .field { flex: 1; min-width: 0; }

/* the selection bar never hides the last rows: room to scroll them above it */
.main:has(.selbar:not([hidden])) { padding-bottom: calc(var(--tabs) + 200px); }
@media (min-width: 900px) { .main:has(.selbar:not([hidden])) { padding-bottom: 120px; } }
