:root {
  --accent: #ff6600;
  --accent-dark: #e65c00;
  --primary: #4f5b6b;
  --matte: #4f5b6b;
  --fabric: #d4d4d4;
  --fabric-dark: #c6c6c6;
  --paper: #fbf6ea;
  --paper-edge: #e8e0cd;
  --ink: #2a2a2a;
  --orange: #ff6600;
  --yellowed: #e7d3a0;
  --red: #e23b3b;
  --shadow: 0 4px 10px rgba(0,0,0,0.18);
  --radius: 16px;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--fabric);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* ---- Sun visor fabric texture ---- */
.app {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), transparent 40%),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.05) 0 2px, transparent 2px 4px),
    var(--fabric);
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(84px + env(safe-area-inset-bottom));
  overflow: hidden;
}

/* ---- Visor clip silhouette ---- */
.clip {
  position: absolute;
  top: 12px;
  left: 8px;
  width: 52px;
  height: 110px;
  background: linear-gradient(135deg, #b8b8b8, #8f8f8f);
  border-radius: 6px 12px 12px 6px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.25), var(--shadow);
  opacity: 0.55;
  pointer-events: none;
}
.clip::after {
  content: "";
  position: absolute;
  top: 18px; left: 6px;
  width: 40px; height: 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #c8c8c8);
  box-shadow: 0 2px 3px rgba(0,0,0,0.2);
}

