/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --border: #e8e4de;
  --accent: #c1440e;
  --accent-hover: #a33a0c;
  --accent-light: #fdf0eb;
  --text: #1a1a1a;
  --text-muted: #6b6560;
  --text-light: #9e9890;
  --up: #2a9d5c;
  --up-bg: #edf7f2;
  --down: #c1440e;
  --down-bg: #fdf0eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.07), 0 0 1px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12), 0 0 1px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px;
  display: flex; align-items: center; gap: 6px; color: var(--text);
}
.brand-icon { font-size: 1.2rem; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-user {
  font-size: .875rem; font-weight: 600;
  background: var(--accent-light); color: var(--accent);
  padding: 4px 10px; border-radius: 20px;
}
.btn-link {
  background: none; border: none; color: var(--text-muted);
  font-size: .875rem; padding: 4px 8px;
}
.btn-link:hover { color: var(--text); }

/* ── Auth ───────────────────────────────────────────────────────────────────── */
.auth-body { background: var(--bg); }
.auth-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.auth-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 40px;
  width: 100%; max-width: 380px; text-align: center;
}
.auth-logo { font-size: 2.5rem; margin-bottom: 8px; }
.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }
.auth-footer { margin-top: 20px; color: var(--text-muted); font-size: .875rem; }
.auth-footer a { color: var(--accent); font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); font-size: .95rem; color: var(--text);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optional { font-weight: 400; color: var(--text-light); text-transform: none; letter-spacing: 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  padding: 9px 20px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; border: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg); color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-full { width: 100%; padding: 12px; font-size: 1rem; }
.icon-btn {
  background: none; border: none; padding: 4px 6px;
  border-radius: 6px; color: var(--text-muted); font-size: .9rem;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ── Alert ──────────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .875rem; text-align: left; }
