/* Tokens first. The shell's slot is the one that must survive every redesign:
   inside an older Second Draft shell a 48px round button floats in the
   bottom-right corner, 16px in from each edge, above everything. This app draws
   its own note trigger instead, so second-draft-note.css sets --shell-slot to
   0 and puts it back only inside such a shell. Keep clear of the corner with
   var(--shell-slot), never a fixed 80px, and the space is there exactly when
   the button is. */
:root {
  --shell-switcher-size: 48px;
  --shell-switcher-inset: 16px;
  --shell-switcher-gap: 16px;
  --shell-slot: 80px; /* inset + size + gap: the corner the shell owns */

  /* Playful dinner-planning palette (from the chosen look). */
  --bg: #EFF2F7;
  --paper: #EFF2F7;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --ink: #20274A;
  --navy: #20274A;
  --quiet: #59617F;
  --line: #DFE4F0;
  --shadow: #D8E0F0;
  --blue: #2A5BD7;
  --blue-deep: #17367F;
  --blue-tint: #DCE6FB;
  --pink: #D6246E;
  --pink-deep: #B01257;
  --pink-tint: #F9D3E3;
  --yellow: #FFD23F;
  --yellow-tint: #FFF0C4;
  --mint: #3FA97C;
  --mint-tint: #BDEBD6;
  --accent: #D6246E;
  --display: 'Baloo 2', 'Trebuchet MS', sans-serif;
  --font: 'Nunito', 'Segoe UI', sans-serif;
  --body: 'Nunito', 'Segoe UI', sans-serif;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 28px;
  --r-pill: 999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 600 16px/1.55 var(--font); }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: var(--r-sm); }

/* The shell gives the page the whole window, behind the clock at the top and
   the gesture bar at the bottom: the background is ours to cover, the content
   ours to keep clear of both. */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px calc(max(var(--shell-safe-bottom, 0px), env(safe-area-inset-bottom, 0px)) + var(--shell-slot));
  padding-right: calc(20px + max(var(--shell-safe-right, 0px), env(safe-area-inset-right, 0px)));
  padding-left: calc(20px + max(var(--shell-safe-left, 0px), env(safe-area-inset-left, 0px)));
}
.layout { padding-bottom: 24px; }

/* Wide window: a real layout, not a phone strip. Content grows, search and
   results sit side by side. */
@media (min-width: 900px) {
  .page { max-width: 1080px; }
  .layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 28px; align-items: start; }
  .layout .plan { position: sticky; top: 110px; }
  .results-col { min-width: 0; }
}

/* The app's bar: the width of the window, in the flow of the page. */
.top-bar {
  position: sticky; top: 0; z-index: 1; background: var(--bg);
  display: flex; align-items: center; gap: 12px;
  margin: 0; padding-bottom: 12px;
  padding-top: calc(18px + max(var(--shell-safe-top, 0px), env(safe-area-inset-top, 0px)));
  padding-right: calc(20px + max(var(--shell-safe-right, 0px), env(safe-area-inset-right, 0px)));
  padding-left: calc(20px + max(var(--shell-safe-left, 0px), env(safe-area-inset-left, 0px)));
}
.top-bar .page-heading { flex: 1; min-width: 0; margin: 0; font: 800 26px/1.1 var(--display); letter-spacing: -.01em; }
.page-heading .dot { color: var(--pink); }
@media (min-width: 760px) {
  .top-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 600px) minmax(0, 1fr); gap: 0; }
  .top-bar .page-heading { grid-column: 2; }
  .top-bar .top-actions { grid-column: 3; justify-self: end; }
}
@media (min-width: 900px) {
  .top-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1040px) minmax(0, 1fr); }
}

/* The note trigger: the app's own control, in the app's own colours. 44px at
   least, mark keeps both shapes. second-draft-note.js fills the mark. */
.note-trigger {
  appearance: none; flex: none;
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--r-md);
  background: var(--surface); color: var(--pink); cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
}
.note-trigger:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.top-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.install-app {
  appearance: none; min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--r-pill);
  background: var(--blue-tint); color: var(--blue-deep); font: 800 14px/1 var(--body); cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
}
.install-app:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.install-app:focus-visible, .note-trigger:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.quiet { color: var(--quiet); margin: 0; }

