:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --line: #d9ded6;
  --text: #1e2528;
  --muted: #667276;
  --accent: #1f7a6d;
  --accent-strong: #155f55;
  --danger: #a73535;
  --shadow: 0 10px 30px rgb(31 42 38 / 10%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.page {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.narrow {
  width: min(720px, calc(100% - 32px));
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.muted,
.file-meta,
.breadcrumbs,
small {
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: #aeb9b2;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #d6afaf;
  color: var(--danger);
}

.button.compact {
  min-height: 32px;
  padding: 5px 10px;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
}

.notice.subtle {
  background: #fafffd;
}

.notice.danger {
  border-color: #e2baba;
  background: #fff5f5;
  color: var(--danger);
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.album-card {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.album-card:hover {
  border-color: var(--accent);
}

.album-name {
  overflow-wrap: anywhere;
  font-weight: 700;
  font-size: 20px;
}

.album-meta {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-bottom: 3px solid transparent;
  padding: 8px 14px;
  color: var(--muted);
  text-decoration: none;
}

.tabs a.active {
  border-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

.people-panel,
.selection-bar,
.share-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0;
  padding: 14px;
  background: var(--surface);
}

.people-head,
.selection-bar,
.share-form,
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.people-head {
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 12px;
}

.people-head select,
.share-form input,
.auth-panel input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.person-chip {
  display: grid;
  grid-template-columns: 18px 44px minmax(80px, 1fr) auto;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}

.person-chip.avatar-only {
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  max-width: none;
  border-radius: 50%;
  padding: 3px;
}

.person-chip.avatar-only.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(31 122 109 / 18%);
}

.person-chip.avatar-only input {
  position: absolute;
  top: -2px;
  left: -2px;
  z-index: 2;
  width: 16px;
  height: 16px;
  margin: 0;
}

.person-chip img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e7ece8;
}

.person-chip.avatar-only img {
  width: 100%;
  height: 100%;
}

.person-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  justify-content: flex-end;
  box-shadow: var(--shadow);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.media-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-link {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  background: #dfe6e2;
}

.preview-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.select-corner {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: rgb(255 255 255 / 88%);
}

.select-corner input {
  width: 18px;
  height: 18px;
}

.play-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgb(0 0 0 / 62%);
  color: white;
}

.media-info {
  display: grid;
  gap: 5px;
  padding: 10px;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.file-warning {
  color: var(--danger);
  font-size: 12px;
}

.download-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.share-panel {
  margin-top: 26px;
}

.share-form {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.share-form label,
.auth-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.share-list {
  display: grid;
  gap: 10px;
}

.share-row {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.share-row.disabled {
  opacity: 0.58;
}

.share-row code {
  display: block;
  overflow: hidden;
  max-width: min(760px, 70vw);
  margin: 4px 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px 0;
}

.auth-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(13 17 18 / 84%);
}

.modal-body {
  position: absolute;
  inset: 24px;
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
}

.modal-stage {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-stage img,
.modal-stage video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
  box-shadow: 0 20px 60px rgb(0 0 0 / 34%);
}

.modal-stage video {
  width: 100%;
  height: 100%;
}

.modal-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.modal-title {
  flex: 0 0 auto;
  margin: 0;
  color: #fff;
  text-align: center;
}

.modal-download {
  flex: 0 0 auto;
  border: 1px solid rgb(255 255 255 / 62%);
  border-radius: 8px;
  padding: 7px 12px;
  color: #fff;
  text-decoration: none;
}

.modal-download:hover {
  background: rgb(255 255 255 / 12%);
}

.modal-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  color: #111;
  font-size: 28px;
  cursor: pointer;
}

.modal-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  width: 46px;
  height: 64px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: rgb(255 255 255 / 86%);
  color: #111;
  font-size: 44px;
  line-height: 1;
  cursor: pointer;
}

.modal-nav:hover {
  background: #fff;
}

.modal-prev {
  left: 0;
}

.modal-next {
  right: 0;
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .topbar,
  .people-head,
  .selection-bar,
  .share-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .top-actions .button,
  .top-actions form,
  .top-actions button,
  .selection-bar button {
    width: 100%;
  }

  h1 {
    font-size: 26px;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 10px;
  }

  .person-chip {
    max-width: 100%;
  }

  .share-row code {
    max-width: calc(100vw - 58px);
  }

  .modal-body {
    inset: 12px;
  }

  .modal-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .modal-title {
    font-size: 14px;
  }

  .modal-download {
    text-align: center;
  }

  .modal-nav {
    width: 38px;
    height: 54px;
    font-size: 36px;
  }
}
