:root {
  --bg:        #17110d;
  --bg-soft:   #1f1712;
  --ticket:    #efe7d8;
  --ticket-2:  #e7ddc9;
  --ink:       #241a12;
  --ink-soft:  #6b5b48;
  --crema:     #e0a458;
  --crema-dk:  #c07f2d;
  --foam:      #f6ede0;
  --line:      #3a2c22;
  --green:     #6f8f5e;
  --danger:    #c96a5a;
  --radius:    14px;
  --shadow:    0 18px 40px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #2a1e16 0%, var(--bg) 55%) fixed;
  color: var(--foam);
  font-family: "Inter", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---------- Masthead ---------- */
.masthead {
  padding: 40px 24px 20px;
  border-bottom: 1px solid var(--line);
}
.masthead-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.title-block h1 {
  font-family: "Fraunces", serif;
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1;
  margin: 0;
  letter-spacing: -.01em;
  color: var(--foam);
}
.title-block h1::first-letter { color: var(--crema); }
.tagline {
  margin: 10px 0 0;
  color: #b7a68f;
  font-size: .98rem;
  max-width: 46ch;
}
.search-wrap { flex: 1 1 240px; max-width: 320px; }
#search {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--foam);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: .95rem;
  font-family: inherit;
}
#search:focus {
  outline: none;
  border-color: var(--crema);
  box-shadow: 0 0 0 3px rgba(224,164,88,.18);
}
#search::placeholder { color: #7c6b57; }

/* ---------- Board ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 120px; }
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 20px;
}

/* ---------- Ticket ---------- */
.ticket {
  --notch: #17110d;
  position: relative;
  min-width: 0;
  overflow-wrap: break-word;
  background: linear-gradient(180deg, var(--ticket) 0%, var(--ticket-2) 100%);
  color: var(--ink);
  border-radius: 4px 4px var(--radius) var(--radius);
  padding: 26px 20px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.ticket:hover { transform: translateY(-3px); box-shadow: 0 24px 44px -20px rgba(0,0,0,.75); }
.ticket:focus-visible { outline: 3px solid var(--crema); outline-offset: 2px; }

/* bord perforé du ticket */
.ticket::before {
  content: "";
  position: absolute;
  top: -6px; left: 0; right: 0;
  height: 12px;
  background-image: radial-gradient(circle at 8px 6px, var(--notch) 5px, transparent 5.5px);
  background-size: 16px 12px;
  background-position: 0 0;
}

.ticket-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1.5px dashed rgba(36,26,18,.28);
}
.ticket-emoji { font-size: 1.7rem; line-height: 1; }
.ticket-name {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.05;
}

.order { font-family: "Spline Sans Mono", monospace; font-size: .9rem; }
.order-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  color: #4a3a2b;
}
.order-line .k { color: var(--ink-soft); }
.order-line .v { font-weight: 600; text-align: right; }
.order-line .v.grand  { color: var(--crema-dk); }

.coffee-name {
  font-family: "Fraunces", serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink);
}
.coffee-name.empty-coffee { color: var(--ink-soft); font-style: italic; font-weight: 400; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-family: "Spline Sans Mono", monospace;
  font-size: .72rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(36,26,18,.08);
  color: #4a3a2b;
  border: 1px solid rgba(36,26,18,.14);
}
.tag.yes { background: rgba(111,143,94,.18); color: #3f5a30; border-color: rgba(111,143,94,.35); }
.tag.no  { color: var(--ink-soft); }

.note {
  margin-top: 12px;
  font-size: .82rem;
  color: #6b5b48;
  font-style: italic;
  border-top: 1px dashed rgba(36,26,18,.2);
  padding-top: 10px;
}

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 80px 20px; color: #9b8a74; }
.empty-big {
  font-family: "Fraunces", serif;
  font-size: 1.5rem;
  color: #cdbba2;
  margin-bottom: 6px;
}

/* ---------- Add button ---------- */
.add-btn {
  position: fixed;
  bottom: 26px; right: 26px;
  background: var(--crema);
  color: #2a1c0c;
  border: none;
  border-radius: 999px;
  padding: 15px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 12px 30px -10px rgba(224,164,88,.6);
  display: flex; align-items: center; gap: 8px;
  transition: transform .1s ease, background .15s ease;
}
.add-btn span { font-size: 1.35rem; line-height: 1; margin-top: -2px; }
.add-btn:hover { background: #ecb265; transform: translateY(-2px); }
.add-btn:active { transform: translateY(0); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,6,3,.72);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: 100%; max-width: 440px;
  max-height: 92vh; overflow-y: auto; overflow-x: hidden;
  padding: 26px;
  box-shadow: var(--shadow);
}
.modal h2 {
  font-family: "Fraunces", serif;
  font-weight: 700;
  margin: 0 0 20px;
  font-size: 1.5rem;
}

.field { margin-bottom: 16px; display: flex; flex-direction: column; }
.field label { font-size: .82rem; color: #b7a68f; margin-bottom: 7px; }
.field .muted { color: #6f6050; }
.field input[type="text"], .field input[type="search"] {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--foam);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: .95rem;
  font-family: inherit;
  width: 100%;
  min-width: 0;
}
.field input:focus {
  outline: none; border-color: var(--crema);
  box-shadow: 0 0 0 3px rgba(224,164,88,.16);
}
.field-row { flex-direction: row; gap: 12px; align-items: flex-end; min-width: 0; }
.field-row > * { min-width: 0; }
.emoji-field { flex: 0 0 78px; min-width: 0; }
.emoji-field input { text-align: center; font-size: 1.3rem; width: 100%; min-width: 0; }
.grow { flex: 1; min-width: 0; }

.segmented {
  display: flex; gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  min-width: 0;
}
.segmented button {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #b7a68f;
  padding: 9px 6px;
  border-radius: 7px;
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.segmented button.active { background: var(--crema); color: #2a1c0c; font-weight: 600; }

.toggles { gap: 10px; }
.toggle {
  flex: 1;
  min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: .95rem;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--crema); cursor: pointer; }

.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.spacer { flex: 1; }
.btn-primary, .btn-ghost, .btn-danger {
  border-radius: 10px; padding: 11px 20px;
  font-size: .95rem; font-family: inherit; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--crema); color: #2a1c0c; }
.btn-primary:hover { background: #ecb265; }
.btn-ghost { background: transparent; color: #b7a68f; border-color: var(--line); }
.btn-ghost:hover { color: var(--foam); border-color: #55463a; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(201,106,90,.4); }
.btn-danger:hover { background: rgba(201,106,90,.14); }

.hidden { display: none !important; }

@media (max-width: 520px) {
  .masthead { padding: 28px 18px 16px; }
  main { padding: 20px 16px 120px; }
  .board { gap: 14px; }
  .add-btn { bottom: 18px; right: 18px; padding: 13px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}