:root {
  --primary: #8b5e3c;
  --primary-dark: #6f4527;
  --secondary: #fdf6e3;
  --accent: #2a9d8f;
  --paper: #fffdf5;
  --ink: #4a3524;
  --muted: #8a7a6a;
  --cork: #c89b62;
  --cork-hi: #d4a86f;
  --cork-lo: #b5874f;
  --brick: #a54a32;
  --brick-lo: #8f3d28;
  --brick-hi: #b8583d;
  --wood: #4a3324;
  --wood-hi: #5d4330;
  --shadow: rgba(0,0,0,.25);
  --pin-red: #d33f3f;
  --pin-blue: #3f7fd3;
  --pin-green: #3fae6d;
  --pin-yellow: #e0b93f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --hand: "Comic Sans MS", "Segoe Print", "Bradley Hand", "Brush Script MT", "Comic Sans", cursive;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--hand);
  color: var(--ink);
  background: var(--brick);
  /* brick wall */
  background-image:
    linear-gradient(90deg, transparent 46%, rgba(0,0,0,.07) 48%, rgba(0,0,0,.07) 50%, transparent 52%),
    linear-gradient(0deg, transparent 46%, rgba(0,0,0,.06) 48%, rgba(0,0,0,.06) 50%, transparent 52%),
    linear-gradient(135deg, var(--brick-hi), var(--brick) 50%, var(--brick-lo));
  background-size: 76px 40px, 76px 40px, 100% 100%;
  min-height: 100vh;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Wooden frame ---- */
#masthead {
  padding: calc(var(--safe-top) + 10px) 16px 12px;
  text-align: center;
  color: var(--secondary);
  background: var(--wood);
  box-shadow: inset 0 0 0 4px var(--wood-hi), inset 0 -4px 8px rgba(0,0,0,.35);
  border-bottom: 3px solid #2f2218;
}
.mast-logo { font-size: 26px; }
#masthead h1 { margin: 2px 0 0; font-size: 26px; letter-spacing: 1px; }
.mast-sub { font-size: 12px; opacity: .85; font-style: italic; }

/* ---- Corkboard main area ---- */
#board {
  flex: 1;
  background:
    radial-gradient(circle at 12px 8px, rgba(0,0,0,.12) 3px, transparent 3.5px),
    radial-gradient(circle at 1px 34px, rgba(0,0,0,.10) 2px, transparent 2.5px),
    radial-gradient(circle at 54px 22px, rgba(255,255,255,.10) 3px, transparent 3.5px),
    radial-gradient(circle at 3px 64px, rgba(0,0,0,.08) 2px, transparent 2.5px),
    radial-gradient(circle at 40px 70px, rgba(0,0,0,.09) 2px, transparent 2.5px),
    radial-gradient(circle at 30px 4px, rgba(0,0,0,.10) 2px, transparent 2.5px),
    linear-gradient(120deg, var(--cork-hi), var(--cork) 45%, var(--cork-lo));
  padding: 14px 12px 96px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#board::-webkit-scrollbar { width: 0; }

/* ---- Tabs ---- */
.tabpane { display: none; animation: fade .22s ease; }
.tabpane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title {
  font-family: var(--serif);
  color: var(--secondary);
  text-shadow: 1px 1px 2px rgba(0,0,0,.35);
  margin: 4px 2px 12px;
  font-size: 18px;
}

