:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #2b2a26;
  --muted: #8a857a;
  --line: #e3ded2;
  --accent: #3f6e4e;        /* alpine pine green */
  --accent-ink: #ffffff;
  --warn: #b23b3b;
  --shadow: 0 6px 24px rgba(40, 38, 32, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Chalet photo behind the app (all tabs, never the login screen). Fixed = iOS-friendly. */
body.app-bg::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(rgba(244, 241, 234, 0.55), rgba(244, 241, 234, 0.72)),
    url("/amden-house.jpg") center / cover no-repeat;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; border-radius: 10px; }
a { color: var(--accent); }

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #ffffff;
}
.login-card {
  background: transparent; box-shadow: none; padding: 0;
  text-align: left; width: 420px; max-width: 88vw;
}
.login-card h1 {
  font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 400;
  font-size: 56px; color: #2b2a26; margin: 0 0 16px; letter-spacing: 0;
}
.login-sub { font-size: 20px; color: #3a3a37; margin: 0 0 56px; }
.login-card input {
  width: 100%; padding: 10px 2px; background: transparent;
  border: none; border-bottom: 1px solid #cfccc5; border-radius: 0;
  font-family: Georgia, "Times New Roman", serif; font-style: italic;
  font-size: 20px; color: #2b2a26; margin-bottom: 44px;
}
.login-card input::placeholder { color: #b9b6ae; font-style: italic; }
.login-card input:focus { outline: none; border-bottom-color: var(--accent); }
.login-card button {
  width: 100%; padding: 16px; background: #6fae8d; color: #ffffff;
  font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 400;
  border-radius: 2px;
}
.login-card button:hover { background: #649e7f; }
.login-error { color: var(--warn); min-height: 18px; margin: 16px 0 0; font-size: 14px; }

@media (max-width: 520px) {
  .login-card h1 { font-size: 42px; }
}

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; object-fit: contain; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab {
  background: transparent; color: var(--muted); padding: 8px 14px; font-weight: 600; font-size: 14px;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--accent); color: var(--accent-ink); }
.logout { background: transparent; color: var(--muted); padding: 8px 12px; font-size: 14px; margin-left: auto; }
.logout:hover { color: var(--warn); }
.active-section { display: none; } /* shown only on mobile (see media query) */

/* Hamburger (mobile only) */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 36px; padding: 0 9px; background: transparent;
  border: 1px solid var(--line); border-radius: 8px;
}
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.topbar.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.topbar.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

main { max-width: 1040px; margin: 0 auto; padding: 26px 22px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 24px; }
.section-h { margin: 30px 0 12px; font-size: 17px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.primary { background: var(--accent); color: var(--accent-ink); padding: 10px 16px; font-weight: 600; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 8px 12px; }
.ghost.small { padding: 6px 10px; font-size: 13px; }
.danger { background: var(--warn); color: #fff; padding: 9px 14px; }

/* ---------- Calendar ---------- */
.cal-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-title { font-weight: 700; font-size: 18px; min-width: 180px; text-align: center; }
.calendar {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.cal-cell {
  min-height: 78px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  display: flex; flex-direction: column; gap: 3px; background: #fbfaf6; position: relative;
}
.cal-cell.out { opacity: 0.4; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-date { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-cell.today .cal-date { color: var(--accent); }
.cal-chip {
  font-size: 11px; line-height: 1.3; padding: 2px 6px; border-radius: 6px;
  color: #fff; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; max-width: 100%; align-self: stretch; box-sizing: border-box;
}
.cal-chip.flash { animation: chip-flash 0.5s ease-in-out 3; }
@keyframes chip-flash {
  0%, 100% { box-shadow: none; transform: scale(1); }
  50% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); transform: scale(1.06); }
}

/* ---------- Reservation list ---------- */
.res-list { display: flex; flex-direction: column; gap: 8px; }
.res-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
}
.res-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.res-who { font-weight: 700; }
.res-dates { color: var(--muted); font-size: 14px; }
.res-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.res-nights { font-size: 13px; color: var(--muted); }
.res-edit { background: transparent; border: 1px solid var(--line); padding: 6px 12px; }
.empty { color: var(--muted); padding: 18px; text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; }

/* ---------- Change log ---------- */
.log-box { margin-top: 26px; }
.log-box summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.log-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.log-item { display: flex; gap: 10px; padding: 6px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.log-time { color: var(--muted); white-space: nowrap; }
.log-action { font-weight: 700; text-transform: uppercase; font-size: 11px; }
.log-action.create { color: var(--accent); }
.log-action.update { color: #b8860b; }
.log-action.delete { color: var(--warn); }

/* ---------- Frames (PDF / Google Doc) ---------- */
.frame-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.frame-wrap iframe, .frame-wrap embed { width: 100%; height: 78vh; border: 0; display: block; }
.frame-note { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Photos ---------- */
.photo-actions { display: flex; gap: 8px; align-items: center; }

/* Album switcher bar */
.album-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px;
  margin-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.album-chip {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px;
  flex: 0 0 auto; box-shadow: var(--shadow);
}
.album-chip:hover { border-color: var(--accent); }
.album-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.album-chip-count {
  background: rgba(0,0,0,0.08); color: inherit; font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px; min-width: 20px; text-align: center;
}
.album-chip.active .album-chip-count { background: rgba(255,255,255,0.22); }
.album-chip.trash-chip { margin-left: 6px; }
.album-chip.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Context toolbar (album name + actions, trash actions, drop hint) */
.album-toolbar { display: flex; align-items: center; gap: 10px; min-height: 0; margin-bottom: 14px; flex-wrap: wrap; }
.album-toolbar:empty { display: none; }
.album-toolbar .at-title { font-weight: 700; font-size: 16px; }
.album-toolbar .at-note { color: var(--muted); font-size: 13px; }
.album-toolbar .spacer { flex: 1; }
.link-btn { background: transparent; border: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 6px; }
.link-btn.warn { color: var(--warn); }

/* Storage meter */
.storage-meter {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; box-shadow: var(--shadow); margin-bottom: 16px; font-size: 13px;
}
.storage-meter.hidden { display: none; }
.sm-label { font-weight: 700; white-space: nowrap; }
.sm-bar { flex: 1; min-width: 120px; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.sm-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
.sm-fill.warn { background: #c79019; }
.sm-fill.crit { background: var(--warn); }
.sm-sub { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sm-sub strong { color: var(--ink); font-weight: 700; }
.sm-warn { color: var(--warn); font-weight: 600; white-space: nowrap; }
.upload-space { color: var(--muted); font-size: 12px; margin: 0 0 8px; min-height: 14px; }
.upload-space.low { color: var(--warn); font-weight: 600; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.photo-month { grid-column: 1 / -1; margin: 14px 0 0; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.photo-month:first-child { margin-top: 0; }
.photo-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.photo-thumb { position: relative; cursor: pointer; }
.photo-card img, .photo-card video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #e9e6dd; }
.photo-card video { pointer-events: none; }
/* Video play badge */
.play-badge {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.play-badge::after {
  content: "▶"; color: #fff; font-size: 18px; line-height: 1;
  width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding-left: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.media-dur {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,0.6); color: #fff;
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; pointer-events: none;
}
.photo-meta { padding: 8px 10px; font-size: 13px; }
.photo-cap { font-weight: 600; word-break: break-word; }
.photo-cap.placeholder { color: var(--muted); font-weight: 500; font-style: italic; }
.photo-by { color: var(--muted); font-size: 12px; }

/* Selection mode */
.photo-grid.selecting .photo-thumb { cursor: pointer; }
.photo-check {
  position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.85); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  display: none; align-items: center; justify-content: center; z-index: 2; color: #fff; font-size: 14px;
}
.photo-grid.selecting .photo-check { display: flex; }
.photo-card.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.photo-card.selected .photo-check { background: var(--accent); border-color: #fff; }
.photo-card.selected .photo-check::after { content: "✓"; }

/* Floating selection action bar */
.select-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom)); z-index: 55;
  display: flex; align-items: center; gap: 10px; width: min(620px, calc(100vw - 28px));
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; box-shadow: 0 10px 30px rgba(40,38,32,0.22);
}
.select-bar .small { padding: 7px 12px; }
.select-del { color: var(--warn); border-color: var(--line); }
#select-count { font-weight: 700; font-size: 14px; }

/* Trash cards */
.trash-actions { display: flex; gap: 6px; padding: 8px 10px 10px; }
.trash-actions button { flex: 1; font-size: 12px; padding: 6px 8px; }

/* Drop zone (upload modal) */
.drop-zone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 26px 16px; text-align: center;
  cursor: pointer; transition: border-color 0.15s, background 0.15s; background: #fbfaf6; margin-bottom: 14px;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: #eef6f0; }
.drop-icon { font-size: 26px; }
.drop-title { font-weight: 700; margin-top: 6px; }
.drop-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.drop-link { color: var(--accent); font-weight: 600; text-decoration: underline; }
.drop-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; max-height: 180px; overflow-y: auto; }
.drop-list:empty { display: none; }
.drop-item { display: flex; align-items: center; gap: 10px; background: #fbfaf6; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; font-size: 13px; }
.drop-item .di-thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; background: #e9e6dd; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.drop-item .di-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-item .di-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.drop-item .di-remove { background: transparent; border: none; color: var(--muted); font-size: 16px; padding: 0 4px; }
.drop-item .di-remove:hover { color: var(--warn); }
.field { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.select { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; font-weight: 400; background: #fff; }
.upload-progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 4px 0 8px; }
.upload-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s ease; }

/* Move-to-album modal */
.move-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.move-opt { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; background: #fbfaf6; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font-size: 14px; font-weight: 600; }
.move-opt:hover { border-color: var(--accent); background: #eef6f0; }
.move-opt .mo-count { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 600; }
.move-opt.current { opacity: 0.5; pointer-events: none; }
.move-new { display: flex; gap: 8px; margin-bottom: 6px; }
.move-new input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }

/* Toast (undo) */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(20px, env(safe-area-inset-bottom)); z-index: 80;
  display: flex; align-items: center; gap: 14px;
  background: #2b2a26; color: #fff; border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3); font-size: 14px; max-width: calc(100vw - 28px);
}
.toast-action { background: transparent; border: none; color: #8fd0ac; font-weight: 700; font-size: 14px; padding: 2px 4px; }
.toast.hidden { display: none; }

/* ---------- Documents ---------- */
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.doc-icon { font-size: 22px; }
.doc-name { font-weight: 600; word-break: break-word; }
.doc-sub { color: var(--muted); font-size: 13px; }
.doc-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Modals ---------- */
/* z-index 70 so modals opened from the viewer (move, edit) sit ABOVE the lightbox (60). */
.modal { position: fixed; inset: 0; background: rgba(30, 28, 24, 0.5); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 16px; }
.edit-hint { color: var(--muted); font-size: 12px; margin: -4px 0 4px; }
.modal-card { background: var(--card); border-radius: 16px; padding: 26px; width: 380px; max-width: 100%; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 16px; }
.modal-card label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.modal-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; font-weight: 400; }
.color-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.color-row input[type="color"] {
  width: 52px; height: 38px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: none; cursor: pointer;
}
.color-hex { font-size: 13px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }
.form-error { color: var(--warn); min-height: 18px; margin: 4px 0 0; font-size: 13px; }

/* ---------- Viewer / player (lightbox) ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px; }
.lb-stage { display: flex; align-items: center; justify-content: center; max-width: 94vw; max-height: 82vh; }
.lb-stage img, .lb-stage video { max-width: 94vw; max-height: 82vh; border-radius: 8px; display: block; background: #000; }
.lb-stage video { outline: none; }
.lb-close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; font-size: 17px; display: flex; align-items: center; justify-content: center; z-index: 2; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center; z-index: 2; }
.lb-nav:active { background: rgba(255,255,255,0.3); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; padding: 18px 20px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0,0,0,0.72), transparent); }
.lb-info { min-width: 0; flex: 1; }
.lightbox-cap { color: #fff; font-size: 16px; font-weight: 600; word-break: break-word; cursor: pointer; }
.lightbox-cap:hover { text-decoration: underline; text-decoration-style: dotted; }
.lightbox-cap.placeholder { color: #b9b6ae; font-weight: 500; font-style: italic; }
.lightbox-sub { color: #b9b6ae; font-size: 13px; margin-top: 3px; }
.lb-cap-input { width: 100%; max-width: 420px; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.3); border-radius: 8px; color: #fff; font-size: 16px; font-weight: 600; padding: 8px 10px; font-family: inherit; }
.lb-date-input { margin-top: 3px; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.35); border-radius: 8px; color: #fff; font-size: 14px; padding: 6px 10px; font-family: inherit; color-scheme: dark; }
.lb-tools { display: flex; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.lb-tool { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.22); padding: 8px 14px; font-size: 13px; font-weight: 600; }
.lb-tool:active { background: rgba(255,255,255,0.26); }
.lb-tool.lb-del { color: #ff9a9a; border-color: rgba(255,138,138,0.45); }
.lb-tool.lb-del:active { background: rgba(255,138,138,0.18); }

/* ---------- Beslissers (decision-maker rotation) ---------- */
.deciders-intro { color: var(--muted); margin: -6px 0 18px; max-width: 60ch; }
.dec-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.dec-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.dec-head { background: #f4f1ea; padding: 12px 16px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--line); }
.dec-card.current .dec-head { background: var(--accent); color: var(--accent-ink); border-bottom: none; }
.dec-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.dec-row:first-of-type { border-top: none; }
.dec-period { color: var(--muted); font-size: 14px; flex: 1; }
.dec-name { font-weight: 700; }
.dec-row.now { background: #eef6f0; }
.dec-row.now .dec-period { color: var(--ink); }
.dec-badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.dec-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dec-toolbar .section-h { margin: 30px 0 12px; }
.dec-edit, .dec-save, .dec-cancel { background: transparent; border: 1px solid var(--line); width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; font-size: 14px; }
.dec-edit { color: var(--muted); }
.dec-edit:hover { color: var(--ink); }
.dec-save { border-color: var(--accent); color: var(--accent); }
.dec-cancel { color: var(--warn); }
.dec-input { flex: 0 1 190px; padding: 6px 9px; border: 1px solid var(--accent); border-radius: 8px; font: inherit; font-weight: 700; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .topbar {
    padding: 10px 14px; padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right)); gap: 10px;
  }
  .brand { font-size: 18px; }
  .active-section {
    display: block; flex: 1; text-align: center; font-weight: 600; font-size: 15px;
    color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  }
  .nav-toggle { display: flex; margin-left: auto; }

  /* Tabs become a full-width slide-down drawer */
  .tabs {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; flex-wrap: nowrap; gap: 0;
    background: var(--card); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    max-height: 0; overflow: hidden; padding: 0;
    transition: max-height 0.25s ease;
  }
  .topbar.nav-open .tabs { max-height: 85vh; overflow-y: auto; }
  .tab {
    width: 100%; text-align: left; border-radius: 0;
    padding: 16px 20px; font-size: 16px; border-bottom: 1px solid var(--line);
  }
  .tab.active { background: var(--accent); color: var(--accent-ink); }
  .logout {
    width: 100%; text-align: left; margin-left: 0;
    padding: 16px 20px; font-size: 16px;
  }
  main { padding: 18px 14px 80px; }
  .panel-head h2 { font-size: 21px; }
}

@media (max-width: 560px) {
  .calendar { gap: 4px; padding: 8px; }
  .cal-cell { min-height: 58px; padding: 4px; }
  .cal-date { font-size: 11px; }
  .cal-chip { font-size: 10px; padding: 1px 4px; }
  .cal-dow { font-size: 10px; }
  .cal-title { font-size: 16px; min-width: 110px; }

  .res-row { flex-wrap: wrap; }
  .res-meta { margin-left: 0; width: 100%; justify-content: space-between; }

  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }

  /* Viewer bar stacks: caption on top, tools below, full-width tappable */
  .lb-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .lb-tools { justify-content: space-between; }
  .lb-tool { flex: 1; text-align: center; padding: 10px 8px; }
  .lb-cap-input { max-width: none; }

  .select-bar { gap: 6px; padding: 9px 10px; }
  .select-bar .small { padding: 8px 9px; font-size: 13px; }
  #select-count { font-size: 13px; }

  .doc-row { flex-wrap: wrap; }
  .doc-actions { margin-left: 0; width: 100%; }

  .frame-wrap iframe, .frame-wrap embed { height: 72vh; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card { width: 100%; border-radius: 16px 16px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
}
