/* The Journey. Neutral near-black with fine grain and a faint brown-gold warmth; photographs carry the meaning.
   Type: Gill Sans Light for titles and time, Helvetica Neue for everything else. Every control is at least 44px, for a finger. */
:root {
  --ink: #f5f3ee; --dim: rgba(245, 243, 238, .66); --faint: rgba(245, 243, 238, .42);
  --line: rgba(255, 255, 255, .16); --line-2: rgba(255, 255, 255, .3);
  --glass: rgba(20, 19, 18, .58); --glass-2: rgba(255, 255, 255, .08); --ground: #151413;
  --cross: #39d0c2; --on-cross: #06211f; --warn: #ff8a6b; --glow: rgba(255, 228, 190, .3);
  --title: "Gill Sans", "Gill Sans MT", "Avenir Next", "Helvetica Neue", sans-serif;
  --ui: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --r: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--ground); color: var(--ink); font: 15px/1.35 var(--ui); overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Grit: a very faint warm light over fine grain */
#grit { position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: radial-gradient(90% 80% at 50% 0%, rgba(150, 112, 58, .10), transparent 70%), radial-gradient(70% 60% at 85% 100%, rgba(120, 84, 40, .07), transparent 70%), var(--ground); }
#grit::after { content: ''; position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

.view { position: fixed; inset: 0; padding: max(26px, env(safe-area-inset-top)) max(34px, env(safe-area-inset-right)) max(26px, env(safe-area-inset-bottom)) max(34px, env(safe-area-inset-left)); display: flex; flex-direction: column; }
.grow { flex: 1; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.pill { height: 44px; padding: 0 20px; border-radius: 22px; border: 1px solid var(--line); background: var(--glass-2); font-size: 14px; white-space: nowrap; }
.pill:active, .pill.on { background: var(--ink); color: var(--ground); }
.pill.warn { border-color: rgba(255, 138, 107, .55); }

/* ---------- Journey view ---------- */
.jh { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.jh h1 { margin: 4px 0 0; font: 300 32px/1.1 var(--title); letter-spacing: .05em; text-transform: uppercase; }
.jh h1[contenteditable="true"] { border-bottom: 1px dashed var(--line-2); outline: none; user-select: text; -webkit-user-select: text; }
#cards { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 18px; }
#cards .row { flex: 1; min-height: 0; display: flex; gap: 18px; justify-content: center; }
.card { position: relative; flex: 0 0 calc((100% - 18px * (var(--per) - 1)) / var(--per)); border-radius: 30px; overflow: hidden; text-align: left; padding: 26px;
  display: flex; flex-direction: column; justify-content: flex-end; background: #222 center / cover; border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0, 0, 0, .55); }
.card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8, 8, 10, .1) 30%, rgba(8, 8, 10, .78)); }
.card > * { position: relative; }
.card .no { font: 300 88px/1 var(--title); }
.card .ti { font: 300 25px/1.15 var(--title); letter-spacing: .08em; text-transform: uppercase; margin-top: 8px; }
.two .card .no { font-size: 60px; } .two .card .ti { font-size: 21px; } .two .card { padding: 20px 24px; }
.card .live { position: absolute; top: 22px; left: 26px; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.card .live::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 12px #fff; }
.card.now { border-color: rgba(255, 255, 255, .6); box-shadow: 0 14px 34px rgba(0, 0, 0, .55), 0 0 54px var(--glow); }
.card .edit { position: absolute; top: 18px; right: 18px; }
.stepper { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.stepper b { font-size: 20px; color: var(--ink); width: 28px; text-align: center; font-weight: 500; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass-2); display: grid; place-items: center; font-size: 20px; }

/* ---------- Chapter view ---------- */
#backdrop { position: absolute; inset: -30px; background: center / cover; filter: blur(26px) brightness(.29) saturate(1.1); transition: background-image 1s; }
#chapter .pg { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.back { align-self: flex-start; height: 32px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-weight: 600; margin: -6px 0 6px; }
.hd { display: grid; grid-template-columns: 1fr auto auto; column-gap: 28px; row-gap: 10px; align-items: center; }
.title { font: 300 58px/58px var(--title); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.title input { width: 100%; background: transparent; border: 0; border-bottom: 1px dashed var(--line-2); font: inherit; letter-spacing: inherit; text-transform: uppercase; padding: 0; outline: none; user-select: text; -webkit-user-select: text; }
.time { font: 300 58px/58px var(--title); min-width: 150px; text-align: right; font-variant-numeric: tabular-nums; }
.time.over { color: var(--warn); }
.tr { display: flex; gap: 12px; }
.tr button { width: 56px; height: 56px; border-radius: 18px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22); display: grid; place-items: center; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.tr button:active { background: rgba(255, 255, 255, .25); }
.tr button:disabled { opacity: .3; }
.tr svg { width: 22px; height: 22px; fill: var(--ink); }
.labs { display: flex; gap: 12px; }
.labs span { width: 56px; text-align: center; font-size: 12px; color: var(--dim); }
.st { text-align: right; font-size: 13px; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.keyc { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 11px; border: 1px solid rgba(255, 255, 255, .7); border-radius: 18px; font-size: 14px; font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); border-radius: 18px; padding: 0 14px 0 3px; font-size: 14px; }
.chip i { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .18) center / cover; display: grid; place-items: center; font-style: normal; font-size: 12px; }
.chip.add { padding: 0 14px; border-style: dashed; color: var(--dim); }
.chip .x { margin-left: 2px; color: var(--dim); font-size: 16px; }

.els { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 26px; border-radius: 28px; padding: 0; transition: box-shadow 1.2s; }
.els.usher { animation: usher 3.2s ease-in-out infinite; }
@keyframes usher { 0%, 100% { box-shadow: 0 0 0 1px rgba(255, 236, 210, .1), 0 0 30px rgba(255, 228, 190, .08); } 50% { box-shadow: 0 0 0 1px rgba(255, 236, 210, .32), 0 0 60px rgba(255, 228, 190, .26); } }
.el { border-radius: 24px; overflow: hidden; background: var(--glass); border: 1px solid rgba(255, 255, 255, .14); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); display: flex; flex-direction: column; min-width: 0; transition: border-color .6s, box-shadow .6s; }
.el.on { border-color: rgba(255, 255, 255, .5); animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 30px 0 rgba(255, 214, 170, .16); } 50% { box-shadow: 0 0 46px 4px rgba(255, 214, 170, .3); } }
.el .ph { height: 150px; background: rgba(255, 255, 255, .05) center / cover; display: grid; place-items: center; color: var(--faint); font-size: 13px; width: 100%; }
.el .b { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.el h3 { margin: 0; font-size: 19px; font-weight: 600; }
.el small { display: block; font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ctl { display: flex; align-items: center; gap: 12px; }
.go { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .75); display: grid; place-items: center; flex: none; }
.go:disabled { opacity: .3; }
.el.on .go, .el.in .go { background: var(--ink); border-color: var(--ink); }
.go .sq { width: 12px; height: 12px; border-radius: 2px; background: #15151a; }
.go .tri { width: 0; height: 0; border-left: 12px solid var(--ink); border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 3px; }
.go .ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; opacity: 0; }
.go .ring circle { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 169.6; stroke-dashoffset: 169.6; }
.el.in .ring, .el.out .ring { opacity: 1; }
.fader { position: relative; flex: 1; min-width: 0; height: 44px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .2); overflow: hidden; touch-action: none; cursor: ew-resize;
  background: linear-gradient(90deg, rgba(245, 243, 238, .34) var(--v), rgba(255, 255, 255, .08) 0); }