/* ---- Views ---- */
.views {
  position: relative;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.view { display: none; animation: fade 0.2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { padding: 6px 4px 4px; }
.app-title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary);
}
.tagline { margin: 2px 0 14px; font-size: 13px; color: #6b7480; }

/* ---- Dashboard counters ---- */
.counters {
  display: flex;
  gap: 16px;
  padding: 8px 4px;
}
.sticker-counter {
  position: relative;
  flex: 1;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 5px solid var(--orange);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.5), transparent 55%),
    #fff7ea;
  box-shadow: var(--shadow), inset 0 0 12px rgba(255,102,0,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: rotate(-2deg);
  transition: transform 0.15s ease;
  overflow: hidden;
}
.sticker-counter.overdue {
  transform: rotate(2deg);
  border-color: #c9a23c;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.5), transparent 55%),
    #f4e9c9;
  box-shadow: var(--shadow), inset 0 0 14px rgba(201,162,60,0.25);
}
.sticker-counter:active { transform: scale(0.97); }
.sticker-counter .num {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  color: var(--orange);
}
.sticker-counter.overdue .num { color: #a67f1e; }
.sticker-counter .silkscreen {
  position: absolute;
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #a35c12;
  text-transform: uppercase;
}
.sticker-counter.overdue .silkscreen { color: #8a6a1a; }
.sticker-counter .oil {
  width: 16px; height: 20px;
  background: var(--orange);
  border-radius: 50% 50% 46% 46% / 58% 58% 40% 40%;
  margin-bottom: 6px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.15);
}
.sticker-counter.overdue .oil { background: #c9a23c; }

/* ---- Upcoming list ---- */
.dash-section { margin-top: 8px; }
.dash-heading {
  margin: 12px 4px 8px;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #7a7a7a;
}
.upcoming-list { display: flex; flex-direction: column; gap: 12px; padding: 0 2px; }

/* ---- Generic sticker chip ---- */
.sticker-chip {
  position: relative;
  border-radius: 26px;
  border: 2px solid var(--orange);
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.55), transparent 50%),
    rgba(255,255,255,0.82);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  transform: rotate(var(--r, -1deg));
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s ease;
}
.sticker-chip:active { transform: rotate(var(--r, -1deg)) scale(0.99); }
.sticker-chip.overdue {
  border-color: #c9a23c;
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.5), transparent 50%),
    rgba(246,236,205,0.85);
}
.sticker-chip .st-title {
  font-family: "Comic Sans MS", "Segoe Print", cursive, sans-serif;
  font-size: 20px;
  line-height: 1.1;
  color: #111;
  margin: 0;
}
.sticker-chip .st-mileage { font-weight: 800; font-size: 15px; color: var(--accent-dark); }
.sticker-chip.overdue .st-mileage { color: #9a741c; }
.sticker-chip .st-date {
  font-size: 11px;
  letter-spacing: 1px;
  color: #7a7a7a;
  font-variant-numeric: tabular-nums;
}

/* Swipe row */
.swipe-row { position: relative; overflow: hidden; border-radius: 26px; }
.swipe-delete {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 84px;
  background: linear-gradient(135deg, #e23b3b, #b82a2a);
  border: none;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 3;
  pointer-events: none;
}
.swipe-row.open .swipe-delete { transform: translateX(0); pointer-events: auto; }
.swipe-row .sticker-chip { transition: transform 0.25s ease; }
.swipe-row.open .sticker-chip { transform: translateX(-74px); }
.tear { font-size: 22px; line-height: 1; }
.swipe-backdrop {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.swipe-row.open .swipe-backdrop { pointer-events: auto; }

/* ---- Search ---- */
.search-wrap { padding: 4px 4px 10px; }
.search {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #bbb;
  border-radius: 30px;
  font-size: 16px;
  background: rgba(255,255,255,0.9);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.08);
}

/* ---- All list ---- */
.stickers-list { display: flex; flex-direction: column; gap: 12px; padding: 0 2px; }

.empty { text-align: center; color: #8a8a8a; padding: 40px 10px; }
.empty p { margin: 0; font-size: 15px; }

/* ---- Add form ---- */
.form { padding: 6px 4px 20px; }
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #6b7480;
  margin-bottom: 6px;
  font-weight: 700;
}
.field input, .field textarea {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  border: 2px solid #bbb;
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  font-family: inherit;
  color: var(--ink);
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,102,0,0.18);
}
.err { color: var(--red); font-size: 12px; margin-top: 4px; display: block; min-height: 14px; }
.field.invalid input, .field.invalid textarea { border-color: var(--red); }

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 800;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: var(--shadow);
}
.btn.primary { background: linear-gradient(180deg, #ff7a22, var(--accent)); color: #fff; }
.btn.primary:active { background: var(--accent-dark); }
.btn.ghost { background: #fff; color: var(--primary); border: 2px solid var(--matte); box-shadow: none; }

/* ---- Completed folder ---- */
.folder {
  position: relative;
  margin: 4px;
  padding: 26px 16px 20px;
  background: linear-gradient(180deg, #dfd3bb, #d3c5a8);
  border-radius: 6px 16px 16px 6px;
  min-height: 200px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.15), var(--shadow);
}
.folder-corner {
  position: absolute;
  top: 0; left: 0;
  width: 90px; height: 30px;
  background: #d4c7a8;
  border-bottom-right-radius: 14px;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1);
}
.peeled-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 6px 2px;
}

/* Peeled sticker outline with torn edge */
.peel {
  position: relative;
  border: 2px dashed #a9a9a9;
  border-radius: 14px;
  background: rgba(255,255,255,0.35);
  padding: 12px 10px;
  min-height: 96px;
  cursor: pointer;
  transform: rotate(var(--r, -1deg));
  transition: transform 0.12s ease;
}
.peel:active { transform: rotate(var(--r, -1deg)) scale(0.98); }
.peel .p-title {
  font-family: "Comic Sans MS", "Segoe Print", cursive, sans-serif;
  font-size: 15px;
  margin: 0 0 6px;
  color: #555;
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,0.35);
}
.peel .p-date { font-size: 11px; color: #7a7a7a; }
.peel::before, .peel::after {
  content: "";
  position: absolute;
  height: 6px;
  background: #bdb09a;
  clip-path: polygon(0 100%, 12% 0, 26% 100%, 42% 0, 100% 30%);
}
.peel::before { top: -3px; left: -4px; width: 40%; }
.peel::after { bottom: -3px; right: -4px; width: 50%; }

/* ---- Bottom tab bar ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(240,240,240,0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  z-index: 10;
}
.tab {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 4px 6px;
  min-width: 64px;
  -webkit-tap-highlight-color: transparent;
}
.knob {
  width: 26px; height: 30px;
  border-radius: 50% 50% 30% 30% / 55% 55% 40% 40%;
  background: linear-gradient(180deg, #6b7786, var(--matte));
  box-shadow: 0 3px 5px rgba(0,0,0,0.25);
  transition: all 0.2s ease;
}
.tab-label { font-size: 10px; color: #7a7a7a; font-weight: 600; }
.tab.active .knob {
  background: radial-gradient(circle at 32% 28%, #ffa24d, var(--accent) 60%);
  box-shadow: 0 4px 8px rgba(255,102,0,0.5), inset 0 1px 1px rgba(255,255,255,0.6);
  transform: translateY(-2px);
}
.tab.active .tab-label { color: var(--accent); }
.plus-knob { position: relative; }
.plus-knob::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

/* ---- FAB ---- */
.fab {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  right: 20px;
  width: 62px; height: 62px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 32% 28%, #ffa24d, var(--accent) 62%);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(255,102,0,0.5);
  cursor: pointer;
  z-index: 9;
}
.fab:active { transform: scale(0.95); }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  max-height: 80vh;
  overflow-y: auto;
}
.modal-card h2 { margin: 0 0 8px; font-family: "Comic Sans MS", cursive; }
.modal-card .row { margin-bottom: 8px; font-size: 15px; }
.modal-card .row b { color: #8a8a8a; font-weight: 600; }
.modal-card .done-btn {
  margin-top: 14px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(180deg, #7a8795, var(--primary));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.modal-card .close-btn {
  margin-top: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 30px;
  background: #eee;
  color: #555;
  font-size: 15px;
  cursor: pointer;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,0.92);
  color: #fff;
  padding: 12px 18px;
  border-radius: 30px;
  font-size: 14px;
  z-index: 30;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 620px) {
  .app { max-width: 620px; margin: 0 auto; box-shadow: 0 0 30px rgba(0,0,0,0.2); }
}