@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400&display=swap');

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

body {
  font-family: 'Lato', sans-serif;
  background: #f5f5f0;
  color: #222;
  min-height: 100vh;
}

header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 { font-size: 1.25rem; }

header .user-info { font-size: 0.875rem; color: #555; display: flex; gap: 1rem; align-items: center; }

.account-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 1rem;
  min-width: 200px;
  z-index: 50;
}
.account-menu-dropdown.open { display: block; }
.account-menu-avatar-row { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; }
.account-avatar-wrap {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden; cursor: pointer;
  border: 1px solid #ddd; position: relative; background: #f0f0f0;
}
.account-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-avatar-placeholder {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #aaa;
}
.account-menu-hint { font-size: 0.75rem; color: #888; }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}

.btn-primary { background: #333; color: #fff; }
.btn-primary:hover { background: #111; }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-secondary:hover { background: #ccc; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.container { max-width: 800px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card h2 { margin-bottom: 0.25rem; font-size: 1.1rem; }
.card p { color: #666; font-size: 0.9rem; margin-bottom: 0.75rem; }

form label { display: block; margin-bottom: 0.25rem; font-size: 0.875rem; font-weight: bold; }

form input[type=text], form input[type=password], form textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 0.75rem;
}

form textarea { min-height: 6rem; resize: vertical; }

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.page-title h2 { font-size: 1.4rem; }

.title-input {
  font-size: 1.4rem;
  font-weight: bold;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  margin: 0;
  background: transparent;
  min-width: 0;
  flex: 1;
}
.title-input:hover { border-color: #ccc; }
.title-input:focus { border-color: #999; background: #fff; outline: none; }

/* Auth page */
.auth-wrapper {
  max-width: 380px;
  margin: 5rem auto;
  padding: 0 1rem;
}

.auth-wrapper h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.75rem; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab { flex: 1; padding: 0.5rem; background: #eee; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; text-align: center; }
.tab.active { background: #333; color: #fff; border-color: #333; }

.error-msg { color: #c0392b; font-size: 0.85rem; margin-bottom: 0.75rem; }
.success-msg { color: #27ae60; font-size: 0.85rem; margin-bottom: 0.75rem; }

/* Post editor */
.post-content { margin-top: 1.5rem; }

.block {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.block img { max-width: 100%; border-radius: 4px; margin-top: 0.5rem; }
.block .block-label { font-size: 0.75rem; color: #999; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.block p { white-space: pre-wrap; line-height: 1.6; }

.add-block-area {
  background: #fff;
  border: 2px dashed #ccc;
  border-radius: 6px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.add-block-area h4 { margin-bottom: 0.75rem; color: #555; }

.block-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  margin: 1rem;
}

.modal h3 { margin-bottom: 1rem; }

.modal-large { max-width: 95vw; width: 95vw; max-height: 92vh; overflow-y: auto; }

.zoom-wrap {
  position: relative;
  overflow: hidden;
  touch-action: none;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  border-radius: 4px;
  background: #f4f4f4;
}
.zoom-wrap img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  cursor: grab;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}
.zoom-wrap img.zoomed { cursor: grab; }
.zoom-wrap img.grabbing { cursor: grabbing; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.breadcrumb { font-size: 0.85rem; color: #666; margin-bottom: 1rem; }
.breadcrumb a { color: #444; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* Tables */
.content-table { width: 100%; border-collapse: separate; border-spacing: 4px; background: #ddd; margin: 0.5rem 0; table-layout: fixed; border-radius: 4px; }
.content-table td { border: 1px solid #ddd; vertical-align: top; padding: 0; }
.content-table td:has(.cell-img) { vertical-align: middle; }
.table-cell { min-height: 60px; }
.table-cell-empty { text-align: center; vertical-align: middle; cursor: pointer; background: #fafafa; transition: background 0.1s; }
.table-cell-empty:hover { background: #f0f0f0; }
.cell-add { color: #ccc; font-size: 1.5rem; line-height: 3.5rem; display: block; user-select: none; }
.table-cell-filled { padding: 0.5rem; cursor: pointer; transition: background 0.1s; }
.table-cell-filled:hover { background: #f9f9f9; }
.table-cell-filled p { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.5; }
.cell-img { max-width: 100%; display: block; margin: 0 auto; user-select: none; -webkit-user-drag: none; }
.table-row-del { width: 32px; text-align: center; vertical-align: middle; border: none !important; padding: 0 2px; }
.table-cell[data-block-id] { cursor: grab; touch-action: none; }
.table-cell.drag-over { outline: 2px solid #555; outline-offset: -2px; background: #f0f0f0; }
.table-cell.dragging { opacity: 0.4; }

/* Image captions */
.image-caption { font-size: 0.85rem; color: #666; font-style: italic; text-align: center; margin-top: 0.4rem; }
.cell-caption { padding: 0 0.35rem 0.35rem; margin-top: 0.25rem; }
.caption-edit-area { display: flex; gap: 0.5rem; align-items: flex-start; margin-top: 0.5rem; }
.caption-edit-area textarea { flex: 1; min-height: 2.5rem; resize: vertical; font-style: italic; font-size: 0.875rem; padding: 0.35rem; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; }

/* Insert gutters */
.gutter {
  height: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.gutter::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: #bbb;
  opacity: 0;
  transition: opacity 0.12s;
}
.gutter::after {
  content: '+';
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  color: #aaa;
  background: #f5f5f0;
  padding: 0 6px;
  opacity: 0;
  transition: opacity 0.12s;
}
.gutter:hover::before, .gutter:hover::after { opacity: 1; }
.gutter-open {
  height: auto;
  padding: 5px 0;
  gap: 0.4rem;
  flex-wrap: wrap;
  cursor: default;
}
.gutter-open::before, .gutter-open::after { display: none; }

/* Block editing */
.block-editable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.block-editable:hover { border-color: #999; box-shadow: 0 0 0 2px #f0f0f0; }
.edit-hint { font-weight: normal; color: #ccc; text-transform: none; letter-spacing: 0; font-size: 0.75rem; }
.block-editing { border-color: #555; }
.block-selected { border-color: #555; }
.block-edit-textarea {
  width: 100%; min-height: 3rem; padding: 0.5rem;
  border: 1px solid #ccc; border-radius: 4px;
  font-size: 1rem; font-family: inherit; resize: vertical; margin-bottom: 0.5rem;
  overflow-y: hidden;
}
.block-edit-actions { display: flex; gap: 0.5rem; }
.block-image-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* Hike date row in post editor */
.hike-date-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; font-size: 0.875rem; color: #555; }
.hike-date-row label { font-weight: bold; margin: 0; }
.hike-date-row input[type=date] { padding: 0.25rem 0.4rem; border: 1px solid #ccc; border-radius: 4px; font-size: 0.875rem; font-family: inherit; margin: 0; width: auto; }

/* Calendar */
.cal-table { width: 100%; border-collapse: collapse; min-width: 560px; table-layout: fixed; }
.cal-table th { background: #333; color: #fff; padding: 0.5rem; text-align: center; font-size: 0.85rem; font-weight: normal; }
.cal-cell { border: 1px solid #ddd; vertical-align: top; padding: 0.4rem; background: #fff; width: 14.28%; }
.cal-today { background: #fffbe6; border-color: #f0c040; }
.cal-day-num { font-size: 0.8rem; color: #aaa; margin-bottom: 0.2rem; }
.cal-today .cal-day-num { color: #b8860b; font-weight: bold; }
.cal-post { display: block; font-size: 0.78rem; color: #333; text-decoration: none; background: #e8f0fe; border-radius: 3px; padding: 0.2rem 0.35rem; margin-bottom: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-post:hover { background: #c8d8fc; }
.cal-post.cal-has-photo { background: #a9c8f5; }
.cal-post.cal-has-photo:hover { background: #8fb6ee; }
.week-controls { display: flex; gap: 0.25rem; }
.cal-cell-empty { cursor: pointer; }
.cal-cell-empty:hover { background: #f5f5f0; }
.cal-cell-one { cursor: pointer; }
.cal-cell-one:hover { background: #f9f9f9; }
.cal-controls { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
.cal-controls input[type=date] { padding: 0.25rem 0.4rem; border: 1px solid #ccc; border-radius: 4px; font-size: 0.875rem; font-family: inherit; }
