:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #697386;
  --line: #dfe4ec;
  --surface: #ffffff;
  --page: #f3f5f8;
  --accent: #ef6c4d;
  --accent-dark: #d95437;
  --accent-soft: #fff0eb;
  --navy: #101827;
  --success: #2c9a73;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
}

body.auth-active {
  background-color: #f7edf1;
  background-image: var(--login-background-image, none);
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
}

body.auth-active::before { position: fixed; inset: 0; z-index: 0; content: ''; background: rgba(255, 244, 248, .62); backdrop-filter: blur(2px); }
.romance-layer { position: fixed; inset: -12vh 0 0; z-index: 1; overflow: hidden; pointer-events: none; }
body:not(.auth-active) .romance-layer { display: none; }
.romance-layer span { position: absolute; top: -12vh; color: #fff; font-size: 20px; filter: drop-shadow(0 3px 5px rgba(116, 34, 61, .16)); opacity: .84; animation: romantic-fall 13s linear infinite; }
.romance-layer span:nth-child(1) { left: 5%; animation-delay: -2s; animation-duration: 14s; }
.romance-layer span:nth-child(2) { left: 15%; font-size: 15px; animation-delay: -9s; animation-duration: 12s; }
.romance-layer span:nth-child(3) { left: 26%; animation-delay: -5s; animation-duration: 16s; }
.romance-layer span:nth-child(4) { left: 37%; font-size: 24px; animation-delay: -12s; animation-duration: 18s; }
.romance-layer span:nth-child(5) { left: 48%; font-size: 14px; animation-delay: -4s; animation-duration: 11s; }
.romance-layer span:nth-child(6) { left: 60%; animation-delay: -10s; animation-duration: 15s; }
.romance-layer span:nth-child(7) { left: 71%; font-size: 16px; animation-delay: -7s; animation-duration: 19s; }
.romance-layer span:nth-child(8) { left: 80%; font-size: 23px; animation-delay: -1s; animation-duration: 13s; }
.romance-layer span:nth-child(9) { left: 89%; font-size: 14px; animation-delay: -8s; animation-duration: 17s; }
.romance-layer span:nth-child(10) { left: 96%; animation-delay: -3s; animation-duration: 12s; }

.page-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  width: min(1040px, calc(100% - 48px));
  min-height: 620px;
  margin: 7vh auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid #e7eaf0;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(16, 24, 39, 0.11);
  position: relative;
  z-index: 2;
}

.intro-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px clamp(32px, 6vw, 78px);
  color: #fff;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-color: rgba(55, 25, 43, .92);
  background-image: linear-gradient(135deg, rgba(55, 25, 43, .82), rgba(55, 25, 43, .42)), var(--intro-background-image, none);
  background-position: center;
  background-size: cover;
}


.brand-mark {
  display: grid;
  place-items: center;
  width: 136px;
  height: 54px;
  margin-bottom: 34px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  background: #f7c7a5;
  border-radius: 8px;
}