/* ---- Bottom tab bar as pushpins ---- */
#tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(64px + var(--safe-bottom));
  padding: 8px 6px var(--safe-bottom);
  display: flex;
  background: var(--wood);
  box-shadow: inset 0 3px 6px rgba(0,0,0,.4), 0 -2px 10px rgba(0,0,0,.25);
  border-top: 3px solid var(--wood-hi);
  z-index: 40;
}
.tab {
  flex: 1;
  border: 0;
  background: none;
  color: var(--secondary);
  font-family: var(--hand);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab-label { letter-spacing: .5px; }

/* pushpin base */
.pin {
  width: 26px; height: 28px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  display: block;
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.pin::after {
  content: "";
  position: absolute;
  left: 50%; top: 2px;
  transform: translateX(-50%);
  width: 14px; height: 18px;
  border-radius: 50% 50% 4px 4px;
  background: linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0));
}
.pin.red    { background: radial-gradient(circle at 30% 28%, #ff7a6a, var(--pin-red) 62%); }
.pin.blue   { background: radial-gradient(circle at 30% 28%, #7db4ff, var(--pin-blue) 62%); }
.pin.green  { background: radial-gradient(circle at 30% 28%, #7be0a6, var(--pin-green) 62%); }
.pin.yellow { background: radial-gradient(circle at 30% 28%, #ffe48a, var(--pin-yellow) 62%); }

/* inactive: flush, matte, shadowless */
.tab .pin { box-shadow: none; filter: saturate(.7) brightness(.92); transform: none; }

/* active: metallic sheen + soft drop shadow */
.tab.active .pin {
  transform: translateY(-4px) rotate(-4deg);
  filter: saturate(1.15) brightness(1.08);
  box-shadow: 0 6px 9px var(--shadow), 0 2px 3px rgba(0,0,0,.3);
}
.tab.active .tab-label { font-weight: bold; }

/* ---- Paper notice card ---- */
.card {
  background: var(--paper);
  border-radius: 4px;
  padding: 14px 12px 10px;
  margin-bottom: 12px;
  position: relative;
  box-shadow: 0 3px 6px var(--shadow);
  transform: rotate(var(--tilt, 0deg));
  border: 1px solid #efe6d2;
  cursor: pointer;
}
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-title { font-family: var(--serif); font-weight: bold; font-size: 15px; margin: 2px 0 4px; }
.card-desc {
  font-size: 12.5px; color: #6b5b49; margin: 2px 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.chip {
  font-size: 10.5px; padding: 2px 8px; border-radius: 10px;
  font-weight: bold; letter-spacing: .4px; border: 1px solid rgba(0,0,0,.1);
}
.chip.lost { background:#fdeaea; color:#b0352a; }
.chip.found{ background:#eaf4fd; color:#2a66a6; }
.chip.other{ background:#fbf4dd; color:#9a7a20; }

/* -- pushpin on card -- */
.note-pin {
  width: 14px; height: 15px; border-radius: 50%; flex: 0 0 auto;
  position: relative; margin-top: -3px;
}
.note-pin::after {
  content:""; position:absolute; left:50%; top:1px; transform:translateX(-50%);
  width:8px; height:10px; border-radius:50% 50% 3px 3px;
  background: linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0));
}
.note-pin.red    { background: radial-gradient(circle at 30% 28%, #ff7a6a, var(--pin-red) 62%); box-shadow: 0 3px 4px rgba(0,0,0,.3); }
.note-pin.blue   { background: radial-gradient(circle at 30% 28%, #7db4ff, var(--pin-blue) 62%); box-shadow: 0 3px 4px rgba(0,0,0,.3); }
.note-pin.green  { background: radial-gradient(circle at 30% 28%, #7be0a6, var(--pin-green) 62%); box-shadow: 0 3px 4px rgba(0,0,0,.3); }
.note-pin.yellow { background: radial-gradient(circle at 30% 28%, #ffe48a, var(--pin-yellow) 62%); box-shadow: 0 3px 4px rgba(0,0,0,.3); }

/* ---- Espresso cup counters ---- */
.cups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.cup-wrap { text-align: center; transform: rotate(var(--tilt, 0deg)); }
.cup-saucer {
  width: 78px; height: 14px; margin: -2px auto 0;
  border-radius: 50%;
  background: linear-gradient(#fff,#f0e6d2);
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.cup-saucer b {
  font-family: var(--serif); font-size: 13px; color: var(--primary-dark);
  margin-top: -3px;
}
.cup {
  width: 62px; height: 48px;
  margin: 0 auto;
  border-radius: 6px 6px 16px 16px;
  position: relative;
  box-shadow: inset 0 -8px 10px rgba(0,0,0,.18), 0 3px 5px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
}
.cup::before { /* handle */
  content:""; position:absolute; right:-11px; top:8px;
  width: 12px; height: 18px;
  border: 4px solid var(--cupcolor, #8b5e3c); border-left: 0;
  border-radius: 0 9px 9px 0;
}
.cup.red    { --cupcolor:#d33f3f; background: linear-gradient(135deg,#e26a5f,#b5312a); }
.cup.blue   { --cupcolor:#3f7fd3; background: linear-gradient(135deg,#6aa7e8,#2f62b0); }
.cup.green  { --cupcolor:#2a9d8f; background: linear-gradient(135deg,#57c4a9,#1f8a7d); }
.cup-sleeve {
  position:absolute; left:0; right:0; top:0; bottom:0;
  border-radius: inherit;
  background: rgba(253,246,227,.9);
  border: 1px solid rgba(0,0,0,.08);
  display:flex; align-items:center; justify-content:center;
}
.cup-label {
  font-size: 10px; color: var(--primary-dark); font-weight: bold;
  writing-mode: vertical-rl; transform: rotate(180deg);
  letter-spacing: .5px;
}

/* quick add card */
.quick-add {
  background: var(--paper);
  border: 1px dashed var(--primary);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 14px;
  cursor: pointer;
  box-shadow: 0 2px 4px var(--shadow);
  transform: rotate(-.5deg);
  text-align: center;
  font-family: var(--hand); color: var(--primary);
}
.quick-add .qa-plus { font-size: 20px; }
.quick-add small { display:block; font-size: 11px; margin-top: 2px; }

/* ---- Search + chips ---- */
.searchbar {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #e2d5bd;
  border-radius: 20px;
  background: var(--paper);
  font-family: var(--hand); font-size: 14px;
  color: var(--ink);
  margin-bottom: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,.18);
  outline: none;
}
.chips { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.chip-btn {
  border: 0; border-radius: 14px; padding: 6px 14px;
  font-family: var(--hand); font-size: 12px; cursor: pointer;
  background: rgba(253,246,227,.92); color: var(--primary-dark);
  border: 1px solid rgba(0,0,0,.1);
}
.chip-btn.active { background: var(--primary); color: var(--secondary); border-color: var(--primary-dark); }

/* ---- My posts / resolved ---- */
.mycard .row-actions { display:flex; align-items:center; gap:8px; margin-top:6px; }
.mycard .row-actions .spacer { flex:1; }

/* toggle switch */
.switch { position: relative; width: 46px; height: 24px; }
.switch input { opacity: 0; width:0; height:0; }
.slider {
  position:absolute; inset:0; border-radius: 24px;
  background:#cbbfa8; transition:.2s; cursor:pointer;
}
.slider::before {
  content:""; position:absolute; width:18px; height:18px; left:3px; top:3px;
  border-radius:50%; background:#fff; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.toggle-label { font-size: 11px; color: var(--muted); }

/* delete */
.btn-del {
  border:0; background:#f7e2e0; color:#b0352a; border-radius:12px;
  padding:6px 12px; font-family:var(--hand); font-size:12px; cursor:pointer;
  border:1px solid rgba(0,0,0,.08);
}

/* settled stamp */
.stamp {
  position:absolute; right:8px; bottom:6px;
  font-family:var(--serif); font-weight:bold; font-size:16px;
  letter-spacing:2px; text-transform:uppercase;
  color:#b3472f; opacity:.38;
  border:3px double #b3472f; border-radius:6px;
  padding:1px 6px; transform: rotate(-12deg);
  pointer-events:none;
}
.resolved-card .card-desc { color:#a99b89; }

.empty {
  text-align:center; color: var(--secondary); font-style: italic;
  padding: 40px 0; text-shadow: 1px 1px 2px rgba(0,0,0,.3);
}

/* ---- Modal ---- */
#modal {
  position: fixed; inset:0; background: rgba(40,28,16,.55);
  display:flex; align-items:center; justify-content:center;
  z-index: 50; padding: 16px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
#modal.hidden, #detail.hidden { display:none; }
.modal-card {
  background: var(--paper); border-radius:6px; width:100%; max-width:380px;
  padding: 18px 16px 16px;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  border: 2px solid #efe6d2;
  max-height: 90vh; overflow-y:auto;
}
.modal-card h2 { margin:0 0 12px; font-family:var(--serif); color: var(--primary-dark); }
label { display:block; font-size:12px; color: var(--primary-dark); margin:10px 0 4px; font-weight:bold; }
label em { color:#b0352a; font-style:normal; }
input, textarea, select {
  width:100%; padding:10px 10px;
  border:1px solid #dccfb8; border-radius:4px;
  background:#fffef9; font-family:var(--hand); font-size:14px; color:var(--ink);
  outline:none;
}
textarea { resize:vertical; min-height:72px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(42,157,143,.2); }
.field-error { color:#b0352a; font-size:11px; margin-top:3px; font-style:italic; }
.modal-actions { display:flex; gap:8px; margin-top:16px; }
.btn {
  flex:1; border:0; border-radius:6px; padding:11px;
  font-family:var(--hand); font-size:14px; cursor:pointer;
}
.btn.primary { background: var(--accent); color:#fff; font-weight:bold; }
.btn.ghost { background:#ece2cc; color: var(--primary-dark); }

/* ---- Detail ---- */
#detail {
  position: fixed; inset:0; background: rgba(40,28,16,.55);
  z-index: 45; display:flex; align-items:center; justify-content:center; padding:16px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
#detail.hidden { display:none; }
.detail-card {
  background: var(--paper); border-radius:6px; width:100%; max-width:380px;
  padding:20px 16px 16px; box-shadow:0 10px 24px rgba(0,0,0,.35);
  border:2px solid #efe6d2; max-height:88vh; overflow-y:auto;
  position:relative;
}
.detail-title { font-family:var(--serif); font-size:18px; margin:2px 0 8px; }
.detail-desc { font-size:14px; line-height:1.5; color:#5b4b39; white-space:pre-wrap; }
.detail-meta { font-size:12px; color:var(--muted); margin-top:10px; border-top:1px dashed #ddd2bb; padding-top:8px; }
.detail-close { margin-top:14px; }
#detail-body .stamp { position:static; display:inline-block; margin-top:8px; transform:rotate(-8deg); }

/* ---- FAB ---- */
#fab {
  position: fixed; right: 16px; bottom: calc(72px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  border:0; background: var(--accent); color:#fff;
  font-size: 28px; font-weight:bold; line-height:1;
  box-shadow: 0 6px 14px rgba(0,0,0,.35);
  cursor:pointer; z-index: 30;
}
#fab:active { transform: scale(.94); }

.hidden { display:none !important; }