/* Doable. The brand's colours and type are the tokens below; everything else is built from them. */
:root {
  /* colour: the brand palette */
  --warm-white: #F7F5EE;    /* warm ivory: the app background */
  --paper: #FFFEFA;         /* paper white: cards, the card editor and other surfaces */
  --ink: #102B21;           /* evergreen ink: the wordmark, headings and task text */
  --muted: #536159;         /* muted green-grey: dates, timestamps and placeholders */
  --forest: #0B3829;        /* forest green: filled Today, Done and + buttons, secondary button outlines */
  --leaf: #358541;          /* leaf green: the logo square, and the dots on days with ta-das */
  --sage: #E4E8D2;          /* soft sage: the date pill and subtle highlights */
  --rule: #F58873;          /* coral: the thin rule along the top of a card */
  --border: #D8D2C4;        /* warm border: card edges and input outlines */
  --white: #FFFFFF;         /* the logo tick and text on filled buttons */
  --control: #7F8F86;       /* outlines of controls (tick circles): 3.4:1 on paper */
  --error: #A53F2B;         /* error messages only */
  --shadow: 0 1px 2px rgba(16, 43, 33, .06), 0 4px 12px rgba(16, 43, 33, .05);
  --shadow-lift: 0 2px 6px rgba(16, 43, 33, .08), 0 18px 40px rgba(16, 43, 33, .14);
  --r-card: 14px;           /* cards */
  --r: 14px;                /* buttons, fields */
  /* type: Lexend throughout; the wordmark keeps the logo's own lettering */
  --display: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --logo: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }
body { margin: 0; background: var(--warm-white); color: var(--ink); font: 400 14px/22px var(--text);   /* body and helper copy */
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ type roles */
.hello, .today-title, .page-title { font: 700 32px/38px var(--display); letter-spacing: -.015em; }                         /* page title */
.pick-title, .empty h2, .cal-nav h2, .day-head, .up-sheet h2 { font: 600 20px/26px var(--display); }                        /* subheading */
.card-text .t, .done-head .t { font: 600 18px/24px var(--display); }                          /* a task on a card */
.btn, .link, .stamp, .tile-label, .cal-head span, #toast button, .menu-item { font: 600 15px/20px var(--text); }  /* buttons and labels */
.date-line { display: inline-block; justify-self: start; align-self: flex-start; padding: 6px 16px; border-radius: 999px; background: var(--sage);
  font: 400 16px/24px var(--text); color: var(--ink); }
.meta, .day-head span, .chip, .done-head .sub { font: 400 13px/18px var(--text); }                                         /* dates and metadata */

#app { min-height: 100dvh; max-width: 560px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; }

/* ------------------------------------------------------------ the logo: the forest tick box and "doable", always lowercase */
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.logo-btn { padding: 0; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.logo-mark svg { width: 30px; height: 30px; }
.wordmark { font: 700 30px/1 var(--logo); letter-spacing: -.025em; color: var(--ink); padding-bottom: 2px; }

/* every screen: the logo, and the ••• menu */
.bar { display: flex; align-items: center; justify-content: space-between; padding: max(16px, env(safe-area-inset-top)) 0 0; min-height: 60px; }
.menu-btn { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--paper); color: var(--ink); }
.menu-btn:hover { background: var(--sage); }
dialog.menu { position: fixed; inset: auto; margin: 0; width: 230px; padding: 8px; border: 1px solid var(--border); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow-lift);
  animation: fade .15s ease-out; }
dialog.menu::backdrop { background: rgba(16, 43, 33, .12); }
.menu-who { padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.menu-item { display: block; width: 100%; padding: 12px; border: 0; border-radius: 10px; background: none; text-align: left; color: var(--ink); }
.menu-item:hover { background: var(--sage); }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; padding: 12px 22px; border: 0; border-radius: var(--r);
  transition: transform .1s, opacity .2s, background .15s; }
.btn svg { width: 22px; height: 22px; stroke-width: 2.2; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.primary, .go { background: var(--forest); color: var(--white); }
.secondary { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--forest); }
.secondary:hover { background: var(--sage); }
.quiet { min-height: 44px; padding: 8px 16px; background: none; color: var(--muted); }
.quiet:hover { color: var(--ink); }
.link { padding: 4px; border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
.link:hover { color: var(--ink); }
.x { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--ink); }
.x svg { width: 26px; height: 26px; }
.x:hover { background: var(--sage); }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 12px; width: 100%; }

/* ------------------------------------------------------------ cards: warm paper, with a coral edge along the top */
.card { position: relative; background: var(--paper); border-radius: var(--r-card); box-shadow: 0 0 0 1px var(--border), var(--shadow); overflow: hidden; }
.card::before { content: ''; position: absolute; inset: 0 0 auto; height: 5px; background: var(--rule); }

