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

:root {
  --bg: #f5f0eb;
  --surface: #ffffff;
  --text: #1a1614;
  --muted: #8c7b74;
  --accent: #5c3d2e;
  --gold: #c8922a;
  --border: #e5ddd6;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04);
  --radius: 14px;
  --max: 600px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top banner ──────────────────────────── */

.top-banner {
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.banner-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.7;
  flex-shrink: 0;
}

.banner-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner-stars {
  margin-left: auto;
  letter-spacing: 1px;
  font-size: 15px;
  flex-shrink: 0;
}

/* ── Header ──────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--accent);
}

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

.btn-add {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: opacity 0.15s;
  line-height: 1;
}
.btn-add:hover { opacity: 0.82; }

.btn-add-place {
  background: #3d7a5c;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: opacity 0.15s;
  line-height: 1;
}
.btn-add-place:hover { opacity: 0.82; }

/* ── Feed ────────────────────────────────── */

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 12px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

/* ── Entry card ──────────────────────────── */

.entry {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
}

.entry-photo-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--border);
}

/* Compact card — hidden elements */
.entry:not(.expanded) .entry-attrs,
.entry:not(.expanded) .entry-comment,
.entry:not(.expanded) .entry-footer,
.entry:not(.expanded) .place-location-link,
.entry:not(.expanded) .place-description { display: none; }

.entry:not(.expanded) .entry-body { padding: 10px; }
.entry:not(.expanded) .entry-header { margin-bottom: 0; }
.entry:not(.expanded) .entry-rating { font-size: 13px; }
.entry:not(.expanded) .avg-badge { display: none; }

/* Compact place photo strip — first photo as square thumbnail */
.entry:not(.expanded) .place-photo-strip {
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.entry:not(.expanded) .place-photo { display: none; }
.entry:not(.expanded) .place-photo:first-child {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Expanded card — full width */
.entry.expanded {
  grid-column: 1 / -1;
}
.entry.expanded .entry-photo-wrap { aspect-ratio: 4 / 3; }
.entry-photo-wrap.no-photo { display: none; }

/* Expanded place photo strip — horizontal scroll */
.entry.expanded .place-photo-strip {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 0;
  padding: 0 0 8px;
  background: var(--surface);
}
.entry.expanded .place-photo {
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  scroll-snap-align: start;
  border-radius: 0;
}
.place-photo-strip.no-photo { display: none; }

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

.entry-body { padding: 16px; }

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
}

.entry-roaster {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 3px;
}

.entry-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.entry-rating {
  flex-shrink: 0;
  font-size: 17px;
  letter-spacing: 1px;
  padding-top: 2px;
}

/* Attribute dots */

.entry-attrs {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.attr-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attr-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.attr-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}
.dot.filled { background: var(--accent); }

/* Comment & footer */

.entry-comment {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

.entry-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.entry-date {
  font-size: 12px;
  color: var(--muted);
}

.entry-actions {
  display: flex;
  gap: 12px;
}

.btn-edit {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s;
  padding: 2px 0;
}
.btn-edit:hover { opacity: 1; }

.btn-delete {
  background: none;
  border: none;
  font-size: 12px;
  color: #b44;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s;
  padding: 2px 0;
}
.btn-delete:hover { opacity: 1; }

/* ── Modal ───────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.modal[hidden] { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px 20px 32px;
  animation: slide-up 0.22s ease;
}

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (min-width: 640px) {
  .modal { align-items: center; justify-content: center; }
  .modal-content {
    max-width: 480px;
    border-radius: var(--radius);
    max-height: 88vh;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  font-size: 17px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.btn-close:hover { color: var(--text); }

/* ── Form ────────────────────────────────── */

.form-group { margin-bottom: 20px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 7px;
  color: var(--text);
}

.req { color: var(--accent); }

.char-count {
  float: right;
  font-weight: 400;
  color: var(--muted);
}

input[type="text"],
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  appearance: none;
}
input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="file"] {
  width: 100%;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
}

textarea {
  resize: vertical;
  line-height: 1.5;
  min-height: 72px;
}

.photo-preview {
  margin-top: 10px;
  border-radius: 9px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--border);
}
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Rating sections ─────────────────────── */

.rating-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-bottom: 20px;
}

.rating-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 14px;
}

.rating-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.rating-section .form-group:last-child { margin-bottom: 0; }

/* ── M / S dot colors ────────────────────── */

.dots-m .dot.filled { background: #9b7fd4; }
.dots-s .dot.filled { background: #e4899a; }

/* ── Half stars ──────────────────────────── */

.star-full  { color: var(--gold); }
.star-empty { color: var(--border); }

.star-half {
  position: relative;
  display: inline-block;
  color: var(--border);
}
.star-half::before {
  content: '★';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--gold);
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

/* ── Avg badge ───────────────────────────── */

.avg-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
  margin-left: 5px;
  vertical-align: middle;
  line-height: 1.4;
}

/* ── Star inputs ─────────────────────────── */

.star-input {
  display: flex;
  gap: 2px;
}

.star-input .star {
  font-size: 26px;
  cursor: pointer;
  color: var(--border);
  transition: color 0.1s, transform 0.08s;
  user-select: none;
  line-height: 1;
}
.star-input .star.active { color: var(--gold); }
.star-input .star:hover  { transform: scale(1.15); }

/* Attribute star inputs (smaller) */

.attr-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attr-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attr-name {
  font-size: 13px;
  color: var(--muted);
  width: 95px;
  flex-shrink: 0;
}

.attr-row .star-input .star { font-size: 19px; }

/* ── Submit ──────────────────────────────── */

.btn-submit {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.btn-submit:hover    { opacity: 0.84; }
.btn-submit:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Logout ──────────────────────────────── */

.btn-logout {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.15s;
}
.btn-logout:hover { color: var(--text); }

/* ── Login page ──────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-wrap {
  width: 100%;
  max-width: 340px;
  padding: 0 24px;
  text-align: center;
}

.login-wrap h1 {
  font-size: 22px;
  margin-bottom: 28px;
}

.login-form {
  text-align: left;
}

.login-error {
  font-size: 13px;
  color: #b44;
  margin-bottom: 12px;
}

input[type="date"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  appearance: none;
}
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="password"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  appearance: none;
}
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Place card ──────────────────────────── */

.place-type-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #3d7a5c;
  margin-bottom: 3px;
}

.place-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.place-rating-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  flex-shrink: 0;
}
.place-rating-badge[data-rating="bad"]   { background: #b44; }
.place-rating-badge[data-rating="good"]  { background: var(--gold); }
.place-rating-badge[data-rating="great"] { background: #3d7a5c; }
.place-rating-badge[data-rating="super"] { background: var(--accent); }

.place-location-link {
  display: inline-block;
  font-size: 13px;
  color: #3d7a5c;
  text-decoration: none;
  margin-bottom: 10px;
}
.place-location-link:hover { text-decoration: underline; }

.place-description {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

/* ── Place form ──────────────────────────── */

.place-form-preview {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 10px;
}
.place-form-preview img {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}

/* ── Rating pills ────────────────────────── */

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

.rating-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.rating-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.rating-pill:has(input:checked) { color: #fff; border-color: transparent; }
.rating-pill[data-rating="bad"]:has(input:checked)   { background: #b44; }
.rating-pill[data-rating="good"]:has(input:checked)  { background: var(--gold); }
.rating-pill[data-rating="great"]:has(input:checked) { background: #3d7a5c; }
.rating-pill[data-rating="super"]:has(input:checked) { background: var(--accent); }
