:root {
  --wood-dark: #4a3527;
  --wood: #6b4f3a;
  --wood-light: #8a6a4f;
  --plank: #a98a67;
  --cream: #f4e8d0;
  --cream-soft: #faf3e4;
  --paper: #fdf8ec;
  --coral: #e86a58;
  --mustard: #d9a13b;
  --teal: #3f8f83;
  --ink: #3a2d22;
  --ink-soft: #7a6a58;
  --rail-h: 92px;
  --tab-h: 76px;
}

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

html, body { height: 100%; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

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

/* ---------- Top rail: weathered wood + washers ---------- */
.top-rail {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0);
}

.rail-wood {
  height: var(--rail-h);
  background:
    repeating-linear-gradient(94deg,
      rgba(0,0,0,.10) 0 2px, transparent 2px 14px),
    linear-gradient(180deg, var(--wood-light), var(--wood) 70%, #5a4230);
  box-shadow: 0 2px 6px rgba(58,45,34,.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 6px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-tag {
  width: 26px;
  height: 22px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 4px 4px 6px 6px;
  position: relative;
  transform: rotate(-6deg);
}
.brand-tag::before {
  content: "";
  position: absolute;
  top: 3px; left: 50%;
  width: 5px; height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--wood);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.4);
}
.brand-tag::after {
  content: "";
  position: absolute;
  top: -7px; left: 50%;
  width: 10px; height: 9px;
  margin-left: -5px;
  border: 2.5px solid var(--coral);
  border-bottom-color: transparent;
  border-radius: 50% 50% 0 0;
}

.brand-name {
  color: var(--cream);
  font-size: 1.35rem;
  letter-spacing: .04em;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}

.washers {
  display: flex;
  gap: 10px;
}

.washer {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 10px, #5f6360 10px 13px, transparent 13px),
    radial-gradient(circle at 35% 30%, #cfd2cd, #9aa09a 60%, #7c827c);
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,.55),
    inset 0 -2px 4px rgba(0,0,0,.35),
    0 3px 5px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotate(3deg);
}
.washer-open { transform: rotate(3deg); }
.washer-done { transform: rotate(-4deg); }

.washer-num {
  font-size: 1.35rem;
  font-weight: bold;
  color: #3d423e;
  line-height: 1;
  font-family: 'Courier New', monospace;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.washer-label {
  font-size: .58rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #4a504c;
  margin-top: 1px;
}

/* ---------- Main board area ---------- */
.board-area {
  flex: 1;
  padding: 14px 14px calc(var(--tab-h) + env(safe-area-inset-bottom, 0) + 28px);
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(255,255,255,.5), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 88px, rgba(107,79,58,.07) 88px 90px),
    var(--cream);
}

.section-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ink-soft);
  margin: 6px 2px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--wood-light) 0 8px, transparent 8px 14px);
  opacity: .5;
  border-radius: 2px;
}
.section-label-later { margin-top: 26px; }

