:root {
  --cork: #8a5a33;
  --cork-light: #a06b3f;
  --cork-dark: #6e4526;
  --ink: #2b2118;
  --paper: #fdfaf1;
  --card: #ffffff;
  --accent: #d64545;
  --primary: #5c4033;
  --secondary: #f5ecd7;
  --yellow: #f7d94c;
  --shadow: rgba(40, 25, 12, 0.25);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Avenir Next", Avenir, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--cork);
  overflow: hidden;
}

#app {
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* Corkboard background with faint pushpin holes */
.corkboard {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 24%, rgba(20, 10, 0, 0.12) 2px, transparent 3px),
    radial-gradient(circle at 72% 18%, rgba(20, 10, 0, 0.12) 2px, transparent 3px),
    radial-gradient(circle at 44% 68%, rgba(20, 10, 0, 0.10) 2px, transparent 3px),
    radial-gradient(circle at 88% 56%, rgba(20, 10, 0, 0.12) 2px, transparent 3px),
    radial-gradient(circle at 8% 82%, rgba(20, 10, 0, 0.10) 2px, transparent 3px),
    radial-gradient(circle at 60% 34%, rgba(20, 10, 0, 0.10) 2px, transparent 3px),
    linear-gradient(120deg, rgba(0,0,0,0.06), transparent 40%),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.04) 0, rgba(0,0,0,0.04) 1px, transparent 1px, transparent 7px);
  background-color: var(--cork);
}

.scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 16px 14px calc(92px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

.section {
  display: none;
}
.section.active {
  display: block;
}

.section-title {
  font-family: "Courier New", "Courier", monospace;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--paper);
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
  margin-bottom: 10px;
  font-size: 20px;
}

/* ---------- Sticky note counters ---------- */
.counters {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sticky {
  position: relative;
  width: 47%;
  background: var(--yellow);
  padding: 16px 12px 18px;
  box-shadow: 0 3px 6px var(--shadow);
  transform: rotate(-2deg);
}
.sticky:nth-child(2) {
  transform: rotate(2deg);
}
.sticky::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-top: 18px solid var(--cork-dark);
  border-left: 18px solid transparent;
  opacity: 0.6;
}
.sticky .pin {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f4a0a0, #c22d2d 65%, #8f1d1d);
  box-shadow: 0 2px 3px var(--shadow);
}
.sticky .label {
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  font-size: 12px;
  color: rgba(43, 33, 24, 0.7);
  text-align: center;
}
.sticky .value {
  font-family: "Marker Felt", "Permanent Marker", "Comic Sans MS", cursive;
  font-weight: 900;
  font-size: 42px;
  text-align: center;
  color: #3a2a15;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.4);
}

/* Quick add button between counters */
.quick-add {
  flex: 0 0 auto;
  align-self: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(180deg, #e66a6a, var(--accent));
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 3px 6px var(--shadow), inset 0 -2px 3px rgba(0,0,0,0.2);
  cursor: pointer;
  line-height: 1;
}
.quick-add:active {
  transform: translateY(1px);
  box-shadow: 0 1px 3px var(--shadow);
}

/* ---------- Legal pad ---------- */
.pad-wrap {
  position: relative;
  margin-top: 14px;
}
.pad {
  position: relative;
  background: var(--paper);
  transform: rotate(-1deg);
  border-radius: 4px 4px 10px 10px;
  box-shadow: 0 6px 12px var(--shadow);
  overflow: hidden;
}
.pad::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0, transparent 25px, rgba(120,150,210,0.35) 25px, rgba(120,150,210,0.35) 26px);
}
.pad::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  height: 22px;
  background: linear-gradient(180deg, transparent, var(--paper) 60%);
  clip-path: polygon(0 60%, 6% 45%, 12% 58%, 19% 40%, 26% 60%, 33% 44%, 40% 62%, 48% 42%, 55% 60%, 62% 45%, 70% 62%, 78% 42%, 86% 58%, 93% 45%, 100% 58%, 100% 100%, 0 100%);
}
.pad .bulldog {
  position: absolute;
  top: -12px;
  left: 22%;
  width: 56px;
  height: 34px;
  background: linear-gradient(180deg, #c8ccd0, #9aa0a6 60%, #73797f);
  border-radius: 14px 14px 10px 10px;
  box-shadow: 0 3px 4px var(--shadow);
  z-index: 2;
}
.pad .bulldog::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 28px solid transparent;
  border-right: 28px solid transparent;
  border-bottom: 16px solid #9aa0a6;
}
.pad .redline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 40px;
  width: 2px;
  background: rgba(214, 69, 69, 0.45);
}
.pad-inner {
  position: relative;
  padding: 28px 16px 26px 54px;
}
.pad .pad-heading {
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  color: var(--primary);
  font-size: 15px;
  margin-bottom: 6px;
}

