/* fotoaman web. Colours follow the mobile app: #3478F6 blue, #FF3B30 red,
   and the iOS system greys. Button fills are a shade darker than the brand
   blue, because white on #3478F6 is 4.07:1, under WCAG's 4.5:1. */

:root {
  --accent: #1d6ae5;
  --accent-text: #1d5fd6;
  --on-accent: #ffffff;
  --danger: #d70015;
  --danger-fill: #d70015;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #5c5c63;
  --line: #d1d1d6;
  --chip: #e8f0fe;
  --chip-text: #1b4fae;
  --placeholder: #e5e5ea;
  --radius: 12px;
  --tabbar-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2f6fe0;
    --accent-text: #79a9ff;
    --danger: #ff6961;
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f2f2f7;
    --muted: #a1a1a8;
    --line: #3a3a3c;
    --chip: #1d2a44;
    --chip-text: #a9c5ff;
    --placeholder: #2c2c2e;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent-text);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  flex: none;
}

.icon.small {
  width: 18px;
  height: 18px;
}

/* ---- frame ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  color: var(--accent-text);
  padding: 0 8px;
}

.brand.big {
  font-size: 1.5rem;
  margin: 0 0 8px;
  padding: 0;
}

.title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--placeholder);
}

/* Bottom tab bar on a phone, a row under the header on a wide screen. */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
}

.tab[aria-current="page"] {
  color: var(--accent-text);
  font-weight: 600;
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + var(--safe-bottom) + 24px) max(16px, env(safe-area-inset-left, 0px));
}

@media (min-width: 900px) {
  .tabbar {
    position: static;
    height: auto;
    padding: 0 16px;
    justify-content: center;
    gap: 8px;
    border-top: 0;
    border-bottom: 1px solid var(--line);
  }

  .tab {
    flex: none;
    flex-direction: row;
    gap: 8px;
    padding: 0 16px;
    font-size: 0.9375rem;
  }

  .content {
    padding-bottom: 48px;
  }
}

/* ---- shared pieces ---- */

.status,
.empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  padding: 24px 0;
  margin: 0;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--chip);
  color: var(--text);
}

.notice.error {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.notice p {
  margin: 0 0 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.button.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button.secondary {
  background: var(--surface);
  color: var(--accent-text);
  border-color: var(--line);
}

.button.danger {
  background: var(--danger-fill);
  color: #ffffff;
}

.button.wide {
  width: 100%;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-text);
  font-size: 0.8125rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.tag-key {
  opacity: 0.75;
}

.tag.more {
  background: transparent;
  color: var(--muted);
}

.pill {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--placeholder);
  color: var(--muted);
  font-size: 0.8125rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.lead {
  color: var(--muted);
  margin-top: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
}

.field-error {
  color: var(--danger);
  margin: 4px 0;
  min-height: 0;
}

.field-error:empty {
  display: none;
}

.copy-status {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---- albums ---- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.rows li + li {
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 8px 16px;
  color: var(--text);
  text-decoration: none;
}

.row:hover {
  background: color-mix(in srgb, var(--placeholder) 50%, transparent);
}

.row-icon {
  color: var(--accent-text);
}

.row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0;
}

/* ---- grid ---- */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 600px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
  }
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--placeholder);
}

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

.placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}

.placeholder .icon {
  width: 40px;
  height: 40px;
}

.badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px 2px 4px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.65);
  color: #ffffff;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.tile-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-footer {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

/* ---- one asset ---- */

.media-frame {
  display: flex;
  justify-content: center;
  background: #000000;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 -16px 16px;
}

@media (min-width: 600px) {
  .media-frame {
    margin: 0 0 16px;
  }

  .media {
    max-height: 75vh;
    max-height: 75dvh;
  }
}

.media {
  display: block;
  width: 100%;
  max-height: 60vh; /* the title and tags stay in view under a portrait clip */
  max-height: 60dvh;
  object-fit: contain;
  background: #000000;
}

.asset-title {
  margin: 0 0 8px;
  font-size: 1.375rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 16px 0;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 599px) {
  .actions .button {
    flex: 1 1 100%;
  }
}

/* ---- tokens ---- */

.form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
}

.form h2,
.section-title {
  margin: 0 0 8px;
  font-size: 1.125rem;
}

.form label {
  font-weight: 600;
  margin-top: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* below 16px iOS Safari zooms in on focus */
}

fieldset {
  border: 0;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

legend {
  font-weight: 600;
  margin-bottom: 4px;
}

.form .check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 44px;
  margin: 0;
  padding: 8px 0;
  font-weight: 400;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.check > span {
  display: flex;
  flex-direction: column;
}

.check-label {
  font-weight: 600;
}

.check code {
  font-size: 0.8125rem;
  color: var(--muted);
}

.check-detail {
  color: var(--muted);
  font-size: 0.875rem;
}

.preset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--chip);
}

.preset p {
  flex: 1 1 220px;
  margin: 0;
}

.form > .button.primary {
  margin-top: 12px;
  align-self: flex-start;
}

@media (max-width: 599px) {
  .form > .button.primary {
    align-self: stretch;
  }
}

.secret-card {
  scroll-margin-top: 72px; /* clear the sticky top bar */
  border: 2px solid var(--accent);
  margin-bottom: 24px;
}

.secret-card h2 {
  margin-top: 0;
  font-size: 1.125rem;
}

.secret {
  display: block;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  font: 0.9375rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
  user-select: all;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.confirm-text {
  flex: 1 1 100%;
  font-size: 0.9375rem;
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.token-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.token .row-sub {
  margin-top: 8px;
}

/* ---- sign in ---- */

.auth {
  max-width: 400px;
  margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top, 0px)) 20px 48px;
}

.auth h1 {
  font-size: 1.5rem;
  margin: 0 0 16px;
}

.auth .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.auth label {
  font-weight: 600;
}

.auth .button.wide {
  margin-top: 8px;
}