/* ------------------------------------------------------------ the first screen: pick today's tasks */
.pick-screen { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.hello { margin-top: 26px; max-width: 12ch; }
.pick-screen .date-line { align-self: center; margin-top: 14px; }
.pick-title { margin-top: 26px; }
.stage, .sort-controls { align-self: stretch; }
.stage { flex: 1; display: grid; place-items: start center; min-height: 260px; padding: 24px 0 34px; }
.stage > * { grid-area: 1 / 1; }
.sort-card { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 8px; width: 100%; aspect-ratio: 3 / 2; padding: 26px 20px 18px;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lift); text-align: left; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab; }
.sort-card::before { height: 6px; }
.sort-card.dragging { cursor: grabbing; }
.sort-card p { flex: 0 1 auto; min-height: 0; max-width: 100%; overflow: hidden; margin-right: 36px; font: 700 26px/32px var(--display); letter-spacing: -.01em; overflow-wrap: anywhere; }
/* the date button in the card's top right corner: hold it until a date */
.sort-card .card-date { position: absolute; top: 16px; right: 14px; }
.card-date .date-btn { height: 42px; min-width: 42px; padding: 0 10px; }
.sort-card.dragging .card-date { opacity: 0; }
/* the cards underneath fan out a little, like a real pile */
/* the pile: cards 3:2 landscape, about 80% of the width (never narrower than 250px, unless the screen is) */
.pile-stack, .stage > .yay-card { width: 80%; min-width: min(100%, 250px); }
.pile-stack { position: relative; }
.pile-stack .sort-card { position: relative; z-index: 1; }
.under { position: absolute; inset: 0; }
.under.u1 { transform: translate(6px, 10px) rotate(1.4deg); }
.under.u2 { transform: translate(11px, 20px) rotate(2.8deg); }
.stamp { position: absolute; top: 18px; right: 18px; padding: 2px 10px; border: 2px solid; border-radius: 8px; background: var(--paper); pointer-events: none; }
.stamp.yes { color: var(--forest); opacity: var(--yes, 0); rotate: 8deg; }
.stamp.no { color: var(--muted); opacity: var(--no, 0); rotate: -8deg; }
.sort-controls { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 0 max(22px, env(safe-area-inset-bottom)); }
.sort-controls .actions .btn { min-height: 58px; }
/* an empty pile: a space for cards, and Add a card */
/* nothing in the pile: a card that says so */
.yay-card { align-items: center; cursor: default; }
.yay-card p { margin: 0; color: var(--forest); text-align: center; }
.add-card { padding-left: 14px; padding-right: 14px; white-space: nowrap; }

/* ------------------------------------------------------------ Today */
.home .date-line { margin-top: 18px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.tile { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 12px 16px; border: 0; border-radius: var(--r-card); background: var(--paper);
  box-shadow: 0 0 0 1px var(--border), var(--shadow); color: var(--ink); transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile-done { background: var(--sage); box-shadow: 0 0 0 1px var(--sage); }
.tile-icon svg { width: 24px; height: 24px; }
.tile-text { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; text-align: left; }
.tile-action { display: inline-flex; align-items: center; gap: 1px; white-space: nowrap; font: 500 13px/18px var(--text); color: var(--forest); }
.tile-action svg { width: 14px; height: 14px; stroke-width: 2.4; }
.tile b { font: 700 26px/1 var(--display); font-variant-numeric: tabular-nums; }
.today-title { margin: 30px 0 14px; }
.today { display: flex; flex-direction: column; gap: 14px; }
.home-pile .stage { flex: none; min-height: 0; padding: 0 0 26px; }
.home-pile .sort-controls { padding-bottom: 8px; }
.home-pile .hint { margin-top: -4px; text-align: center; }
.well-done { margin: -4px 0 14px; text-align: center; }
.well-done h2 { font: 700 24px/30px var(--display); color: var(--forest); }
.well-done .hint { margin-top: 4px; font-size: 16px; }
.today-card { display: flex; align-items: center; gap: 8px; min-height: 76px; padding: 18px 10px 14px 20px; cursor: pointer; transition: box-shadow .15s; }
.today-card:hover { box-shadow: 0 0 0 1px var(--border), var(--shadow-lift); }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0; border: 0; background: none;
  text-align: left; overflow-wrap: anywhere; }
/* tick circles, on the right; forest when ticked */
.tick { flex: none; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; background: none; color: transparent; }
.tick span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1.8px solid var(--control); background: var(--paper);
  transition: background .2s, border-color .2s, color .2s; }
.tick svg { width: 18px; height: 18px; stroke-width: 2.8; }
.tick:hover span { border-color: var(--forest); color: var(--forest); }
.tick.on span { background: var(--forest); border-color: var(--forest); color: var(--white); }