/* Recent projects list */
.recent-list {
  list-style: none;
}
.recent-item {
  position: relative;
  padding: 6px 0;
  font-size: 14px;
  color: var(--ink);
}
.recent-item .r-client {
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  color: var(--primary);
  font-size: 15px;
}
.recent-item .r-title {
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 13px;
}
.stamp {
  display: inline-block;
  margin-left: 6px;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b03a3a;
  border: 1.5px solid #b03a3a;
  border-radius: 3px;
  padding: 1px 4px;
  transform: rotate(-3deg);
  opacity: 0.85;
}
.stamp.due {
  border-color: #b03a3a;
  color: #b03a3a;
}
.stamp.overdue {
  border-color: #d64545;
  color: #d64545;
  background: rgba(214,69,69,0.08);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 26px 10px 10px;
}
.empty svg {
  width: 160px;
  height: auto;
  opacity: 0.5;
}
.empty p {
  margin-top: 8px;
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  color: rgba(43,33,24,0.6);
}

/* ---------- Search bar ---------- */
.searchbar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.searchbar input {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 15px;
  background: var(--paper);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.15);
  font-family: inherit;
  color: var(--ink);
}
.searchbar input::placeholder {
  color: rgba(92,64,51,0.5);
  font-style: italic;
}

/* ---------- Project cards ---------- */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  position: relative;
  background: var(--card);
  border-radius: 5px;
  box-shadow: 0 3px 8px var(--shadow);
  padding: 18px 34px 16px 16px;
  cursor: pointer;
}
.card::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 14px;
  background: linear-gradient(180deg, #9aa0a6, #6b7177);
  border-radius: 5px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}
.card::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 8px;
  background: #d8dbe0;
  border-radius: 2px;
}
.card .c-title {
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 2px;
}
.card .c-client {
  font-family: "Comic Sans MS", "Segoe Print", cursive;
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 8px;
}
.card .c-date {
  display: inline-block;
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
  color: #8a3b3b;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 2px solid #8a3b3b;
  border-radius: 4px;
  padding: 3px 7px;
  transform: rotate(-2deg);
  background: rgba(245,236,215,0.6);
}
.card .c-done {
  display: inline-block;
  margin-left: 6px;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 11px;
  color: rgba(76,120,60,0.9);
  border: 1.5px solid rgba(76,120,60,0.8);
  border-radius: 3px;
  padding: 2px 5px;
  transform: rotate(2deg);
  opacity: 0.8;
}

