:root {
  color-scheme: light;
  --paper: #f4f4f4;
  --surface: #ffffff;
  --surface-soft: #ececec;
  --ink: #0f0f0f;
  --ink-soft: #303030;
  --muted: #6f6f6f;
  --line: #d5d5d5;
  --accent: #2c2c2c;
  --accent-soft: #e2e2e2;
  --danger: #555555;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.12);
  --radius-sm: 14px;
  --radius-md: 22px;
  --radius-lg: 32px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 85% -5%, rgba(0, 0, 0, 0.055), transparent 30rem),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 42%, #eeeeee 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(0, 0, 0, 0.22);
  outline-offset: 2px;
}

.svg-sprite,
.hidden-input {
  display: none;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 18px calc(112px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(150px, 420px) auto;
  align-items: center;
  gap: 14px;
  margin: 0 -18px;
  padding: max(12px, env(safe-area-inset-top, 0px)) 18px 12px;
  border-bottom: 1px solid rgba(205, 205, 205, 0.8);
  background: rgba(248, 248, 248, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-style: italic;
}

.brand-copy {
  display: grid;
}

.brand-copy strong {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.brand-copy small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
}

.search-shell input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.search-shell input::placeholder {
  color: #9b9b9b;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
}

.icon-button.danger {
  color: var(--danger);
}

.topbar-add {
  justify-self: end;
}

main {
  padding-top: 34px;
}

.view[hidden],
.viewer[hidden],
.empty-state[hidden] {
  display: none !important;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 12px 2px 38px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: Avenir Next, Helvetica Neue, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(36px, 6vw, 72px);
  font-weight: 400;
  letter-spacing: -0.06em;
  line-height: 1.05;
}

.hero-actions,
.toolbar-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.button-secondary {
  color: var(--ink-soft);
}

.library-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.library-meta p {
  margin: 0;
}

.library-meta strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-top: 20px;
}

.album-card {
  position: relative;
  min-width: 0;
}

.album-open {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.album-cover {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1.18;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 16%, rgba(255, 255, 255, 0.62), transparent 30%),
    linear-gradient(140deg, #d8d8d8, #929292 56%, #4d4d4d);
  color: rgba(255, 255, 255, 0.86);
}

.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(13, 12, 11, 0.65), transparent 54%);
  pointer-events: none;
}

.album-cover-placeholder {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 56px;
  font-style: italic;
}

.album-info {
  position: absolute;
  right: 13px;
  bottom: 13px;
  left: 13px;
  z-index: 1;
  color: white;
}

.album-info strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-info span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.album-more {
  position: absolute;
  z-index: 3;
  top: 9px;
  right: 9px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(15, 14, 13, 0.46);
  color: white;
  backdrop-filter: blur(10px);
}

.empty-state {
  max-width: 620px;
  margin: 56px auto 0;
  padding: 54px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.empty-state.compact {
  margin-top: 22px;
}

.empty-state h2 {
  margin: 20px 0 8px;
  font-size: 24px;
  font-weight: 500;
}

.empty-state p {
  max-width: 430px;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.empty-art {
  position: relative;
  display: inline-flex;
  width: 114px;
  height: 86px;
  align-items: end;
  justify-content: center;
}

.empty-art span {
  display: block;
  width: 42px;
  height: 58px;
  border: 1px solid #bdbdbd;
  border-radius: 12px;
  background: #ededed;
  transform: rotate(-10deg) translateX(12px);
}

.empty-art span:nth-child(2) {
  z-index: 2;
  height: 70px;
  background: #c7c7c7;
  transform: translateY(-4px);
}

.empty-art span:nth-child(3) {
  transform: rotate(10deg) translateX(-12px);
}

.empty-art.small {
  width: 90px;
  height: 68px;
}

.album-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.album-heading {
  min-width: 0;
  flex: 1;
}

.album-heading h1 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 400;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-subline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0 5px;
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
}

.image-tile {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  aspect-ratio: 1;
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-tile .cover-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: rgba(20, 18, 16, 0.66);
  color: #fff;
  backdrop-filter: blur(8px);
}

.image-tile .cover-badge .icon {
  width: 14px;
  height: 14px;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: max(14px, calc((100vw - 760px) / 2));
  bottom: calc(12px + var(--safe-bottom));
  left: max(14px, calc((100vw - 760px) / 2));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  min-height: 70px;
  padding: 6px;
  border: 1px solid rgba(210, 203, 194, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 50px rgba(42, 36, 30, 0.16);
  backdrop-filter: blur(22px);
}

.bottom-nav-item {
  display: grid;
  min-height: 56px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.bottom-nav-item[aria-current="page"] {
  background: var(--surface-soft);
  color: var(--ink);
}

.bottom-nav-item.emphasis .icon {
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
}

.dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(22, 20, 18, 0.44);
  backdrop-filter: blur(8px);
}

.dialog form {
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfaf8;
  color: var(--ink);
  font-size: 16px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 24px;
}

.viewer {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(13, 12, 11, 0.96);
  color: white;
}

.viewer-top {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top, 0px)) 16px 10px;
}

