:root {
  color-scheme: light;
  --bg: #f4efe8;
  --bg-accent: #ece3d8;
  --panel: #ffffff;
  --panel-soft: #faf6f0;
  --line: #e4dacd;
  --line-soft: #efe7db;
  --text: #2c2722;
  --muted: #8c8175;
  --primary: #7d1d28;
  --primary-strong: #641520;
  --primary-soft: #f3e4e3;
  --success: #5a7d4f;
  --danger: #b5303a;
  --shadow: 0 14px 40px rgba(60, 40, 30, .10);
  --shadow-sm: 0 4px 14px rgba(60, 40, 30, .07);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(125, 29, 40, .06), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: .2px;
}

button,
input,
textarea {
  font: inherit;
}

button,
.button {
  align-items: center;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  height: 40px;
  justify-content: center;
  padding: 0 18px;
  font-weight: 500;
  letter-spacing: .3px;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .05s ease, box-shadow .18s ease;
}

button:hover,
.button:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  box-shadow: var(--shadow-sm);
}

button:active,
.button:active {
  transform: translateY(1px);
}

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

button.secondary:hover,
.button.secondary:hover {
  background: var(--panel-soft);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: none;
}

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

input,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 40px;
  padding: 9px 12px;
  width: 100%;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(125, 29, 40, .12);
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 12px;
  letter-spacing: .4px;
  text-transform: uppercase;
  font-weight: 600;
}

/* ---------- Login ---------- */
.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-width: 400px;
  width: 100%;
  padding: 38px 34px;
}

.login-logo {
  display: block;
  margin: 0 auto 6px;
  height: 76px;
}

.login form > div {
  text-align: center;
}

.login h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.login p {
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
}

.login label input {
  text-transform: none;
}

/* ---------- Shell / Topbar ---------- */
.shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 26px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand img {
  height: 46px;
}

.brand .brand-divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.brand .brand-title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}

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

.content {
  display: grid;
  gap: 20px;
  padding: 24px 32px 48px;
  max-width: none;
  margin: 0;
  width: 100%;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric,
.panel,
.photo-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.metric {
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}

.metric strong {
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 360px minmax(0, 1fr);
}

.panel {
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel header {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--panel-soft);
}

.panel h2 {
  font-size: 17px;
  margin: 0;
}

.panel-body {
  padding: 18px;
}

/* ---------- Calendar ---------- */
.calendar-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-head strong {
  font-family: var(--serif);
  font-size: 17px;
  text-transform: capitalize;
}

.calendar-head button.secondary {
  height: 34px;
  width: 34px;
  padding: 0;
  border-radius: 8px;
}

.calendar-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(7, 1fr);
}

.weekday {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  text-align: center;
  padding-bottom: 4px;
}

.day {
  aspect-ratio: 1;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  position: relative;
  width: 100%;
  padding: 0;
  height: auto;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.day:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: none;
}

.day.has-photos::after {
  background: var(--primary);
  border-radius: 99px;
  bottom: 6px;
  content: "";
  height: 5px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 5px;
}

.day.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.day.selected.has-photos::after {
  background: #fff;
}

/* ---------- Gallery ---------- */
.gallery-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.photo-card {
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}

.photo-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.thumb {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: var(--bg-accent);
  display: flex;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  border: none;
  border-radius: 0;
  padding: 0;
  height: auto;
  cursor: zoom-in;
}

.thumb:hover {
  background: var(--bg-accent);
  box-shadow: none;
}

.thumb img {
  height: 100%;
  object-fit: cover;
  width: 100%;
  transition: transform .3s ease;
}

.photo-card:hover .thumb img {
  transform: scale(1.04);
}

.photo-meta {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.photo-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
}

.photo-meta span,
.empty,
.error {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 24px 4px;
  text-align: center;
}

.error {
  color: var(--danger);
  background: rgba(181, 48, 58, .08);
  border: 1px solid rgba(181, 48, 58, .2);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
}

/* ---------- Settings dialog ---------- */
.settings-backdrop {
  background: rgba(44, 30, 24, .42);
  backdrop-filter: blur(3px);
  inset: 0;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.settings-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-height: calc(100vh - 48px);
  max-width: 820px;
  overflow: auto;
}

.settings-dialog header {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--panel-soft);
  position: sticky;
  top: 0;
}

.settings-dialog h2 {
  margin: 0;
  font-size: 19px;
}

.settings-form {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

/* ---------- Small / danger buttons ---------- */
button.small,
.button.small {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 7px;
}

button.danger,
.button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

button.danger:hover,
.button.danger:hover {
  background: #9b2730;
  border-color: #9b2730;
  color: #fff;
}

.photo-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.icon-btn {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  height: 34px;
  width: 34px;
  padding: 0;
  justify-content: center;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.icon-btn:hover {
  background: var(--panel-soft);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: none;
}

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

.icon-btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------- Selection ---------- */
.photo-card {
  position: relative;
}

.photo-select {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.photo-select input {
  width: 20px;
  height: 20px;
  min-height: auto;
  cursor: pointer;
  accent-color: var(--primary);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}

.photo-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  flex-wrap: wrap;
}

.selection-bar.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.selection-bar .sel-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.selection-bar .sel-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.select-all {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  text-transform: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.select-all input {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

.notice {
  color: var(--success);
  background: rgba(90, 125, 79, .10);
  border: 1px solid rgba(90, 125, 79, .25);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
  font-size: 13px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 14, 12, .82);
  backdrop-filter: blur(6px);
  display: flex;
  padding: 24px;
}

.lightbox-inner {
  margin: auto;
  max-width: 1280px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 48px);
}

.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: calc(100vh - 170px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: #1a1411;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  border: none;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  padding: 0;
}

.lightbox-nav:hover {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.lightbox-nav.prev { left: 10px; }
.lightbox-nav.next { right: 10px; }

.lightbox-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.lightbox-info strong {
  display: block;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
}

.lightbox-info span {
  color: var(--muted);
  font-size: 12px;
}

.lightbox-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Confirm / prompt modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(44, 30, 24, .5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 460px;
  width: 100%;
  padding: 22px 22px 18px;
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.modal p {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.modal-field {
  text-transform: none;
  color: var(--muted);
  margin-bottom: 18px;
  display: grid;
  gap: 6px;
}

.modal-field input {
  text-transform: none;
}

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

@media (max-width: 900px) {
  .metrics,
  .main-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .brand .brand-title { display: none; }

  .content { padding: 20px 16px 40px; }
}
