:root {
  --primary: #2f6b5e;
  --primary-dark: #245449;
  --secondary: #f2e7d5;
  --accent: #e26d5a;
  --cream: #fbf5e9;
  --ink: #2b2b26;
  --muted: #7a766a;
  --tape-idea: #e0b23f;
  --tape-progress: #e26d5a;
  --tape-finished: #2f6b5e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #e8e0d2;
  color: var(--ink);
  overscroll-behavior-y: none;
}

.mat {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(rgba(47,107,94,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,107,94,0.06) 1px, transparent 1px),
    #bfe3d6;
  background-size: 22px 22px, 22px 22px, auto;
  padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: calc(var(--safe-bottom) + 96px);
}

.tab-screen { display: block; padding: 8px 14px 0; }
.tab-screen[hidden] { display: none; }

.screen-inner { max-width: 520px; margin: 0 auto; }

/* ---------- Brad counters ---------- */
.brad-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 2px 4px;
}

.brad {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 3px 0 rgba(36,84,73,0.45), 0 5px 10px rgba(0,0,0,0.18), inset 0 2px 4px rgba(255,255,255,0.35);
}
.brad-active { background: radial-gradient(circle at 32% 28%, #f5d98a, #c99a34 70%); }
.brad-finished { background: radial-gradient(circle at 32% 28%, #d8a08a, #b8543f 70%); }

.brad-num {
  font-size: 30px;
  font-weight: 800;
  color: #3d2f14;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.brad-finished .brad-num { color: #3c1810; }

.brad-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(50,38,16,0.8);
}
.brad-finished .brad-label { color: rgba(60,24,16,0.85); }

/* plus-shaped paper scrap quick action */
.scrap-plus {
  margin: 16px auto 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 210px;
  height: 210px;
  background: var(--cream);
  border: none;
  cursor: pointer;
  clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.18));
  transition: transform 0.12s ease;
}
.scrap-plus:active { transform: scale(0.96); }
.plus-glyph { font-size: 64px; font-weight: 700; color: var(--primary); line-height: 1; }
.plus-note {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Section titles ---------- */
.strip-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary-dark);
  margin: 18px 2px 10px;
}

/* ---------- Recent strip ---------- */
.recent-strip { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  background: var(--cream);
  border-radius: 4px 14px 4px 14px;
  padding: 12px 14px 12px 18px;
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
  cursor: pointer;
}
.recent-item::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 6px;
  width: 6px;
  border-radius: 3px;
  background: var(--stage-color, var(--accent));
}
.recent-name { font-weight: 700; font-size: 15px; }
.recent-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.empty-note {
  background: rgba(251,245,233,0.75);
  border: 1.5px dashed rgba(47,107,94,0.45);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Projects: search + chips ---------- */
.search-box {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  border: 2px solid rgba(47,107,94,0.35);
  border-radius: 12px;
  background: var(--cream);
  color: var(--ink);
  outline: none;
  margin-bottom: 12px;
}
.search-box:focus { border-color: var(--primary); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 9px 16px;
  min-height: 40px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid rgba(47,107,94,0.4);
  border-radius: 999px;
  background: var(--cream);
  color: var(--primary-dark);
  cursor: pointer;
}
.chip-on { background: var(--primary); border-color: var(--primary); color: var(--cream); }

/* ---------- Torn paper project cards ---------- */
.card-list { display: flex; flex-direction: column; gap: 12px; }

.paper-card {
  position: relative;
  background: var(--cream);
  padding: 16px 16px 14px 22px;
  cursor: pointer;
  box-shadow: 0 3px 7px rgba(0,0,0,0.14);
  border-radius: 3px;
  clip-path: polygon(0 0, 88% 0, 90% 3%, 86% 7%, 91% 12%, 87% 18%, 92% 24%, 88% 31%, 93% 38%, 88% 46%, 92% 54%, 87% 62%, 92% 70%, 88% 78%, 92% 86%, 87% 93%, 91% 97%, 87% 100%, 0 100%);
}
.paper-card::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 46px;
  height: 10px;
  background: var(--stage-color, var(--accent));
  transform: rotate(-3deg);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.card-name { font-weight: 800; font-size: 17px; margin-top: 10px; }
.card-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.type-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(47,107,94,0.12);
  color: var(--primary-dark);
  border-radius: 4px;
  padding: 3px 8px;
}
.stage-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  border-radius: 4px;
  padding: 3px 8px;
  background: var(--stage-color, var(--accent));
}
.card-step { margin-top: 8px; font-size: 14px; color: var(--muted); }
.card-step strong { color: var(--primary-dark); font-weight: 700; }

.card-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn-edit, .btn-del {
  flex: 1;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-edit { background: var(--primary); color: var(--cream); }
.btn-del { background: rgba(226,109,90,0.16); color: #a2402f; }

/* Finished rows */
.finished-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--cream);
  border-radius: 4px 12px 12px 4px;
  padding: 14px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
}
.finished-row::before {
  content: "";
  width: 6px;
  align-self: stretch;
  border-radius: 3px;
  background: var(--tape-finished);
}
.finished-info { flex: 1; min-width: 0; }
.finished-name { font-weight: 700; font-size: 15px; }
.finished-type { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }
.btn-reopen {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
}
.btn-reopen:active { background: var(--accent); color: #fff; }

/* ---------- Capture form ---------- */
.form-heading {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 8px 2px 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-dark);
  margin: 16px 2px 6px;
}
.req { color: var(--accent); }

.field {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  border: 2px solid rgba(47,107,94,0.35);
  border-radius: 10px;
  background: var(--cream);
  color: var(--ink);
  outline: none;
}
.field:focus { border-color: var(--primary); }

.field-error {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #a2402f;
}
.field.bad, .seg.bad { border-color: var(--accent); }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
  min-height: 42px;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid rgba(47,107,94,0.4);
  border-radius: 999px;
  background: var(--cream);
  color: var(--primary-dark);
  cursor: pointer;
}
.seg-btn.seg-on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--cream);
}
.seg-btn.seg-finished.seg-on { background: var(--tape-finished); border-color: var(--tape-finished); }
.seg-btn.seg-progress.seg-on, .seg-btn.seg-paint.seg-on { background: var(--accent); border-color: var(--accent); }

.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn {
  flex: 1;
  min-height: 50px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.btn-save { background: var(--primary); color: var(--cream); box-shadow: 0 3px 0 var(--primary-dark); }
.btn-save:active { transform: translateY(2px); box-shadow: none; }
.btn-cancel { background: transparent; color: var(--primary-dark); border: 2px solid rgba(47,107,94,0.5); }

/* ---------- Washi tape tab bar ---------- */
.washi-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 4px;
  padding: 10px 8px calc(var(--safe-bottom) + 10px);
  background: linear-gradient(rgba(47,107,94,0.10) 1px, transparent 1px), #a9d8c6;
  background-size: 22px 22px, auto;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  z-index: 10;
}

.washi {
  flex: 1;
  position: relative;
  min-height: 58px;
  border: none;
  cursor: pointer;
  background: rgba(242,231,213,0.88);
  transform: skewY(-2deg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.washi::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.45) 0 6px, transparent 6px 12px);
}
.w-desk.washi-on { background: var(--accent); }
.w-projects.washi-on { background: var(--tape-idea); }
.w-capture.washi-on { background: var(--primary); }
.w-finished.washi-on { background: #7fae9e; }

.washi-on {
  transform: skewY(-6deg) translateY(-4px) rotate(-1.5deg);
  box-shadow: 0 6px 10px rgba(0,0,0,0.28);
}

.washi-word {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(43,43,38,0.65);
}
.washi-on .washi-word { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