.viewer-top p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  text-align: center;
}

.viewer-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.viewer > img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.viewer-arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: grid;
  width: 46px;
  height: 58px;
  place-items: center;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  transform: translateY(-50%);
}

.viewer-arrow.left {
  left: 12px;
}

.viewer-arrow.right {
  right: 12px;
}

.viewer-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px calc(18px + var(--safe-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.viewer-actions button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 12px;
}

.viewer-actions button.danger {
  color: #d0d0d0;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 18px;
  bottom: calc(98px + var(--safe-bottom));
  left: 18px;
  width: fit-content;
  max-width: calc(100vw - 36px);
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(26, 24, 22, 0.92);
  color: white;
  font-size: 13px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

@media (min-width: 640px) {
  .app-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .topbar {
    margin-right: -28px;
    margin-left: -28px;
    padding-right: 28px;
    padding-left: 28px;
  }

  .album-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .image-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 900px) {
  .album-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .image-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    margin-right: -14px;
    margin-left: -14px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .brand-copy {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-bottom: 26px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button {
    padding-right: 14px;
    padding-left: 14px;
  }

  .library-meta {
    gap: 8px 15px;
  }

  .library-meta p:last-child {
    width: 100%;
  }

  .album-info strong {
    font-size: 13px;
  }

  .album-more {
    width: 34px;
    height: 34px;
  }

  .viewer-actions {
    justify-content: stretch;
  }

  .viewer-actions button {
    flex: 1;
    justify-content: center;
    padding-right: 8px;
    padding-left: 8px;
  }

  .viewer-actions button .icon {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .album-open,
  .image-tile,
  .button,
  .icon-button,
  .bottom-nav-item {
    transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
  }

  .album-open:active,
  .image-tile:active,
  .button:active,
  .icon-button:active,
  .bottom-nav-item:active {
    transform: scale(0.98);
  }
}



.sort-albums-button {
  margin-left: auto;
  color: var(--ink);
  font-weight: 500;
}

.sort-albums-button[aria-pressed="true"] {
  color: var(--muted);
}

.search-results {
  padding-top: 30px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.album-sort-controls {
  position: absolute;
  z-index: 4;
  right: 9px;
  bottom: 9px;
  left: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(10, 10, 10, 0.76);
  backdrop-filter: blur(10px);
}

.album-sort-controls button {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 10px;
  background: transparent;
  color: white;
}

.album-card.sorting .album-info {
  bottom: 62px;
}

.image-tag-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.image-tile .cover-badge + .image-tag-badge {
  right: 42px;
}

.tag-editor {
  display: flex;
  min-height: 44px;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  padding: 10px 0 18px;
}

.tag-editor:empty::before {
  content: "还没有标签";
  color: var(--muted);
  font-size: 13px;
}

.tag-chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
}

.tag-chip button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #d2d2d2;
  color: #222;
  font-size: 12px;
  line-height: 1;
}

.tag-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.tag-field input {
  min-width: 0;
}

.field-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .sort-albums-button {
    width: 100%;
    margin-left: 0;
    text-align: left;
  }

  .tag-entry {
    grid-template-columns: 1fr;
  }

  .tag-entry .button {
    width: 100%;
  }
}

.backup-dialog .dialog-body {
  padding: 24px;
}

.backup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 0;
}

.backup-actions .button {
  width: 100%;
}

@media (max-width: 480px) {
  .backup-actions {
    grid-template-columns: 1fr;
  }
}
