* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Times New Roman', Times, serif;
  background: #fff;
  color: #000;
  min-height: 100vh;
}

/* ── Auth Overlay ── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: #fafaf8;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: #fff;
  border: 1px solid #e8e4de;
  border-radius: 12px;
  padding: 40px 36px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  text-align: center;
}
.auth-card h2 {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 22px;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 6px;
}
.auth-card p {
  font-family: 'DM Sans', 'Helvetica Neue', sans-serif;
  font-size: 13px;
  color: #8a8178;
  margin-bottom: 24px;
  line-height: 1.4;
}
.auth-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0dbd4;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.auth-input:focus { border-color: #999; }
.auth-btn {
  width: 100%;
  padding: 10px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 8px;
}
.auth-btn:hover { background: #333; }
.auth-error {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: #c00;
  min-height: 18px;
  margin-top: 4px;
}
.auth-hint {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: #b0a89e;
  margin-top: 16px;
  line-height: 1.4;
}

/* ── Toolbar (hidden on print) ── */
.toolbar {
  background: #fafaf8;
  border-bottom: 1px solid #e8e4de;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 52px;
}
.toolbar-title {
  font-family: 'DM Serif Display', 'Georgia', serif;
  font-size: 15px;
  font-weight: 400;
  color: #1a1a1a;
  margin-right: 16px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #e0dbd4;
  margin: 0 6px;
  flex-shrink: 0;
}
button {
  font-family: 'DM Sans', 'Helvetica Neue', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 13px;
  background: transparent;
  color: #4a4540;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
button:hover {
  background: #f0ece6;
  color: #1a1a1a;
  border-color: #e0dbd4;
}
.btn-primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
  padding: 6px 16px;
}
.btn-primary:hover { background: #333; border-color: #333; color: #fff; }
.btn-print {
  background: #fff;
  color: #1a1a1a;
  border-color: #d0cbc4;
  padding: 6px 14px;
}
.btn-print:hover { background: #f5f2ee; border-color: #b8b2ab; }

/* ── Page ── */
.page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 40px 60px;
}

/* ── Header ── */
.page-header {
  text-align: center;
  margin-bottom: 40px;
}
.logo-upload-area {
  margin-bottom: 16px;
  cursor: pointer;
  display: inline-block;
}
.logo-img {
  max-height: 120px;
  max-width: 320px;
  display: block;
  margin: 0 auto;
}
.logo-placeholder {
  border: 2px dashed #ccc;
  border-radius: 6px;
  padding: 18px 32px;
  color: #aaa;
  font-family: Arial, sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
  display: inline-block;
}
.logo-placeholder:hover { border-color: #999; color: #777; }

.event-title-input {
  font-family: 'Times New Roman', Times, serif;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  border: none;
  border-bottom: 1px dashed #ccc;
  outline: none;
  width: 100%;
  max-width: 520px;
  padding: 4px 0;
  color: #000;
  display: block;
  margin: 0 auto 6px;
}
.event-title-input::placeholder { color: #bbb; font-weight: normal; }
.event-title-input:focus { border-bottom-color: #999; }

.event-date-input {
  font-family: 'Times New Roman', Times, serif;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  border: none;
  border-bottom: 1px dashed #ccc;
  outline: none;
  width: 100%;
  max-width: 320px;
  padding: 4px 0;
  color: #000;
  display: block;
  margin: 0 auto;
}
.event-date-input::placeholder { color: #bbb; font-weight: normal; }
.event-date-input:focus { border-bottom-color: #999; }

/* ── Grid ── */
.faces-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 28px 20px;
}

/* ── Face Card ── */
.face-card {
  text-align: center;
  position: relative;
}
.face-card:hover .card-controls { opacity: 1; }

.card-controls {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}
.ctrl-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  font-family: Arial, sans-serif;
}
.ctrl-remove { background: rgba(200,0,0,0.8); color: #fff; }
.ctrl-remove:hover { background: #cc0000; }
.ctrl-upload { background: rgba(0,0,0,0.6); color: #fff; font-size: 10px; }
.ctrl-upload:hover { background: rgba(0,0,0,0.85); }

/* Photo */
.photo-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  margin-bottom: 10px;
  background: #e8e8e8;
  position: relative;
}
.photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #efefef;
  cursor: pointer;
}
.photo-placeholder .ph-icon { font-size: 32px; opacity: 0.35; }
.photo-placeholder .ph-text {
  font-family: Arial, sans-serif;
  font-size: 10px;
  color: #aaa;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.photo-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid #ddd;
  border-top-color: #555;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Text fields */
.card-name {
  font-family: 'Times New Roman', Times, serif;
  font-size: 15px;
  font-weight: bold;
  text-align: center;
  border: none;
  outline: none;
  width: 100%;
  color: #000;
  background: transparent;
  padding: 0;
  line-height: 1.3;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}
.card-name::placeholder { color: #bbb; font-weight: normal; }
.card-name:focus { border-bottom-color: #ccc; }

.card-role {
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  font-style: italic;
  text-align: center;
  border: none;
  outline: none;
  width: 100%;
  color: #000;
  background: transparent;
  padding: 0;
  margin-top: 2px;
  line-height: 1.3;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}
.card-role::placeholder { color: #bbb; }
.card-role:focus { border-bottom-color: #ccc; }

.card-show {
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  font-style: italic;
  text-align: center;
  border: none;
  outline: none;
  width: 100%;
  color: #000;
  background: transparent;
  padding: 0;
  margin-top: 1px;
  line-height: 1.3;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}
.card-show::placeholder { color: #bbb; }
.card-show:focus { border-bottom-color: #ccc; }

/* Find photo button under name */
.find-photo-btn {
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s;
}
.find-photo-btn:hover { background: #444; }
.find-photo-btn:disabled { background: #ccc; cursor: default; }

/* Re-pick button on hover over a set photo */
.repick-btn {
  position: absolute;
  bottom: 6px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.72);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 4;
}
.photo-wrap:hover .repick-btn { opacity: 1; }
.repick-btn:hover { background: rgba(0,0,0,0.92); }

/* Add card placeholder */
.add-card {
  text-align: center;
  border: 2px dashed #ddd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  aspect-ratio: 1/1;
  border-radius: 2px;
}
.add-card:hover { border-color: #999; background: #fafafa; }
.add-card-icon { font-size: 28px; color: #ccc; margin-bottom: 6px; }
.add-card-text {
  font-family: Arial, sans-serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #bbb;
}
.add-card-wrapper {
  text-align: center;
}

/* ── Sections ── */
.section-block {
  margin-bottom: 40px;
}
.section-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  position: relative;
}
.section-title-input {
  font-family: 'Times New Roman', Times, serif;
  font-size: 22px;
  font-weight: bold;
  border: none;
  border-bottom: 2px dashed #ccc;
  outline: none;
  background: transparent;
  color: #000;
  padding: 2px 0;
  text-align: center;
  width: 100%;
  transition: border-color 0.15s;
}
.section-title-input:focus { border-bottom-color: #888; }
.section-title-input::placeholder { color: #bbb; font-weight: normal; }
.section-controls {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.section-header:hover .section-controls { opacity: 1; }
.section-ctrl-btn {
  font-family: Arial, sans-serif;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid #ddd;
  background: #fff;
  color: #666;
  cursor: pointer;
}
.section-ctrl-btn:hover { background: #f0f0f0; }
.section-ctrl-del { color: #c00; border-color: #f5c0c0; }
.section-ctrl-del:hover { background: #fff0f0; }
.section-divider {
  border: none;
  border-top: 1px solid #ddd;
  margin: 32px 0 32px;
}

/* ── Sheet Tabs ── */
.sheets-bar {
  background: #fafaf8;
  border-bottom: 1px solid #e8e4de;
  padding: 0 20px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 0;
}
.sheet-tab {
  font-family: 'DM Sans', 'Helvetica Neue', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  background: transparent;
  color: #8a8178;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  position: relative;
  top: 1px;
  letter-spacing: 0.02em;
}
.sheet-tab:hover { background: #f0ece6; color: #4a4540; }
.sheet-tab.active {
  background: #fff;
  border-color: #e8e4de;
  color: #1a1a1a;
  font-weight: 600;
}
.sheet-tab-close {
  font-size: 12px;
  line-height: 1;
  color: #c8c2bb;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 2px;
}
.sheet-tab-close:hover { color: #c00; }
.sheet-tab-add {
  font-size: 16px;
  padding: 6px 12px;
  color: #b0a89e;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  background: transparent;
  top: 1px;
  position: relative;
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
}
.sheet-tab-add:hover { background: #f0ece6; color: #4a4540; }

/* Export/Import sheet buttons */
.btn-export {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}
.btn-export:hover { background: #333; border-color: #333; color: #fff; }
.btn-drive { background: transparent; color: #4a4540; border-color: transparent; }
.btn-drive:hover { background: #f0ece6; border-color: #e0dbd4; color: #1a1a1a; }
.btn-drive.connected { color: #2d6a4f; font-weight: 600; }
.btn-drive.connected:hover { background: #edf7f2; border-color: #b7deca; }
.btn-drive.syncing { color: #b07d2a; }

/* ── Saved Sheets Panel ── */
.sheets-library-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  background: #fff;
  border-left: 1px solid #ddd;
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.12);
}
.sheets-library-panel.open { transform: translateX(0); }
.saved-sheet-item {
  padding: 14px 18px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: default;
  transition: background 0.12s;
}
.saved-sheet-item:hover { background: #fafafa; }
.saved-sheet-info { flex: 1; min-width: 0; }
.saved-sheet-name {
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-sheet-meta {
  font-family: Arial, sans-serif;
  font-size: 10px;
  color: #aaa;
  margin-top: 2px;
}
.saved-sheet-actions { display: flex; gap: 6px; flex-shrink: 0; }
.saved-sheet-btn {
  font-family: Arial, sans-serif;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid #ddd;
  background: #fff;
  color: #444;
  cursor: pointer;
  white-space: nowrap;
}
.saved-sheet-btn:hover { background: #f0f0f0; }
.saved-sheet-btn.open-btn { background: #111; color: #fff; border-color: #111; }
.saved-sheet-btn.open-btn:hover { background: #333; }
.saved-sheet-btn.del-btn { color: #c00; border-color: #f5c0c0; }
.saved-sheet-btn.del-btn:hover { background: #fff0f0; }
.sheets-lib-empty {
  padding: 40px 20px;
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: #bbb;
  line-height: 1.6;
}

/* ── Photo Library Panel ── */
.library-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 320px;
  background: #fff;
  border-left: 1px solid #ddd;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}
.library-panel.open { transform: translateX(0); }
.library-header {
  padding: 16px 18px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f9f9f9;
}
.library-header h3 {
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #222;
}
.library-header span {
  font-family: Arial, sans-serif;
  font-size: 11px;
  color: #999;
  margin-left: 6px;
}
.library-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
}
.library-close:hover { color: #333; background: none; }
.library-search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
}
.library-search-wrap input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 10px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  outline: none;
  color: #333;
}
.library-search-wrap input:focus { border-color: #999; }
.library-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-content: start;
}
.lib-item {
  position: relative;
  cursor: pointer;
  border: 2px solid #eee;
  border-radius: 4px;
  overflow: visible;
  transition: border-color 0.2s;
  background: #f5f5f5;
}
.lib-item:hover { border-color: #111; z-index: 10; }
.lib-item img {
  width: 100%;
  display: block;
  object-fit: contain;
  background: #f5f5f5;
  border-radius: 2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  transform-origin: center center;
}
.lib-item:hover img {
  transform: scale(2.4);
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
  position: relative;
  z-index: 10;
}
.lib-item-name {
  position: absolute;
  bottom: -20px; left: 0; right: 0;
  color: #555;
  font-family: Arial, sans-serif;
  font-size: 8px;
  font-weight: 600;
  text-align: center;
  padding: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s;
}
.lib-item:hover .lib-item-name { opacity: 1; }
.lib-item-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 14px; height: 14px;
  background: rgba(180,0,0,0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
  line-height: 1;
  z-index: 20;
}
.lib-item:hover .lib-item-del { opacity: 1; }
.lib-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 40px 10px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  color: #bbb;
  line-height: 1.6;
}
.btn-library { background: transparent; color: #4a4540; border-color: transparent; }
.btn-library:hover { background: #f0ece6; border-color: #e0dbd4; color: #1a1a1a; }

/* ── Photo Picker ── */
.photo-picker {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: #fff;
  border: 2px solid #111;
  border-radius: 4px;
  z-index: 20;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  padding: 10px;
  animation: pickerIn 0.18s ease both;
}
@keyframes pickerIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.picker-label {
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 7px;
  text-align: center;
}
.picker-options {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  margin-top: 6px;
}
.picker-opt {
  flex: 0 0 calc(33.333% - 4px);
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.picker-opt:hover { border-color: #111; transform: scale(1.04); }
.picker-opt img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.picker-opt-loading {
  width: 100%;
  aspect-ratio: 1;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.picker-opt-num {
  position: absolute;
  bottom: 2px; left: 2px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
}
.picker-cancel {
  display: block;
  width: 100%;
  margin-top: 7px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 10px;
  color: #aaa;
  cursor: pointer;
  padding: 4px;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}
.picker-cancel:hover { border-color: #999; color: #555; background: none; }
.picker-more {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 10px;
  color: #666;
  cursor: pointer;
  padding: 5px;
  text-align: center;
  transition: all 0.15s;
}
.picker-more:hover { background: #eee; border-color: #ccc; color: #111; }
.picker-more:disabled { cursor: default; color: #bbb; }

/* ── Print ── */
@media print {
  .toolbar, .sheets-bar, .library-panel, .sheets-library-panel,
  .card-controls, .find-photo-btn, .section-controls, .add-card-wrapper,
  .repick-btn, .photo-picker, .auth-overlay { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .event-title-input, .event-date-input, .section-title-input,
  .card-name, .card-role, .card-show {
    border: none !important;
  }
  .photo-placeholder { background: #f5f5f5 !important; }
  .faces-grid { gap: 16px 12px; }
  .section-divider { margin: 20px 0; }
}
