:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #d7ded9;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --ready: #0f7a3f;
  --pending: #9a5b00;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

body.admin {
  background: #eef2ef;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

label span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.stack {
  display: grid;
  gap: 1rem;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.68rem 1rem;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover,
.icon-button:hover {
  border-color: #9ca9a3;
  transform: translateY(-1px);
}

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

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

.button.ghost {
  background: transparent;
}

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

.icon-button {
  width: 2.65rem;
  padding: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.alert {
  border: 1px solid rgba(180, 35, 24, 0.25);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  font-weight: 700;
}

.toast {
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent);
  font-weight: 700;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.25rem;
}

.login-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1,
.visitor-head h1 {
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem clamp(1rem, 3vw, 2rem);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.panel,
.session-card,
.waiting-panel,
.reminder-panel,
.self-delete-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.create-panel {
  align-self: start;
  position: sticky;
  top: 1rem;
  padding: 1rem;
}

.create-panel h2 {
  margin: 0 0 1rem;
}

.sessions {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.sessions-head,
.photos-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0.2rem 0.4rem;
}

.sessions-head h2,
.photos-section-head h2 {
  margin: 0;
}

.sessions-head span,
.photos-section-head span {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.session-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 1rem;
  padding: 1rem;
}

.session-main {
  min-width: 0;
}

.session-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.session-head h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.4vw, 1.35rem);
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  font-size: 0.83rem;
  font-weight: 800;
  white-space: nowrap;
}

.status.ready {
  background: rgba(15, 122, 63, 0.1);
  color: var(--ready);
}

.status.pending {
  background: rgba(154, 91, 0, 0.12);
  color: var(--pending);
}

.status.expired {
  background: rgba(95, 107, 122, 0.12);
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.meta-grid div {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-grid dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.notes {
  margin: 0 0 1rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.5rem;
}

.url-row input {
  min-width: 0;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.admin-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 88px));
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.admin-preview-grid a,
.admin-preview-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe5e1;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.admin-preview-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-empty-small {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-weight: 650;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.check-row input {
  width: auto;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.card-actions form {
  display: flex;
  gap: 0.5rem;
}

.qr-box {
  display: grid;
  align-content: start;
}

.qr-box img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 1rem;
  padding: 1rem;
}

.detail-main,
.side-panel {
  padding: 1rem;
}

.detail-upload {
  margin-bottom: 1.25rem;
}

.detail-side {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.side-panel {
  display: grid;
  gap: 0.85rem;
}

.side-panel h2 {
  margin: 0;
}

.side-panel form {
  display: grid;
  gap: 0.6rem;
}

.detail-qr {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}

.admin-photo-card {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  background: var(--surface-2);
}

.admin-photo-card a {
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe5e1;
}

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

.admin-photo-card figcaption {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.admin-photo-card strong {
  overflow-wrap: anywhere;
}

.admin-photo-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.empty-state {
  border: 1px dashed #9ca9a3;
  border-radius: 8px;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.visitor-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
}

.visitor-head {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.visitor-head h1 {
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.photo-grid a {
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe5e1;
}

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

.waiting-panel {
  min-height: 42vh;
  display: grid;
  align-content: center;
  gap: 0.5rem;
  padding: clamp(1.25rem, 4vw, 3rem);
}

.waiting-panel h1,
.waiting-panel h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
}

.waiting-panel p {
  margin: 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.reminder-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
}

.reminder-panel p {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.self-delete-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
}

.self-delete-panel h2,
.self-delete-panel p {
  margin: 0;
}

.self-delete-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.self-delete-panel form {
  display: grid;
  gap: 0.75rem;
}

.narrow {
  width: min(100%, 680px);
  margin: 4rem auto;
  padding: 1rem;
}

@media (max-width: 900px) {
  .admin-grid,
  .session-card,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .create-panel {
    position: static;
  }

  .qr-box {
    width: min(220px, 100%);
  }

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

@media (max-width: 680px) {
  .topbar,
  .session-head,
  .reminder-panel,
  .self-delete-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .self-delete-panel {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .card-actions form,
  .upload-form,
  .url-row,
  .sessions-head,
  .photos-section-head {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .sessions-head,
  .photos-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-form {
    display: grid;
  }

  .card-actions,
  .card-actions form {
    display: grid;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .reminder-panel p {
    text-align: left;
  }
}