/* a card's date, and a mark when it has details */
.extras { display: flex; align-items: center; gap: 8px; }
.note-mark { display: inline-grid; place-items: center; color: var(--muted); vertical-align: middle; }
.note-mark svg { width: 16px; height: 16px; }
.done-head .t .note-mark { margin-left: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px 1px 7px; border-radius: 999px; background: var(--sage); color: var(--forest); white-space: nowrap; }
.chip svg { width: 13px; height: 13px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 24px; border: 1.5px dashed var(--border); border-radius: var(--r-card);
  color: var(--muted); text-align: center; }
.empty h2 { color: var(--ink); }
.empty p { max-width: 34ch; }

/* writing a card: one box, with the microphone and + inside */
/* Today: Add a card, at the bottom */
.add-bar { position: sticky; z-index: 1; bottom: 0; margin-top: auto; padding: 16px 0 max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(247, 245, 238, 0), var(--warm-white) 26px); }
.add-btn { width: 100%; min-height: 58px; font-size: 17px; }
.add-btn svg { width: 22px; height: 22px; stroke-width: 2.4; }
/* the blank card: the microphone at its bottom right */
.new-card { position: relative; align-items: flex-end; gap: 8px; }
.new-card .sheet-name { min-height: 84px; }
.new-card .mic { flex: none; }
.new-card.listening .mic { background: var(--forest); color: var(--white); animation: listening 1.4s ease-out infinite; }
.mic { flex: none; display: grid; place-items: center; width: 44px; height: 48px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); }
.mic:hover { background: var(--sage); color: var(--ink); }
@keyframes listening { 0% { box-shadow: 0 0 0 0 rgba(11, 56, 41, .4); } 100% { box-shadow: 0 0 0 12px rgba(11, 56, 41, 0); } }

/* a card on its way to a pile */
.ghost { position: fixed; z-index: 50; margin: 0; pointer-events: none; transform-origin: center; }

/* ------------------------------------------------------------ sheets that slide up from the bottom */
dialog { max-width: 100vw; max-height: 100dvh; padding: 0; border: 0; background: none; color: inherit; }
dialog::backdrop { background: rgba(16, 43, 33, .38); }
dialog.up-sheet { position: fixed; inset: auto 0 0; width: min(100%, 560px); max-height: 92dvh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 20px max(22px, env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; background: var(--warm-white); box-shadow: var(--shadow-lift);
  animation: up .26s cubic-bezier(.2, .8, .2, 1); }
.grip { width: 44px; height: 5px; margin: 4px auto 14px; border-radius: 3px; background: var(--border); }
.up-sheet h2 { margin: 6px 0 16px; }
.up-sheet .hint { margin: -8px 0 14px; color: var(--muted); }
@keyframes up { from { transform: translateY(100%); } }
/* a card's sheet */
.sheet-top { display: flex; align-items: center; justify-content: space-between; margin: -2px -6px 14px; }
.date-corner { display: inline-flex; align-items: center; gap: 4px; }
.date-btn { display: inline-flex; align-items: center; gap: 8px; height: 46px; min-width: 46px; justify-content: center; padding: 0 12px; border: 0; border-radius: 14px;
  background: var(--sage); color: var(--forest); font: 600 15px/20px var(--text); }
.date-btn svg { width: 24px; height: 24px; }
.date-btn:hover { box-shadow: inset 0 0 0 1.5px var(--forest); }
.date-clear { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); }
.date-clear svg { width: 18px; height: 18px; }
.picker { position: relative; display: inline-flex; }
.picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.name-box { padding: 22px 18px 16px; }
.sheet-name { display: block; width: 100%; padding: 0; border: 0; outline: none; resize: none; overflow: hidden; background: none; color: var(--ink);
  font: 700 22px/28px var(--display); }
.details-box { margin-top: 14px; padding: 14px 16px; border-radius: var(--r-card); background: var(--paper); box-shadow: 0 0 0 1px var(--border); }
.details-box:focus-within, .name-box:focus-within { box-shadow: 0 0 0 1.5px var(--control); }
.sheet-details { display: block; width: 100%; min-height: 96px; padding: 0; border: 0; outline: none; resize: none; overflow: hidden; background: none;
  color: var(--ink); font: 400 16px/24px var(--text); }
.sheet-name::placeholder, .sheet-details::placeholder { color: var(--muted); }
.card-sheet .actions { margin-top: 22px; }
.card-sheet .actions .btn { min-height: 58px; }
/* Not today: Back to To do, Pick a date */
.card-sheet .throw { display: block; margin: 8px auto 0; }
/* setting a password */
.password-form { display: flex; flex-direction: column; gap: 12px; }
.password-form .hint, .password-form .form-msg, .password-form h2 { margin: 0; }
.password-form .actions { margin-top: 6px; }