/* Scene + search panel */
.scene { display: block; width: 100%; height: auto; margin: 4px 0 2px; }
.plan {
  background: var(--surface); border-radius: var(--r-lg); padding: 22px 20px 24px;
  box-shadow: 8px 8px 0 var(--shadow); position: relative; overflow: hidden;
  margin-top: 8px;
}
.plan::before { content: ""; position: absolute; top: -34px; right: -34px; width: 96px; height: 96px; border-radius: 50%; background: var(--yellow); opacity: .5; }
.plan > * { position: relative; }
.eyebrow { margin: 0 0 14px; font: 800 13px/1 var(--body); letter-spacing: .09em; text-transform: uppercase; color: var(--pink); }
.field { margin-bottom: 14px; }
.field label, .field .like-label { display: block; margin-bottom: 6px; font: 800 13px/1.2 var(--body); letter-spacing: .05em; text-transform: uppercase; }
.hint { margin: 5px 0 0; font-size: 13.5px; color: var(--quiet); }
input[type=text], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 16px;
  border: 2.5px solid var(--line); border-radius: 18px;
  background: var(--surface); font: 700 17px/1.3 var(--body);
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 4px var(--blue-tint); }
textarea { min-height: 64px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.row .field { margin-bottom: 0; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.stepper button {
  appearance: none; width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%;
  background: var(--blue); color: #fff; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 4px 0 var(--blue-deep); font-size: 22px; font-weight: 800;
}
.stepper button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-deep); }
.stepper .count { font: 800 24px/1 var(--display); text-align: center; }
.stepper .count small { display: block; font: 700 12px/1.2 var(--body); color: var(--quiet); letter-spacing: .04em; text-transform: uppercase; margin-top: 3px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--r-pill);
  border: 2.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 800; font-size: 14.5px;
}
.check input { width: 18px; height: 18px; accent-color: var(--pink); }
.check.on { border-color: var(--pink); background: var(--pink-tint); }
.optional-label { margin: 20px 0 10px; font: 800 13px/1 var(--body); letter-spacing: .09em; text-transform: uppercase; color: var(--quiet); }
.stickers { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 4px; }
.find {
  appearance: none; border: 0; cursor: pointer; width: 100%; margin-top: 16px;
  padding: 16px 20px; border-radius: var(--r-pill);
  background: var(--blue); color: #fff;
  font: 800 19px/1.2 var(--display); letter-spacing: .01em;
  box-shadow: 0 6px 0 var(--blue-deep);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.find:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--blue-deep); }
.find:disabled { opacity: .6; cursor: progress; }
.demo-note { background: var(--yellow-tint); border-radius: var(--r-md); padding: 10px 14px; margin: 14px 0 0; font-size: 13.5px; }
.key-box { background: var(--surface); border: 2.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin: 12px 0 0; }
.key-box.is-saved { border-color: var(--mint); }
.key-label { display: block; margin-bottom: 6px; font: 800 13px/1.2 var(--body); letter-spacing: .05em; text-transform: uppercase; }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row input { flex: 1; min-width: 0; min-height: 44px; padding: 10px 14px; font-size: 15px; }
.key-row .btn { flex: none; min-height: 44px; }
.key-line { margin: 0; font-size: 14.5px; }
.key-hint { margin: 6px 0 0; font-size: 13px; color: var(--quiet); }
.key-box.is-saved .btn { margin-top: 8px; }
.offline-note { background: var(--blue-tint); border-radius: var(--r-md); padding: 10px 14px; margin: 14px 0 0; font-size: 13.5px; color: var(--blue-deep); }