/* ---------- Tag cards ---------- */
.tag-queue {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tag-card {
  position: relative;
  background: var(--paper);
  border: 1px solid rgba(107,79,58,.35);
  border-radius: 8px;
  padding: 20px 14px 12px;
  box-shadow: 0 3px 7px rgba(58,45,34,.16);
  border-left: 5px solid transparent;
}

/* string from top of card up to rail */
.tag-card::before {
  content: "";
  position: absolute;
  top: -16px;
  left: 24px;
  width: 3px;
  height: 17px;
  border-radius: 2px;
  background: var(--string, var(--coral));
  transform: rotate(8deg);
}

/* binder clip */
.tag-clip {
  position: absolute;
  top: -9px;
  right: 18px;
  width: 30px;
  height: 16px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #b9bdb6, #8e948c 70%, #6f756d);
  box-shadow: 0 2px 3px rgba(0,0,0,.3), inset 0 1px 1px rgba(255,255,255,.5);
}
.tag-clip::after {
  content: "";
  position: absolute;
  top: -5px; left: 50%;
  width: 10px; height: 7px;
  margin-left: -5px;
  border: 2px solid #82887f;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}

.tag-card.status-Open    { --string: var(--coral);   border-left-color: var(--coral); }
.tag-card.status-Claimed { --string: var(--mustard); border-left-color: var(--mustard); }
.tag-card.status-Done    { --string: var(--teal);    border-left-color: var(--teal); }

.tag-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.tag-title {
  font-size: 1.02rem;
  font-weight: bold;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.tag-kind {
  flex-shrink: 0;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cream);
  background: var(--wood);
  padding: 3px 8px;
  border-radius: 10px;
}

.tag-place {
  margin-top: 5px;
  font-size: .85rem;
  color: var(--ink-soft);
  font-style: italic;
  overflow-wrap: anywhere;
}

.tag-status-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.string-dot {
  display: inline-block;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--string, var(--coral));
  margin-right: 6px;
  vertical-align: -2px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.25);
}
.string-text {
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

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

.chip-btn {
  font-family: inherit;
  font-size: .82rem;
  padding: 8px 13px;
  min-height: 40px;
  border-radius: 8px;
  border: 1.5px solid var(--wood);
  background: var(--cream-soft);
  color: var(--wood);
  font-weight: bold;
  cursor: pointer;
}
.chip-btn:active { transform: scale(.96); }
.chip-btn.accent { border-color: var(--coral); color: var(--coral); }
.chip-btn.danger { border-color: var(--coral); color: #b3402f; }

.tag-card.clickable { cursor: pointer; }
.tag-card.clickable:active { transform: translateY(1px); }

/* ---------- Empty states ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty-title {
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--ink);
  margin-bottom: 6px;
}
.empty-sub { font-size: .9rem; margin-bottom: 16px; }

/* ---------- Search ---------- */
.search-wrap { margin: 4px 0 12px; }
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 14px 16px;
  min-height: 50px;
  border-radius: 10px;
  border: 2px solid var(--wood-light);
  background: var(--paper);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.search-input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(232,106,88,.2);
}

.browse-meta {
  font-size: .8rem;
  color: var(--ink-soft);
  margin: 0 2px 10px;
}

/* ---------- Form ---------- */
.tag-form {
  background: var(--paper);
  border: 1px solid rgba(107,79,58,.35);
  border-radius: 10px;
  padding: 18px 16px 16px;
  box-shadow: 0 3px 7px rgba(58,45,34,.14);
  position: relative;
}
.tag-form::before {
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  width: 34px; height: 18px;
  margin-left: -17px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #b9bdb6, #8e948c 70%);
  box-shadow: 0 2px 3px rgba(0,0,0,.3);
}

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: bold;
}
.field input,
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 13px 14px;
  min-height: 48px;
  border-radius: 8px;
  border: 2px solid var(--wood-light);
  background: var(--cream-soft);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--wood) 50%),
                    linear-gradient(135deg, var(--wood) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(232,106,88,.18);
}
.field input.invalid,
.field select.invalid { border-color: var(--coral); background: #fdf1ef; }

.field-err {
  color: #b3402f;
  font-size: .8rem;
  margin-top: 5px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  flex: 1;
}
.btn:active { transform: translateY(1px); }
.btn-accent {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 3px 6px rgba(232,106,88,.4);
}
.btn-plain {
  background: transparent;
  border: 2px solid var(--wood);
  color: var(--wood);
}
.btn-small { flex: 0 0 auto; font-size: .85rem; min-height: 42px; padding: 8px 14px; }
.btn-danger { border-color: #b3402f; color: #b3402f; }

/* ---------- Done view: about card ---------- */
.about-card {
  margin-top: 30px;
  background: var(--cream-soft);
  border: 2px dashed var(--wood-light);
  border-radius: 10px;
  padding: 16px;
}
.about-card h3 {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--wood);
  margin-bottom: 8px;
}
.about-card p {
  font-size: .88rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.about-note { font-style: italic; }
.about-row { display: flex; gap: 10px; margin-top: 12px; }
.about-msg {
  margin-top: 10px;
  font-size: .85rem;
  color: var(--teal);
  font-weight: bold;
}

/* ---------- Bottom picket tab bar ---------- */
.picket-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.12) 0 2px, transparent 2px 26px),
    linear-gradient(180deg, var(--wood), var(--wood-dark));
  box-shadow: 0 -3px 8px rgba(58,45,34,.35);
  display: flex;
}

.picket {
  flex: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 10px 4px 8px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.picket-plank {
  width: 34px;
  height: 30px;
  border-radius: 6px 6px 3px 3px;
  background:
    repeating-linear-gradient(88deg, rgba(0,0,0,.08) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, #b4946f, var(--plank) 60%, #8f7050);
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  transition: transform .15s ease, box-shadow .15s ease;
  clip-path: polygon(12% 0, 88% 0, 100% 100%, 0 100%);
}

.picket-name {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(244,232,208,.75);
  font-weight: bold;
}

.picket.active .picket-name { color: var(--cream); }

.picket.active .picket-plank {
  transform: translateY(-6px) rotate(-3deg) scaleY(1.12);
  box-shadow: 0 6px 10px rgba(0,0,0,.45);
  background:
    repeating-linear-gradient(88deg, rgba(0,0,0,.08) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, #cfaf85, var(--plank) 60%, #9a7a58);
}

.picket.active::after {
  content: "";
  position: absolute;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--coral);
  transform: translateY(-34px);
  opacity: 0;
}
.picket { position: relative; }
.picket.active::after { opacity: 1; }

/* ---------- Small screens ---------- */
@media (max-width: 360px) {
  .washer { width: 52px; height: 52px; }
  .brand-name { font-size: 1.15rem; }
}
