:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #28201e;
  background: #f8f7f5;
  --accent: #a53527;
  --border: #e6dfdb;
  --secondary: #695e57;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.2; }
h1 { font-size: clamp(1.65rem, 4vw, 2.1rem); }
h2 { font-size: 1.25rem; }
button, input { font: inherit; }
button, .quiet, .primary, .secondary { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: auto;
  max-width: 126rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: inherit;
  font-size: 1.35rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.brand-icon {
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  place-items: center;
  border-radius: .55rem;
  background: var(--accent);
}
.brand-icon::after { content: ""; width: .68rem; height: .92rem; background: #fff; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }

.account { display: flex; align-items: center; min-width: 0; gap: .35rem; color: var(--secondary); font-size: .875rem; }
#email { overflow: hidden; text-overflow: ellipsis; }
.account button { flex-shrink: 0; }

main { margin: auto; max-width: 126rem; padding: 1.6rem clamp(1rem, 4vw, 2.5rem) 3rem; }
.panel { min-width: 0; background: #fffdfb; border: 1px solid var(--border); border-radius: 1.15rem; padding: clamp(1rem, 3vw, 1.75rem); }
.signin { max-width: 30rem; margin: clamp(1rem, 12vh, 6rem) auto; }
.signin p { color: var(--secondary); margin: .75rem 0 1.2rem; }
.library-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .65rem; }
.detail { color: var(--secondary); font-size: .875rem; overflow-wrap: anywhere; }

.toolbar { display: flex; align-items: center; gap: .6rem; margin: 1rem 0 1.2rem; }
.filters { display: flex; gap: .15rem; padding: .2rem; border: 1px solid var(--border); border-radius: .7rem; background: #f0ebe6; }
.filters button { min-height: 2.45rem; padding: .25rem .8rem; border: 0; border-radius: .5rem; background: transparent; color: #544945; cursor: pointer; white-space: nowrap; }
.filters [aria-pressed="true"] { background: #fff; color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px #2b200f1a; }
.toolbar > input.search { max-width: 25rem; }
#open-backups { white-space: nowrap; margin-inline-start: auto; }

.add-favorite { display: grid; grid-template-columns: 1fr; gap: .45rem; margin-top: 1rem; }
label { font-size: .9375rem; font-weight: 650; }
.add-favorite input + label { margin-top: .35rem; }
input:not([type="file"]), select { font: inherit; width: 100%; min-height: 2.75rem; min-width: 0; padding: .55rem .8rem; color: inherit; background: #fff; border: 1px solid #cbbfb7; border-radius: .6rem; }

.primary, .secondary, .quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .45rem .8rem;
  border: 1px solid transparent;
  border-radius: .6rem;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: #84271c; }
.secondary { color: var(--accent); background: #fbeee7; border-color: #edcfc3; }
.secondary:hover, .quiet:hover { background: #f4e8e1; }
.quiet { color: var(--accent); background: transparent; }
button:disabled { opacity: .55; cursor: wait; }

.backup-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; margin-top: .45rem; }
.favorites, .snapshots { list-style: none; margin: 0; padding: 0; }
.favorites { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.favorite {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: .85rem;
  background: #fff;
  box-shadow: 0 2px 6px #27211c0b;
}
.cover {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(140deg, #67443d, #372822);
  color: #fff;
  text-decoration: none;
}
.favorite[data-type="website"] .cover { background: linear-gradient(135deg, #dfb098, #915f54 57%, #414d4e); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-mark { padding-bottom: 1.25rem; font-size: 3rem; font-weight: 750; letter-spacing: -.12em; opacity: .84; }
.cover-caption {
  display: grid;
  gap: .1rem;
  position: absolute;
  inset: auto 0 0;
  padding: 1.25rem .8rem .55rem;
  background: linear-gradient(transparent, #191411b8 44%, #191411e8);
  font-size: .875rem;
  line-height: 1.35;
  color: #fff;
}
.cover-source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.cover-caption time { color: #f5e7df; }
.favorite-body { display: flex; flex-direction: column; flex: 1; padding: .75rem .8rem .35rem; }
.favorite-body h2 { min-height: 2.65em; font-size: 1.025rem; line-height: 1.325; }
.favorite-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; color: inherit; text-decoration: none; }
.favorite-title:hover { text-decoration: underline; }
.favorite-actions { display: flex; gap: .3rem; margin-top: auto; border-top: 1px solid #eee7e1; padding-top: .2rem; }
.favorite-actions :is(a, button) { flex: 1; }
.favorite-actions .remove { color: var(--secondary); }
.snapshot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-bottom: 1px solid var(--border); padding-block: .65rem; }
.snapshot:last-child { border-bottom: 0; }
.empty { padding: .85rem; color: var(--secondary); }

#status { color: var(--secondary); margin-bottom: .85rem; }
#status:empty { display: none; }
#status[data-error] { color: #85271b; }
dialog { width: min(calc(100% - 2rem), 28rem); padding: 1.25rem; border: 1px solid var(--border); border-radius: 1rem; color: inherit; background: #fffdfb; }
.backup-dialog { width: min(calc(100% - 2rem), 35rem); }
dialog::backdrop { background: #23181388; }
dialog p { margin-block: .75rem 1rem; }
.snapshot p { margin: .15rem 0 0; }
.form-error { color: var(--secondary); margin-block: .25rem; }
.form-error[data-error] { color: #85271b; }
.form-error:empty { display: none; }
.dialog-actions { display: flex; justify-content: end; gap: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 38rem) {
  .toolbar { flex-wrap: wrap; }
  .toolbar > input.search { order: 1; max-width: none; }
  .favorites { gap: .85rem; }
}