.alert-error { background: var(--down-bg); color: var(--down); border: 1px solid #f5c5b3; }

/* ── Page layout ────────────────────────────────────────────────────────────── */
main { width: 80%; max-width: 1600px; margin: 0 auto; padding: 32px 24px; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px;
}
.page-title { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.page-subtitle { color: var(--text-muted); font-size: .95rem; margin-top: 4px; }

/* ── Rooms grid ─────────────────────────────────────────────────────────────── */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.room-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: block;
}
.room-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.room-thumb { height: 140px; background: var(--border); overflow: hidden; }
.room-thumb img { width: 100%; height: 100%; object-fit: cover; }
.room-thumb-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; font-size: 2.5rem; background: #f0ece6;
}
.room-card-body { padding: 14px 16px; }
.room-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.room-name { font-size: 1rem; font-weight: 700; }
.room-card-btns { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.room-card:hover .room-card-btns { opacity: 1; }
.room-card-btns .icon-btn:last-child:hover { color: var(--down) !important; background: var(--down-bg) !important; }
.room-desc { font-size: .85rem; color: var(--text-muted); margin-bottom: 8px; }
.room-meta { display: flex; gap: 12px; font-size: .8rem; color: var(--text-light); }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1; text-align: center; padding: 60px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-hint { font-size: .875rem; color: var(--text-light); margin-top: 6px; }

/* ── Room page ──────────────────────────────────────────────────────────────── */
.room-header { margin-bottom: 24px; }
.back-link { font-size: .875rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.back-link:hover { color: var(--accent); }

/* ── Drop zone ──────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 24px; text-align: center; margin-bottom: 32px;
  background: var(--surface); transition: border-color .2s, background .2s;
  cursor: default;
}
.drop-zone.dragover {
  border-color: var(--accent); background: var(--accent-light);
}
.drop-zone.uploading { opacity: .7; pointer-events: none; }
.drop-icon { font-size: 2rem; margin-bottom: 8px; }
.drop-text { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.drop-hint { font-size: .875rem; color: var(--text-muted); }
.file-label { color: var(--accent); font-weight: 600; cursor: pointer; }
.file-label:hover { text-decoration: underline; }

/* ── Items grid ─────────────────────────────────────────────────────────────── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.item-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.item-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.item-card.new-item { animation: popIn .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes popIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

.item-thumb {
  width: 100%; aspect-ratio: 4/3; overflow: hidden;
  background: #f0ece6; position: relative; flex-shrink: 0;
}
.item-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .3s;
}
.item-card:hover .item-thumb img { transform: scale(1.03); }
.item-thumb-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; font-size: 2.5rem; color: var(--text-light);
}
.item-thumb.clickable { cursor: pointer; }
/* ── Veto overlay ───────────────────────────────────────────────────────────── */
.item-card.vetoed .item-thumb::before {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: rgba(190, 20, 20, 0.28);
}
.item-card.vetoed .item-thumb::after {
  content: '';
  position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(
    135deg,
    transparent 42%,
    rgba(200, 20, 20, 0.85) 42%,
    rgba(200, 20, 20, 0.85) 58%,
    transparent 58%
  );
}
.item-card.vetoed .item-thumb { position: relative; }
.veto-banner {
  font-size: .7rem; font-weight: 700; letter-spacing: .4px;
  color: #c0160f; background: #fde8e7;
  border: 1px solid #f5b8b5; border-radius: 20px;
  padding: 2px 8px; white-space: nowrap;
}
.veto-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .78rem; font-weight: 700; color: var(--text-muted);
  transition: all .15s; cursor: pointer;
}
.veto-btn:hover { border-color: #c0160f; color: #c0160f; background: #fde8e7; }
.veto-btn.active { background: #fde8e7; border-color: #c0160f; color: #c0160f; }

.link-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: .7rem; padding: 2px 7px; border-radius: 20px; backdrop-filter: blur(4px);
}

.item-body { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.item-title { font-size: .95rem; font-weight: 700; line-height: 1.3; flex: 1; }
.item-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.item-card:hover .item-actions { opacity: 1; }

.item-meta-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.price-badge {
  background: var(--accent-light); color: var(--accent);
  font-size: .8rem; font-weight: 700; padding: 3px 9px; border-radius: 20px;
}
.buy-link {
  font-size: .8rem; font-weight: 600; color: var(--up);
  background: var(--up-bg); padding: 3px 10px; border-radius: 20px;
  transition: background .15s;
}
.buy-link:hover { background: #d5f0e3; }

.item-notes { font-size: .85rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }

.item-footer {
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.added-by { font-size: .75rem; color: var(--text-light); }

.vote-row { display: flex; gap: 6px; }
.vote-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; border: 1.5px solid var(--border);
  font-size: .8rem; font-weight: 600; background: var(--surface);
  color: var(--text-muted); transition: all .15s;
}
.vote-btn:hover { border-color: var(--text-muted); color: var(--text); }
.vote-btn.active-up { background: var(--up-bg); border-color: var(--up); color: var(--up); }
.vote-btn.active-down { background: var(--down-bg); border-color: var(--down); color: var(--down); }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(2px); }
.modal-box {
  position: relative; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 28px; width: 100%; max-width: 460px;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 20px; }

/* ── Loading ────────────────────────────────────────────────────────────────── */
.loading-row { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .875rem; margin-bottom: 14px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .6s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1a1a1a; color: #fff; padding: 10px 20px; border-radius: 24px;
  font-size: .875rem; font-weight: 500; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease; opacity: 0; z-index: 300;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Upload progress overlay ────────────────────────────────────────────────── */
.upload-overlay {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  background: var(--surface); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; font-size: .875rem;
}

/* ── Cost bar ───────────────────────────────────────────────────────────────── */
.cost-bar {
  display: flex; gap: 28px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px; margin-bottom: 24px;
}
.cost-stat { display: flex; flex-direction: column; gap: 1px; }
.cost-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.cost-value { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.cost-fun { color: #a07000; }

/* ── Room card cost ─────────────────────────────────────────────────────────── */
.room-cost { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.room-cost-required { font-size: .85rem; font-weight: 700; color: var(--text); }
.room-cost-fun { font-size: .78rem; color: #a07000; background: #fff8e1; border: 1px solid #f0d060; padding: 1px 7px; border-radius: 20px; }

/* ── Fun / optional item ────────────────────────────────────────────────────── */
.item-card.optional { border: 2px solid #f0c040; }
.fun-badge {
  font-size: .7rem; font-weight: 700; letter-spacing: .3px;
  color: #a07000; background: #fff8e1; border: 1px solid #f0c040;
  border-radius: 20px; padding: 2px 8px; white-space: nowrap;
}
.fun-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .78rem; font-weight: 700; color: var(--text-muted);
  transition: all .15s; cursor: pointer;
}
.fun-btn:hover { border-color: #f0c040; color: #a07000; background: #fff8e1; }
.fun-btn.active { background: #fff8e1; border-color: #f0c040; color: #a07000; }

/* ── Room header row ────────────────────────────────────────────────────────── */
.room-header-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tab-row { display: flex; gap: 6px; margin-bottom: 20px; }
.tab-btn {
  flex: 1; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-size: .875rem; font-weight: 600; color: var(--text-muted);
  transition: all .15s;
}
.tab-btn:hover { border-color: var(--text-muted); color: var(--text); }
.tab-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ── Tab divider ("or") ─────────────────────────────────────────────────────── */
.tab-divider {
  text-align: center; font-size: .78rem; font-weight: 600;
  color: var(--text-light); margin: 4px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.tab-divider::before, .tab-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── File drop area (inside modal) ──────────────────────────────────────────── */
.file-drop-area {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 90px; padding: 16px;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--bg); cursor: pointer; text-align: center;
  font-size: .875rem; color: var(--text-muted);
  transition: border-color .15s, background .15s;
}
.file-drop-area:hover, .file-drop-area.dragover {
  border-color: var(--accent); background: var(--accent-light); color: var(--accent);
}
.file-drop-area.has-file { border-style: solid; border-color: var(--up); color: var(--up); background: var(--up-bg); }

/* ── Budget panel ────────────────────────────────────────────────────────────── */
.budget-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.budget-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.budget-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.budget-bar-track {
  position: relative; width: 100%; height: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden; margin-bottom: 14px;
  display: flex;
}
.budget-bar-spent { background: var(--accent); height: 100%; transition: width .3s ease; }
.budget-bar-planned { background: #f0c040; height: 100%; transition: width .3s ease; }
.budget-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 18px;
}
.budget-stat { display: flex; flex-direction: column; gap: 2px; }
.budget-stat-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
}
.budget-stat-value { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.budget-spent { color: var(--accent); }
.budget-planned { color: #a07000; }
.budget-good { color: var(--up); }
.budget-over { color: var(--down); }

/* ── Invoices list (in budget modal) ─────────────────────────────────────────── */
.modal-subtitle { font-size: .85rem; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .4px; }
.invoice-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px; background: var(--bg);
}
.invoice-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.invoice-main { flex: 1; min-width: 0; }
.invoice-desc { font-size: .9rem; font-weight: 600; color: var(--text); }
.invoice-meta { font-size: .72rem; color: var(--text-light); display: flex; gap: 4px; }
.invoice-amount { font-size: .95rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.invoice-del { color: var(--text-light); }
.invoice-del:hover { color: var(--down) !important; background: var(--down-bg) !important; }
.invoice-empty { padding: 16px; text-align: center; color: var(--text-light); font-style: italic; font-size: .85rem; }

/* ── Search bar ──────────────────────────────────────────────────────────────── */
.search-bar-wrap { margin-bottom: 16px; }
.search-bar {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: .95rem; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.search-bar:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.search-bar::-webkit-search-cancel-button { cursor: pointer; }

/* ── Pin / favorite ─────────────────────────────────────────────────────────── */
.pin-btn {
  background: none; border: 1.5px solid transparent; padding: 3px 8px;
  border-radius: 20px; font-size: .85rem; font-weight: 700;
  color: var(--text-light); cursor: pointer;
  transition: all .15s; display: inline-flex; align-items: center; gap: 4px;
}
.pin-btn:hover { color: #b8860b; background: #fff8e1; }
.pin-btn.active { color: #b8860b; background: #fff8e1; border-color: #f0c040; }
.pin-count { font-size: .72rem; font-weight: 700; }
.item-card.favorited { box-shadow: var(--shadow-lg), 0 0 0 2px #f0c040; }

/* ── Drag and drop ──────────────────────────────────────────────────────────── */
.item-card { cursor: grab; }
.item-card.dragging { opacity: .35; cursor: grabbing; }
.group-grid.drop-target {
  outline: 2px dashed var(--accent); outline-offset: 4px;
  background: var(--accent-light); border-radius: var(--radius-sm);
}
/* Make sure interactive child elements don't intercept drags */
.item-card a, .item-card button, .item-card input { cursor: pointer; }
.item-card input[type="text"], .item-card .comments-input { cursor: text; }

/* ── Comments ───────────────────────────────────────────────────────────────── */
.comments-toggle-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .78rem; font-weight: 700; color: var(--text-muted);
  transition: all .15s; cursor: pointer;
}
.comments-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.comments-section {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; max-height: 240px; overflow-y: auto; }
.comments-loading, .comments-empty {
  font-size: .8rem; color: var(--text-light); padding: 6px 0; font-style: italic;
}
.comment-row { background: var(--bg); padding: 6px 10px; border-radius: var(--radius-sm); }
.comment-meta { display: flex; align-items: center; gap: 4px; font-size: .72rem; color: var(--text-muted); margin-bottom: 2px; }
.comment-author { font-weight: 700; color: var(--text); }
.comment-time { color: var(--text-light); }
.comment-del {
  margin-left: auto; background: none; border: none; color: var(--text-light);
  font-size: 1.1rem; line-height: 1; padding: 0 4px; cursor: pointer; border-radius: 4px;
}
.comment-del:hover { color: var(--down); background: var(--down-bg); }
.comment-body { font-size: .85rem; color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.comments-compose { display: flex; gap: 6px; }
.comments-input {
  flex: 1; padding: 6px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  font-size: .85rem; color: var(--text);
}
.comments-input:focus { outline: none; border-color: var(--accent); }

/* ── Item lightbox (reusing the lightbox class from floorplan) ──────────────── */
/* (.lightbox styles are already defined globally) */

/* ── Search-hidden group sections ──────────────────────────────────────────── */
.group-section.search-hidden { display: none; }

/* ── Thumbnail preview (edit modal) ─────────────────────────────────────────── */
.thumb-preview-wrap { margin-bottom: 8px; }
.thumb-preview-img {
  width: 100%; max-height: 160px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border); display: block;
}

/* ── Group sections ──────────────────────────────────────────────────────────── */
.group-section { margin-bottom: 36px; }
.group-section:last-child { margin-bottom: 0; }
.group-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 14px;
}
.group-name-heading {
  font-size: 1rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.group-name-heading::before { content: ''; display: inline-block; width: 3px; height: 1em; background: var(--accent); border-radius: 2px; }
.ungrouped-label { color: var(--text-muted); font-weight: 600; }
.ungrouped-label::before { background: var(--border); }
.group-hdr-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.group-section:hover .group-hdr-actions { opacity: 1; }
.group-hdr-actions .group-delete-btn:hover { color: var(--down) !important; background: var(--down-bg) !important; }
.group-grid { min-height: 60px; }

/* ── Quantity stepper ───────────────────────────────────────────────────────── */
.qty-stepper {
  display: flex; align-items: center; gap: 0;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface);
}
.qty-btn {
  background: var(--bg); border: none; padding: 8px 12px;
  font-size: 1rem; font-weight: 600; color: var(--text-muted);
  transition: background .15s, color .15s; line-height: 1;
}
.qty-btn:hover { background: var(--border); color: var(--text); }
.qty-stepper input[type="number"] {
  width: 48px; border: none; border-left: 1.5px solid var(--border); border-right: 1.5px solid var(--border);
  text-align: center; padding: 8px 4px; font-size: .95rem; font-weight: 600;
  background: var(--surface); color: var(--text);
  -moz-appearance: textfield;
}
.qty-stepper input[type="number"]::-webkit-inner-spin-button,
.qty-stepper input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.qty-stepper input[type="number"]:focus { outline: none; }

/* ── Price with quantity ─────────────────────────────────────────────────────── */
.price-qty {
  font-size: .72rem; font-weight: 600; color: var(--accent); opacity: .8; margin-left: 2px;
}
.price-total {
  background: var(--accent); color: #fff;
  font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 20px;
}

/* ── Homepage two-column layout ─────────────────────────────────────────────── */
.homepage-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}
.homepage-main { min-width: 0; }

/* ── Floor plan panel ────────────────────────────────────────────────────────── */
.floorplan-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; position: sticky; top: 76px;
}
.floorplan-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.floorplan-title { font-size: .85rem; font-weight: 700; color: var(--text-muted); }
.floorplan-actions { display: flex; gap: 6px; align-items: center; }
.floorplan-body { padding: 0; }
.floorplan-img {
  width: 100%; display: block; cursor: zoom-in;
  transition: opacity .2s;
}
.floorplan-img:hover { opacity: .92; }
.floorplan-empty {
  padding: 40px 20px; text-align: center; color: var(--text-muted);
}
.floorplan-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.floorplan-empty p { font-size: .9rem; }
.floorplan-empty-hint { font-size: .8rem; color: var(--text-light); margin-top: 4px; }

/* ── Small buttons ───────────────────────────────────────────────────────────── */
.btn-sm { padding: 5px 12px; font-size: .8rem; cursor: pointer; }
.btn-danger {
  background: var(--down-bg); color: var(--down);
  border: 1.5px solid #f5c5b3;
}
.btn-danger:hover { background: #f9d5c8; }

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.85); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .homepage-layout { grid-template-columns: 1fr; }
  .floorplan-panel { position: static; }
  /* Floorplan shouldn't dominate the stacked layout */
  .floorplan-img { max-height: 360px; object-fit: contain; background: #f0ece6; }
}
@media (max-width: 768px) {
  main { width: 96%; }
  /* Stack header buttons */
  .room-header-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .room-header-row > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; }
  .room-header-row > div:last-child .btn { flex: 1; min-width: 0; }
  /* Cost bar wrap */
  .cost-bar { gap: 16px; padding: 10px 14px; }
  /* Modal: make scrollable on short viewports */
  .modal-box { max-height: 90vh; overflow-y: auto; }
  /* Reveal action buttons by default on touch (no hover) */
  .item-actions, .group-hdr-actions, .room-card-btns { opacity: 1; }
}
@media (max-width: 600px) {
  main { width: 100%; padding: 20px 16px; }
  .page-header { flex-direction: column; gap: 12px; }
  .rooms-grid { grid-template-columns: 1fr 1fr; }
  .items-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .vote-row { flex-wrap: wrap; }
  .item-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .modal-box { padding: 20px; }
  /* Drag on touch is awkward — rely on the edit modal group selector instead */
  .item-card { cursor: default; }
}