.eyebrow, .section-label {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow { color: #f7c7a5; }

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

h1 {
  max-width: 280px;
  margin-bottom: 18px;
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 280px;
  margin-bottom: 42px;
  color: #b8c2d2;
  font-size: 15px;
  line-height: 1.7;
}

.service-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #e5ebf3;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #54d59f;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(84, 213, 159, 0.13);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px clamp(32px, 7vw, 90px);
  background: rgba(255, 255, 255, .94);
}

.panel-heading { margin-bottom: 34px; }

.section-label { margin-bottom: 11px; color: var(--accent-dark); }

h2 {
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-subtitle, .security-note {
  color: var(--muted);
  font-size: 14px;
}

.panel-subtitle { margin-bottom: 0; }

.field-label {
  display: block;
  margin: 0 0 9px;
  color: #3c4658;
  font-size: 13px;
  font-weight: 650;
}

.input-wrap {
  display: flex;
  align-items: center;
  min-height: 50px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-icon {
  width: 42px;
  color: #9aa4b3;
  font-size: 15px;
  text-align: center;
}

input {
  width: 100%;
  min-width: 0;
  padding: 14px 12px 14px 0;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  border: 0;
  outline: 0;
  background: transparent;
}

input::placeholder { color: #a8b0bd; }

.icon-button {
  flex: 0 0 auto;
  margin-right: 9px;
  padding: 7px 8px;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover, .icon-button:focus-visible { color: var(--accent-dark); background: var(--accent-soft); outline: 0; }

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  margin-top: 4px;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.submit-button:hover { background: var(--accent-dark); }
.submit-button:active { transform: translateY(1px); }
.submit-button:disabled { cursor: wait; opacity: 0.75; }

.button-spinner {
  display: none;
  width: 16px;
  height: 16px;
  margin-left: 9px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.submit-button.is-loading .button-spinner { display: inline-block; }
.form-message { min-height: 22px; margin: 13px 0 0; font-size: 13px; line-height: 1.6; }
.form-message.is-error { color: #c34537; }
.form-message.is-success { color: var(--success); }
.security-note { margin: 44px 0 0; font-size: 12px; }

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10;
  max-width: min(360px, calc(100% - 48px));
  padding: 13px 16px;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 6px;
  background: #243047;
  box-shadow: 0 10px 28px rgba(16, 24, 39, 0.18);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-success { background: var(--success); }
.toast.is-error { background: #c34537; }

.is-hidden { display: none !important; }

.auth-mode-switch {
  display: flex;
  gap: 22px;
  margin: -4px 0 26px;
  border-bottom: 1px solid var(--line);
}

.mode-button {
  position: relative;
  padding: 0 0 11px;
  color: #8b95a5;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.mode-button.is-active { color: var(--accent-dark); }
.mode-button.is-active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; content: ''; background: var(--accent); }
.auth-mode-switch + form .input-wrap { margin-bottom: 18px; }
.question-number { margin: 0 0 10px; color: #b86a82; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.question-title { display: block; margin: 0 0 18px; color: #3b2631; font-size: 25px; font-weight: 700; }
.question-actions { display: grid; grid-template-columns: 88px 1fr; gap: 10px; align-items: center; }
.question-actions .submit-button { margin: 0; }
.question-actions .outline-button { width: 100%; }
.background-form { grid-template-columns: minmax(160px, 1fr) auto !important; }

.home-shell { width: min(1180px, calc(100% - 48px)); min-height: 640px; margin: 4vh auto; padding-bottom: 56px; }

.home-header { display: flex; align-items: center; justify-content: space-between; gap: 34px; min-height: 58px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }

.home-brand, .home-actions { display: flex; align-items: center; gap: 12px; }
.home-brand { color: var(--ink); font-size: 15px; font-weight: 750; }
.brand-mark.small { width: 86px; height: 32px; margin: 0; font-size: 9px; border-radius: 6px; }
.welcome-user { color: var(--muted); font-size: 13px; }
.album-layout { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 34px; align-items: start; }
.year-sidebar { position: sticky; top: 24px; padding: 10px 0 0 12px; }
.year-sidebar > .section-label { margin-bottom: 18px; }
.album-nav { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding-left: 18px; }
.album-nav::before { position: absolute; top: 4px; bottom: 4px; left: 2px; width: 1px; content: ''; background: #d8cdd2; }
.nav-link { position: relative; padding: 8px 0 8px 13px; color: var(--muted); font: inherit; font-size: 13px; text-align: left; border: 0; background: transparent; cursor: pointer; }
.nav-link::before { position: absolute; top: 50%; left: -19px; width: 7px; height: 7px; content: ''; border: 2px solid #d8cdd2; border-radius: 50%; background: var(--page); transform: translateY(-50%); }
.nav-link:hover, .nav-link.is-active { color: var(--ink); }
.nav-link.is-active { font-weight: 800; }
.nav-link.is-active::before { width: 9px; height: 9px; left: -20px; border-color: var(--accent); background: var(--accent); }
.text-button { padding: 6px 0; color: var(--accent-dark); font: inherit; font-size: 13px; font-weight: 700; border: 0; background: transparent; cursor: pointer; }
.text-button:hover { color: var(--ink); }

.album-hero { display: flex; align-items: flex-end; justify-content: space-between; max-width: 1080px; margin: 0 auto 62px; padding: 0 24px; }
.album-hero h2 { max-width: 620px; margin: 0 0 15px; font-size: clamp(34px, 5vw, 58px); line-height: 1.05; letter-spacing: -0.03em; }
.album-subtitle { margin: 0; color: var(--muted); font-size: 15px; }
.album-stats { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; color: var(--muted); font-size: 13px; }
.album-stats strong { color: var(--accent-dark); font-size: 42px; font-weight: 500; letter-spacing: -0.05em; }
.gallery-section { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.gallery-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.gallery-toolbar h3 { margin: 0; font-size: 22px; }
.search-box { display: flex; align-items: center; gap: 9px; width: 180px; padding: 8px 0; color: var(--muted); border-bottom: 1px solid var(--line); }
.search-box input { padding: 3px 0; font-size: 13px; }
.gallery-grid { display: grid; grid-auto-rows: 190px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.photo-card { position: relative; min-width: 0; overflow: hidden; padding: 0; text-align: left; border: 0; border-radius: 7px; background: #dfe4ec; cursor: pointer; }
.photo-card-0 { grid-row: span 2; }
.photo-card-1 { grid-column: span 2; }
.photo-card-4 { grid-column: span 2; }
.photo-open { position: absolute; inset: 0; width: 100%; padding: 0; text-align: left; border: 0; background: transparent; cursor: pointer; }
.photo-card img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 400ms ease; }
.photo-card:hover img { transform: scale(1.05); }
.photo-shade { position: absolute; inset: 35% 0 0; background: linear-gradient(transparent, rgba(16, 24, 39, 0.72)); }
.photo-card-copy { position: absolute; right: 16px; bottom: 15px; left: 16px; display: flex; flex-direction: column; gap: 5px; color: #fff; }
.photo-card-copy small { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; opacity: .78; }
.photo-card-copy strong { font-size: 16px; font-weight: 650; }
.heart-button { position: absolute; top: 12px; right: 12px; z-index: 2; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; color: #fff; font-size: 23px; line-height: 1; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: rgba(16,24,39,.34); backdrop-filter: blur(6px); cursor: pointer; }
.heart-button:hover, .heart-button.is-liked { color: #fff; border-color: #e85d63; background: #e85d63; }
.empty-gallery { padding: 50px 0; color: var(--muted); text-align: center; font-size: 14px; }

.admin-panel { display: grid; grid-template-columns: 240px 1fr; gap: 34px; max-width: 1032px; margin: 54px auto 0; padding: 28px; border-top: 1px solid var(--line); background: #fff; }
.admin-panel h3 { margin: 0 0 8px; font-size: 20px; }
.admin-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.admin-actions { display: grid; gap: 12px; }
.inline-form { display: grid; grid-template-columns: minmax(130px, 1fr) auto; gap: 10px; }
.inline-form + .inline-form { grid-template-columns: 130px minmax(160px, 1fr) auto auto; }
.inline-form:nth-child(2) { grid-template-columns: minmax(160px, 1fr) minmax(130px, 1fr) auto; }
.inline-form input, .inline-form select { min-width: 0; min-height: 44px; padding: 10px 12px; color: var(--ink); font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 5px; outline: 0; background: #fbfcfd; }
.inline-form input:focus, .inline-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.outline-button, .file-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; color: var(--accent-dark); font: inherit; font-size: 13px; font-weight: 700; border: 1px solid #efb2a2; border-radius: 5px; background: #fff7f4; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.submit-button.compact { width: auto; min-height: 44px; margin: 0; padding: 0 20px; }

.photo-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow: auto; padding: 24px; background: rgba(16, 24, 39, .72); }
.photo-modal-card { position: relative; width: min(880px, 100%); max-height: calc(100vh - 48px); overflow: auto; border-radius: 10px; background: var(--surface); box-shadow: 0 28px 70px rgba(16, 24, 39, .32); }
.photo-modal-card > img { display: block; width: 100%; max-height: 72vh; object-fit: contain; background: #151923; }
.photo-modal-caption { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; padding: 24px 28px 26px; }
.photo-modal-caption h2 { margin: 0 0 7px; font-size: 26px; }
.photo-modal-caption p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.photo-modal-caption > span { color: #9aa4b3; font-size: 13px; }
.photo-modal .close-button { position: absolute; top: 16px; right: 16px; z-index: 1; color: #fff; background: rgba(16,24,39,.45); }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(16, 24, 39, 0.56); }
.modal-card { width: min(480px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 28px; border-radius: 8px; background: var(--surface); box-shadow: 0 24px 60px rgba(16, 24, 39, 0.22); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.modal-header h2 { margin-bottom: 0; font-size: 24px; }
.close-button { width: 32px; height: 32px; color: var(--muted); font-size: 24px; line-height: 1; border: 0; border-radius: 5px; background: #f1f3f6; cursor: pointer; }
.close-button:hover { color: var(--ink); background: #e7ebf0; }
.modal-point { margin: 16px 0; color: var(--muted); font-size: 13px; }
.scanner-frame { position: relative; display: grid; place-items: center; min-height: 190px; margin-bottom: 20px; overflow: hidden; border-radius: 7px; background: #182235; }
.scanner-frame video { display: block; width: 100%; max-height: 250px; object-fit: cover; }
.scanner-line { position: absolute; top: 50%; right: 13%; left: 13%; height: 2px; background: #f7c7a5; box-shadow: 0 0 16px #f7c7a5; }
.scanner-frame p { position: absolute; right: 16px; bottom: 12px; left: 16px; margin: 0; color: #e5ebf3; font-size: 12px; text-align: center; }
.qr-input { width: 100%; min-height: 48px; margin-bottom: 9px; padding: 12px; color: var(--ink); font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 6px; outline: 0; background: #fbfcfd; }
.qr-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qr-hint { margin: 0 0 18px; color: #9aa4b3; font-size: 11px; }

@media (max-width: 720px) {
  .home-shell { width: min(100% - 28px, 560px); margin: 20px auto; }
  .home-header { gap: 14px; margin-bottom: 28px; padding-bottom: 12px; }
  .home-actions { margin-left: auto; }
  .welcome-user { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .album-layout { display: block; }
  .year-sidebar { position: static; margin-bottom: 30px; padding: 0; }
  .album-nav { flex-direction: row; align-items: center; gap: 8px; padding: 0 0 8px; overflow-x: auto; border-bottom: 1px solid #d8cdd2; }
  .album-nav::before { top: auto; right: 0; bottom: 0; left: 0; width: auto; height: 1px; }
  .nav-link { flex: 0 0 auto; padding: 7px 12px; text-align: center; }
  .nav-link::before { display: none; }
  .nav-link.is-active { color: var(--accent-dark); }
  .album-hero { align-items: flex-start; margin-bottom: 44px; padding: 0; }
  .album-hero h2 { font-size: 36px; }
  .album-stats { display: none; }
  .gallery-section { padding: 0; }
  .gallery-toolbar { align-items: flex-start; flex-direction: column; }
  .search-box { width: 100%; }
  .gallery-grid { grid-auto-rows: 180px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photo-card-0 { grid-row: span 1; }
  .photo-card-1, .photo-card-4 { grid-column: span 1; }
  .admin-panel { grid-template-columns: 1fr; margin-top: 40px; padding: 22px 0; }
  .inline-form, .inline-form + .inline-form, .inline-form:nth-child(2) { grid-template-columns: 1fr; }
  .photo-modal-caption { padding: 20px; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes romantic-fall {
  0% { transform: translate3d(0, -12vh, 0) rotate(0deg); }
  45% { transform: translate3d(34px, 48vh, 0) rotate(160deg); }
  100% { transform: translate3d(-24px, 118vh, 0) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) { .romance-layer span { animation: none; display: none; } }

@media (max-width: 720px) {
  .page-shell {
    grid-template-columns: 1fr;
    width: min(100% - 28px, 520px);
    min-height: auto;
    margin: 14px auto;
  }

  .intro-panel { min-height: 260px; padding: 34px 30px; }
  .brand-mark { width: 136px; height: 44px; margin-bottom: 22px; font-size: 12px; }
  h1 { margin-bottom: 12px; font-size: 36px; }
  .intro-copy { margin-bottom: 24px; }
  .login-panel { padding: 38px 30px 34px; }
  .security-note { margin-top: 32px; }
  .toast { top: 14px; right: 14px; max-width: calc(100% - 28px); }
}