/* ------------------------------------------------------------ Done history */
.page-title { margin: 22px 0 16px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .glass { position: absolute; left: 15px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search-wrap .glass svg { width: 22px; height: 22px; }
.search-wrap .clear { position: absolute; right: 5px; display: none; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px;
  background: none; color: var(--muted); }
.search-wrap .clear svg { width: 18px; height: 18px; }
.search-wrap .clear:hover { background: var(--sage); color: var(--ink); }
.search-wrap.has-query .clear { display: grid; }
.search::-webkit-search-cancel-button { display: none; -webkit-appearance: none; }
/* 16px, not 14: on an iPhone, anything smaller makes Safari zoom in when it's tapped */
.search { width: 100%; min-height: 52px; padding: 12px 48px 12px 48px; border: 0; border-radius: var(--r); outline: none; -webkit-appearance: none; appearance: none;
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--border); font: 400 16px/24px var(--text); }
.search:focus { box-shadow: inset 0 0 0 1.5px var(--forest); }
.search::placeholder { color: var(--muted); }
.done-body { padding-bottom: max(30px, env(safe-area-inset-bottom)); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.nav-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--paper); color: var(--ink); }
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover { background: var(--sage); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 4px; }
.cal-head span { padding: 0 0 6px; color: var(--muted); text-align: center; font-weight: 400; font-size: 14px; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 50px; padding: 2px 0; border: 0; border-radius: 12px; background: none; }
.cell .n { display: grid; place-items: center; width: 40px; height: 36px; border-radius: 10px; color: var(--ink); font: 500 15px/20px var(--text); font-variant-numeric: tabular-nums;
  transition: background .15s; }
button.cell:hover .n { background: var(--sage); }
.cell.now .n { color: var(--forest); font-weight: 700; }
.cell.sel .n, button.cell.sel:hover .n { background: var(--forest); color: var(--white); font-weight: 700; }
.cell .dot { width: 6px; height: 6px; border-radius: 50%; }
.cell.has-done .dot { background: var(--leaf); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 24px 0 12px; color: var(--ink); }
.day-head span { color: var(--muted); }
.rows { display: flex; flex-direction: column; gap: 12px; }
.note { margin: 6px 0; color: var(--muted); }
/* a completed task: tap to open it in place */
.done-card { padding: 0; }
.done-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 20px 14px 14px 18px; border: 0; background: none; text-align: left; }
.done-head .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.done-head .t { overflow-wrap: anywhere; }
.done-head .sub { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.ok { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--leaf); color: var(--white); }
.ok svg { width: 14px; height: 14px; stroke-width: 3; }
.chev { flex: none; color: var(--ink); }
.done-card.open { padding: 20px 18px 18px; }
.done-card.open .done-head { padding: 8px 0 14px; border-bottom: 1px solid var(--border); }
.done-card.open .details-box { margin-top: 14px; }
.put-back { width: 100%; margin-top: 16px; }

@keyframes fade { from { opacity: 0; } }

/* ------------------------------------------------------------ toast */
#toast { position: fixed; inset: auto 0 calc(max(16px, env(safe-area-inset-bottom)) + 86px); width: max-content; max-width: calc(100% - 40px); margin: 0 auto;
  align-items: center; gap: 12px; padding: 6px 6px 6px 18px; border: 0; border-radius: var(--r); overflow: visible;
  background: var(--ink); color: var(--white); box-shadow: var(--shadow-lift);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
#toast:popover-open { display: flex; }
#toast.show { opacity: 1; transform: none; }
#toast:not(:has(button)) { padding: 11px 18px; }
#toast button { padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------ sign in */
.signin { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 34px; padding: 40px 0 14vh; text-align: center; }
.brand .logo { justify-content: center; }
.brand .logo-mark svg { width: 46px; height: 46px; }
.brand .wordmark { font-size: 48px; }
.brand p { margin: 14px 0 0; color: var(--muted); }
.signin-form { display: flex; flex-direction: column; gap: 12px; width: min(100%, 360px); }
.field { width: 100%; min-height: 52px; padding: 14px 18px; border: 0; border-radius: var(--r); outline: none; background: var(--paper); box-shadow: inset 0 0 0 1px var(--control);
  font: 400 16px/24px var(--text); text-align: center; }
.field:focus { box-shadow: inset 0 0 0 1.5px var(--forest); }
.field::placeholder { color: var(--muted); }
.code { font: 600 28px/34px var(--text); letter-spacing: .4em; padding-left: calc(18px + .4em); font-variant-numeric: tabular-nums; }
.hint { margin: 6px 0 0; color: var(--muted); }
.form-msg { min-height: 22px; color: var(--error); }
.form-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; margin-top: -22px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