/* Results */
.results-head { margin: 30px 0 6px; }
.results-head h2 { margin: 0; font: 800 32px/1.05 var(--display); letter-spacing: -.01em; }
.squiggle { display: block; margin: 4px 0; }
.progress { margin: 8px 0; font-weight: 800; color: var(--blue-deep); }
.match { background: var(--surface); border-radius: 26px; padding: 20px 18px; margin: 20px 0; }
.match.is-hero { box-shadow: 8px 8px 0 var(--pink-tint); }
.match.is-next { box-shadow: 7px 7px 0 var(--blue-tint); }
.match.is-flagged { box-shadow: 7px 7px 0 var(--yellow-tint); border: 3px dashed var(--yellow); }
.match-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 6px 13px; border-radius: var(--r-pill); font: 800 12.5px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; transform: rotate(-2deg); }
.badge-yellow { background: var(--yellow); }
.badge-mint { background: var(--mint-tint); }
.badge-pink { background: var(--pink-tint); }
.name { margin: 6px 0 2px; font: 800 26px/1.1 var(--display); width: 100%; }
.is-next .name, .is-flagged .name { font-size: 21px; }
.meta { margin: 0; font-size: 14.5px; color: var(--quiet); }
.why { background: var(--mint-tint); border-radius: 18px; padding: 12px 14px; margin: 14px 0 4px; }
.why p { margin: 0; }
.label { font: 800 12px/1.2 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--navy); margin: 0 0 4px; }
.why-text { font-size: 14.5px; }
.dishes { margin: 14px 0 4px; }
.dishes ul { list-style: none; margin: 8px 0 0; padding: 0; }
.dishes li { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 2px dotted var(--line); font-size: 15px; }
.dishes li:last-child { border-bottom: 0; }
.dishes .price { margin-left: auto; font: 800 15px/1.2 var(--display); white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: var(--r-pill); font: 800 13.5px/1.2 var(--display); }
.tag-yellow { background: var(--yellow); }
.tag-mint { background: var(--mint-tint); }
.tag-blue { background: var(--blue-tint); color: var(--blue-deep); }
.book { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-pill); text-decoration: none; border: 0; cursor: pointer;
  font: 800 15px/1.2 var(--display);
  background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-deep);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-deep); }
.btn.ghost { background: var(--surface); color: var(--blue-deep); box-shadow: 0 4px 0 var(--line); border: 2.5px solid var(--blue-tint); }
.btn.small { padding: 8px 14px; font-size: 13.5px; }
.link-plain { font: 800 15px/1.2 var(--display); align-self: center; }
.menu-date { font-size: 13px; color: var(--quiet); margin: 10px 0 0; }
.warn { display: flex; gap: 12px; align-items: flex-start; background: var(--yellow-tint); border-radius: 18px; padding: 13px 14px; margin: 14px 0 4px; }
.warn p { margin: 0; font-size: 14.5px; }
.warn .label { color: var(--pink-deep); }
.dup { background: var(--surface); border: 2.5px solid var(--blue-tint); border-radius: 18px; padding: 14px 16px; margin: 16px 0; }
.dup h3 { margin: 0 0 6px; font: 800 18px/1.2 var(--display); }
.dup .row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.recents { margin: 30px 0 0; }
.recents h2 { font: 800 24px/1.1 var(--display); margin: 0 0 8px; }
.recents ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.recents li button {
  width: 100%; text-align: left; background: var(--surface); border: 2.5px solid var(--line);
  border-radius: 18px; padding: 12px 14px; cursor: pointer;
}
.recents li button:active { border-color: var(--blue); }
.add-link { background: var(--surface); border-radius: 18px; padding: 16px; margin: 26px 0 0; box-shadow: 5px 5px 0 var(--shadow); }
.add-link h2 { font: 800 20px/1.2 var(--display); margin: 0 0 6px; }
.add-link form { display: grid; gap: 10px; }
.foot { margin: 30px 4px 0; text-align: center; font-size: 13.5px; color: var(--quiet); display: grid; justify-items: center; gap: 8px; }

/* Messages that are not the page: keep out of the shell's corner. */
#toast { position: fixed; left: 16px; right: var(--shell-slot); bottom: calc(env(safe-area-inset-bottom, 0px) + var(--shell-switcher-inset)); pointer-events: none; z-index: 5; }
#toast:empty { display: none; }
#toast > * { background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 16px; }