/* Paperclip */
.clip {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 14px;
  height: 40px;
  border: 3px solid var(--clip-color, #f7d94c);
  border-radius: 7px;
  transform: rotate(6deg);
}
.clip::before {
  content: "";
  position: absolute;
  top: 4px;
  left: -3px;
  width: 3px;
  height: 30px;
  background: transparent;
  border-left: 3px solid var(--clip-color, #f7d94c);
  border-right: 3px solid var(--clip-color, #f7d94c);
  border-radius: 6px;
}
.clip.red { --clip-color: #d64545; }
.clip.yellow { --clip-color: #f7d94c; }
.clip.green { --clip-color: #4cac56; }

/* ---------- Bottom tab bar / ruler ---------- */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ruler {
  position: relative;
  background: linear-gradient(180deg, #e7c48a, #caa25f 70%, #b08a4c);
  height: 54px;
  box-shadow: 0 -3px 8px rgba(0,0,0,0.35);
  border-top: 2px solid rgba(255,255,255,0.4);
}
.ruler::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, transparent 24px, rgba(60,40,10,0.35) 24px, rgba(60,40,10,0.35) 25px);
}
.tabs {
  position: relative;
  display: flex;
  height: 100%;
  z-index: 2;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 4px;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 10px;
  color: #3a2412;
}
.tab:active {
  transform: scale(0.97);
}

/* Pushpin */
.pushpin {
  position: relative;
  width: 16px;
  height: 26px;
  margin-bottom: 2px;
}
.pushpin .head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 2px 3px rgba(0,0,0,0.3), inset 0 -2px 2px rgba(0,0,0,0.2), inset 0 2px 2px rgba(255,255,255,0.4);
  z-index: 2;
}
.pushpin .shaft {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 10px;
  background: linear-gradient(180deg, #e8e8e8, #b0b0b0);
  border-radius: 0 0 2px 2px;
}
.pushpin.red .head { background: radial-gradient(circle at 35% 30%, #f0a0a0, #d64545 60%, #8f1d1d); }
.pushpin.blue .head { background: radial-gradient(circle at 35% 30%, #9fc4e8, #3a7fc0 60%, #1e4e7a); }
.pushpin.green .head { background: radial-gradient(circle at 35% 30%, #a9dcae, #4cac56 60%, #2f7036); }
.pushpin.yellow .head { background: radial-gradient(circle at 35% 30%, #fbe98a, #f0c230 60%, #a5801a); }

/* Active tab: pin pulled halfway out */
.tab.active .pushpin {
  transform: translateY(-6px);
}
.tab.active .pushpin .shaft {
  height: 10px;
  background: linear-gradient(180deg, #f0f0f0, #c0c0c0);
}
.tab.active .pushpin .head {
  box-shadow: 0 4px 6px rgba(0,0,0,0.4), inset 0 -2px 2px rgba(0,0,0,0.2);
}
.tab.active .pushpin::after {
  content: "";
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 5px;
  background: rgba(20,10,0,0.65);
  border-radius: 50%;
  filter: blur(1px);
}
.tab.active {
  color: #1d1005;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(30, 18, 6, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px calc(14px + env(safe-area-inset-left,0px));
}
.modal {
  background: var(--paper);
  width: 100%;
  max-width: 420px;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.4);
  padding: 16px;
  transform: rotate(0.5deg);
}
.modal h3 {
  font-family: "Courier New", Courier, monospace;
  margin-bottom: 12px;
  color: var(--primary);
}
.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 4px;
}
.field input,
.field select {
  width: 100%;
  border: 2px solid #d9cfb8;
  border-radius: 5px;
  background: #fff;
  padding: 10px;
  font-size: 15px;
  color: var(--ink);
  font-family: inherit;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
}
.field .error {
  color: #b03a3a;
  font-size: 12px;
  font-family: "Courier New", Courier, monospace;
  margin-top: 3px;
  display: none;
}
.field.invalid .error {
  display: block;
}
.field.invalid input,
.field.invalid select {
  border-color: #b03a3a;
}
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.btn {
  flex: 1;
  border: none;
  border-radius: 5px;
  padding: 12px;
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 4px var(--shadow);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: linear-gradient(180deg, #e66a6a, var(--accent));
  color: #fff;
}
.btn-ghost {
  background: #efe6cf;
  color: var(--primary);
}
.btn-danger {
  background: #3a2412;
  color: #f5ecd7;
}