/* Visual identity from the UC Space Day II poster template: white, UC Space gold, black.
   Gold (#d3bc5f) is only 1.9:1 on white, so it's used for borders, fills and the logo,
   never for text. Text on gold is black (11:1); links use a darker gold (6.8:1). */
:root {
  color-scheme: light;
  --bg: #faf8f1;
  --surface: #ffffff;
  --text: #111111;
  --muted: #575757;
  --line: #e7dfc2;
  --field-line: #8a8574; /* 3.6:1, so form fields stay visible */
  --gold: #d3bc5f;
  --gold-soft: #f6f0dc;
  --link: #6b5a1c;
  --accent: #d3bc5f;
  --accent-text: #000000;
  --accent-soft: #f6f0dc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(60 50 10 / 0.06), 0 1px 3px rgb(60 50 10 / 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 Verdana, Geneva, 'DejaVu Sans', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--link);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

[hidden] {
  display: none !important;
}

/* ---- header ------------------------------------------------------------ */

.site-header {
  border-bottom: 3px solid var(--gold);
  background: var(--surface);
  padding: max(16px, env(safe-area-inset-top)) 0 16px;
}

.site-header .wrap {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.site-header a {
  color: inherit;
  text-decoration: none;
}

.site-header h1 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.2;
}

.site-header .sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-header .sub a {
  color: var(--link);
  text-decoration: underline;
}

.logo {
  display: block;
  flex: none;
}

.logo img {
  display: block;
  width: 92px;
  height: auto;
}

@media (min-width: 720px) {
  .site-header h1 {
    font-size: 1.75rem;
  }

  .logo img {
    width: 150px;
  }
}

/* ---- gallery ----------------------------------------------------------- */

.search {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -4px;
  padding: 12px 4px 8px;
  background: var(--bg);
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming into the field */
}

input:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.card:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 1px;
}

.status {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.poster-list {
  display: grid;
  gap: 10px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}

@media (min-width: 720px) {
  .poster-list {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  display: flex;
  gap: 14px;
  height: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.1s ease;
}

.card:active {
  transform: scale(0.985);
}

.thumb {
  display: flex;
  flex: 0 0 76px;
  align-self: flex-start;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1.414;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

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

.card-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.badge {
  align-self: flex-start;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--gold);
  color: #000;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.card-title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-authors {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ---- poster detail ----------------------------------------------------- */

.detail-nav {
  padding: 8px 0 4px;
}

.back {
  color: var(--link);
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-weight: 600;
  text-decoration: none;
}

.detail {
  max-width: 760px;
}

.detail h2 {
  margin: 8px 0 6px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.detail .authors {
  margin: 0;
}

.detail .affiliation {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.btn.danger {
  color: var(--danger);
}

.btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
}

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

.preview {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff center top / cover no-repeat;
}

.preview img {
  display: block;
  width: 100%;
  height: auto;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.pager {
  display: flex;
  max-width: 760px;
  justify-content: space-between;
  gap: 8px;
  margin: 20px 0 max(32px, env(safe-area-inset-bottom));
}

/* ---- forms ------------------------------------------------------------- */

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.panel {
  max-width: 640px;
  margin: 20px 0 40px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.panel > p:first-of-type {
  margin-top: 0;
}

.field {
  margin-top: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.field .optional {
  color: var(--muted);
  font-weight: 400;
}

.help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

input[type='file'] {
  padding: 10px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 18px;
  font-size: 0.95rem;
}

.check input {
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 2px;
}

.form-actions {
  margin-top: 20px;
}

.form-actions .btn {
  width: 100%;
}

.progress {
  margin-top: 16px;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 0.2s ease;
}

.progress p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.alert {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
}

.alert.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.copy-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.copy-row input {
  min-width: 0;
  font-size: 0.85rem;
}

.mine {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--gold-soft);
  font-size: 0.92rem;
}

.mine ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

/* ---- admin ------------------------------------------------------------- */

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

.toolbar .status {
  margin: 0 auto 0 0;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}

.admin-item {
  display: flex;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-item.is-hidden {
  opacity: 0.6;
}

.admin-main {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

.admin-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.admin-top label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-top input {
  width: 72px;
  padding: 6px 8px;
  font-size: 16px;
}

.chip {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 700;
}

.chip.neutral {
  background: var(--line);
  color: var(--muted);
}

.meta-line {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  transform: translateX(-50%);
}

/* ---- printable QR sheet ------------------------------------------------ */

#print {
  display: none;
}

@media print {
  body > :not(#print) {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  #print {
    display: block;
  }

  .qr-main img {
    width: 7cm;
    height: auto;
  }

  .qr-main {
    padding-top: 40px;
    text-align: center;
    page-break-after: always;
  }

  .qr-main h1 {
    margin: 0;
    font-size: 32pt;
  }

  .qr-main p {
    font-size: 16pt;
  }

  .qr-main svg {
    width: 12cm;
    height: 12cm;
  }

  .qr-url {
    font-family: ui-monospace, monospace;
  }

  .qr-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6cm;
  }

  .qr-label {
    display: flex;
    gap: 0.4cm;
    align-items: center;
    padding: 0.4cm;
    border: 1px solid #d3bc5f;
    break-inside: avoid;
  }

  .qr-label svg {
    width: 3.6cm;
    height: 3.6cm;
    flex: none;
  }

  .qr-label strong {
    display: block;
    font-size: 20pt;
  }

  .qr-label span {
    font-size: 10pt;
  }
}