.fader::after { content: ''; position: absolute; left: clamp(4px, calc(var(--v) - 3px), calc(100% - 9px)); top: 8px; bottom: 8px; width: 5px; border-radius: 3px; background: var(--ink); }
.fader.tone { background: rgba(255, 255, 255, .08); }
/* In sheets a fader sits in a column, where it takes the full width instead of growing */
.side .fader { flex: none; width: 100%; }
.fader.tone::before { content: ''; position: absolute; left: 50%; top: 10px; bottom: 10px; width: 1px; background: var(--line-2); }
.cross { position: relative; height: 40px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .2); display: flex; align-items: center; justify-content: center; gap: 10px; color: rgba(245, 243, 238, .55); font-size: 13px; touch-action: pan-y; width: 100%; }
.cross svg { width: 46px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cross.on { background: var(--cross); border-color: var(--cross); color: var(--on-cross); font-weight: 600; }
.cross .lbl { display: none; }
.cross.on .lbl, .sheet .cross .lbl { display: inline; }

.res { margin-top: auto; display: flex; gap: 26px; border-top: 1px solid rgba(255, 255, 255, .16); padding-top: 16px; }
.grp { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.grp h4 { margin: 0; font-size: 15px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.grp h4 input { width: 120px; background: transparent; border: 0; border-bottom: 1px dashed var(--line-2); padding: 0; outline: none; font-weight: 600; user-select: text; -webkit-user-select: text; }
.ps { display: flex; gap: 10px; }
.os { position: relative; flex: 1 1 0; display: flex; align-items: center; gap: 10px; background: var(--glass); border: 1px solid rgba(255, 255, 255, .14); border-radius: 18px; padding: 7px; min-width: 0; max-width: 220px; text-align: left; }
.os .ph { width: 58px; height: 58px; border-radius: 13px; flex: none; background: rgba(255, 255, 255, .08) center / cover; }
.os span { font-size: 13px; line-height: 1.2; overflow: hidden; }
.os.hit { animation: hit .9s ease-out; }
@keyframes hit { from { box-shadow: 0 0 0 2px rgba(255, 236, 210, .8), 0 0 40px rgba(255, 228, 190, .6); } to { box-shadow: none; } }
.os.add { justify-content: center; border-style: dashed; color: var(--dim); min-width: 72px; flex: 0 0 auto; }
.os .x, .card .x { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; background: #333; border: 1px solid var(--line-2); font-size: 14px; display: grid; place-items: center; }

/* ---------- Sheets: one at a time, over a blurred page ---------- */
#veil { position: fixed; inset: 0; z-index: 10; background: rgba(10, 10, 10, .45); -webkit-backdrop-filter: blur(18px) brightness(.7); backdrop-filter: blur(18px) brightness(.7); animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; } }
#sheet { position: fixed; z-index: 11; inset: max(40px, env(safe-area-inset-top)) 54px max(40px, env(safe-area-inset-bottom)); border-radius: 30px; overflow: hidden; background: rgba(24, 23, 21, .9); border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55); display: flex; animation: rise .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
#sheet.split { display: grid; grid-template-columns: 1.15fr 1fr; }
#sheet .big { background: rgba(255, 255, 255, .05) center / cover; position: relative; display: grid; place-items: center; color: var(--faint); }
#sheet .big .pill { position: absolute; left: 20px; bottom: 20px; }
.side { padding: 28px 30px; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; flex: 1; }
.side h2 { margin: 0; font: 300 34px/1.1 var(--title); letter-spacing: .06em; text-transform: uppercase; }
.sheethead { display: flex; align-items: center; gap: 10px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 18px; padding: 8px; text-align: left; min-height: 72px; width: 100%; }
.opt .ph { width: 54px; height: 54px; border-radius: 12px; flex: none; background: rgba(255, 255, 255, .08) center / cover; }
.opt.sel { border-color: rgba(255, 255, 255, .8); background: rgba(255, 255, 255, .08); }
.opt b { display: block; font-size: 16px; font-weight: 600; }
.opt small { font-size: 13px; color: var(--dim); }
.opt .grow + .pill { height: 36px; padding: 0 14px; font-size: 13px; }
.flab { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; }
.adds { display: flex; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { position: relative; aspect-ratio: 1.35; border-radius: 16px; background: #222 center / cover; border: 2px solid transparent; overflow: hidden; }
.tile span { position: absolute; left: 10px; bottom: 8px; font-size: 13px; font-weight: 600; text-shadow: 0 1px 4px #000; }
.tile.sel { border-color: var(--ink); }
.notes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.notes .pill { padding: 0; }
.row2 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-2); padding: 0 14px; outline: none; user-select: text; -webkit-user-select: text; min-width: 0; }
.setrow { display: flex; flex-direction: column; gap: 6px; }
.setrow .top { display: flex; justify-content: space-between; font-size: 15px; }
.setrow .top b { font-weight: 600; }
.setcard { border: 1px solid rgba(255, 255, 255, .14); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.setcard h3 { margin: 0; font-size: 18px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.setcard h3 button { font-size: 13px; color: var(--dim); font-weight: 400; height: 44px; }
.hint { font-size: 13px; color: var(--dim); }
.switch { width: 52px; height: 32px; border-radius: 16px; background: rgba(255, 255, 255, .16); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.switch.on { background: var(--cross); }
.switch.on::after { transform: translateX(20px); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; color: var(--dim); }
.keys kbd { font: 600 13px var(--ui); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 8px; justify-self: start; }

#toast { position: fixed; z-index: 20; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(30, 29, 27, .95); border: 1px solid var(--line-2); border-radius: 22px; padding: 12px 20px; font-size: 14px; max-width: 80vw; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: fadein .2s; }

/* Narrower screens: iPad portrait and smaller laptops */
@media (max-width: 1000px) {
  .els { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .el .ph { height: 110px; }
  .title, .time { font-size: 44px; line-height: 44px; }
  .res { flex-wrap: wrap; gap: 14px 22px; }
  .res .grp { flex: 1 1 calc(50% - 11px) !important; }
  #sheet { inset: 30px 24px; }
  #sheet.split { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; }
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 760px) { .el .ph { height: 104px; } .els { margin-top: 18px; } }
@media (prefers-reduced-motion: reduce) { .el.on, .els.usher { animation: none; } }
