/* Crew World (world.js): the canvas fills its host; the status line, buttons and hover card float above it. */
.cw-host { position: relative; width: 100%; height: 100%; min-height: 0; }
.cw { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: var(--radius, 22px); background: var(--world-bg); isolation: isolate; touch-action: none; user-select: none; -webkit-user-select: none; }
.cw.compact { touch-action: pan-y; }
.cw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cw.grabbing .cw-canvas { cursor: grabbing !important; }

.cw-status { position: absolute; left: 14px; top: 14px; display: inline-flex; align-items: center; gap: 8px; max-width: calc(100% - 28px); padding: 7px 12px; border-radius: 999px; background: rgba(var(--card-rgb), .92); box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 10px 24px -18px rgba(29, 26, 22, .5); font-size: 13px; font-weight: 500; color: var(--ink); pointer-events: none; backdrop-filter: blur(6px); }
.cw-status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #CFC6B4; }
.cw-dot.live { background: var(--violet); box-shadow: 0 0 0 0 rgba(124, 92, 224, .5); animation: cw-pulse 2s var(--ease, ease) infinite; }
.cw-dot.ask { background: #E9B400; }
@keyframes cw-pulse { 0% { box-shadow: 0 0 0 0 rgba(124, 92, 224, .45); } 70% { box-shadow: 0 0 0 8px rgba(124, 92, 224, 0); } 100% { box-shadow: 0 0 0 0 rgba(124, 92, 224, 0); } }

/* The legend of places on the full world; small views keep the one-line status instead. */
.cw-chips { position: absolute; left: 14px; top: var(--cw-top, 64px); display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 200px); }
/* Momo's narration replaces the old status line everywhere; small views keep it to one line. */
.cw-status, .cw.small .cw-chips { display: none; }
.cw-narrator { position: absolute; left: 14px; top: 14px; display: flex; align-items: flex-start; gap: 10px; max-width: min(640px, calc(100% - 200px)); padding: 9px 14px 9px 9px; border-radius: 18px; background: rgba(var(--card-rgb), .95); box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 12px 28px -20px rgba(29, 26, 22, .55); color: var(--ink); font-size: 14px; line-height: 1.4; backdrop-filter: blur(6px); pointer-events: none; }
.cw-narrator-face { width: 26px; height: 26px; border-radius: 50%; flex: none; object-fit: cover; background: var(--butter-pale); }
.cw-narrator-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; padding-top: 2px; }
.cw.small .cw-narrator { left: 8px; top: 8px; max-width: calc(100% - 56px); padding: 5px 12px 5px 5px; font-size: 12px; align-items: center; border-radius: 999px; }
.cw.small:not(.compact) .cw-narrator { max-width: calc(100% - 150px); }
.cw.small .cw-narrator-face { width: 20px; height: 20px; }
.cw.small .cw-narrator-text { -webkit-line-clamp: 1; padding-top: 0; }

/* The sheet he gets by tapping anything in the world: a side sheet over the right of the world on a wide screen,
   a bottom sheet on a phone (see the phone rules below). He stays on the world the whole time. */
.cw-card { position: absolute; top: 12px; right: 12px; bottom: 12px; z-index: 4; width: min(380px, calc(100% - 24px)); display: flex; flex-direction: column; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 28px 60px -28px rgba(29, 26, 22, .6); overflow: hidden; }
/* The slide-in plays once as it opens (world.js playOnce), never again when the page redraws around the world. */
.cw-card.cw-opening { animation: cw-sheet-in .32s var(--ease, ease); }
.cw-card[hidden] { display: none; }
.cw-card:focus { outline: none; }
@keyframes cw-sheet-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes cw-card-in { from { opacity: 0; } to { opacity: 1; } }
.cw-card-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 18px; flex: none; }
.cw-card-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; font-size: 18px; letter-spacing: -0.02em; line-height: 1.25; }
.cw-card-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cw-card .cw-card-close, .cw-card .cw-card-back { width: 44px; height: 44px; flex: none; border-radius: 12px; box-shadow: none; background: var(--fill); }
.cw-card .cw-card-back { margin-left: -8px; background: transparent; }
.cw-card-body { flex: 1; min-height: 0; overflow: auto; padding: 0 18px 18px; overscroll-behavior: contain; }
.cw-card-role { margin: 0 0 10px; font-size: 13px; color: var(--ink-3); }
.cw-card-now { margin: 0 0 12px; font-size: 15px; line-height: 1.45; }
.cw-card-quiet { margin: 0 0 12px; padding: 8px 11px; border-radius: 10px; background: var(--quiet-bg); color: var(--quiet-ink); font-size: 13px; }
.cw-card-label { display: block; margin: 8px 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.cw-card-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cw-row { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; border-radius: 12px; background: var(--fill-2); text-align: left; font-size: 14px; color: var(--ink); transition: background .2s var(--ease, ease); }
.cw-row:hover:not(:disabled) { background: var(--hover); }
.cw-row:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
.cw-row-words { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cw-row-words span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cw-row-words small { font-size: 12px; color: var(--ink-3); }
.cw-steps { list-style: none; margin: 0 0 8px; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.cw-steps li { display: flex; flex-direction: column; gap: 1px; font-size: 14px; line-height: 1.4; }
.cw-steps li > span { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cw-steps small { font-size: 12px; color: var(--ink-3); }
.cw-card-pic { display: block; width: 100%; margin: 0 0 12px; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--fill); cursor: zoom-in; }
.cw-card-pic img { display: block; width: 100%; max-height: 200px; object-fit: cover; }
.cw-question { margin: 0 0 12px; padding: 12px 14px; border-radius: 14px; background: var(--question-soft); }
.cw-question b { display: block; font-size: 15px; line-height: 1.35; }
.cw-question p { margin: 6px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); white-space: pre-line; }
.cw-question-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.cw-question .cw-card-btn { background: var(--card); }
.cw-link { min-height: 44px; padding: 0 6px; border: 0; background: none; color: var(--ink-2); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.cw-card-actions { display: flex; gap: 8px; margin-top: 12px; }
.cw-card-btn { min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--fill); font-size: 14px; font-weight: 600; color: var(--ink); }
.cw-card-btn:disabled { opacity: .5; }
.cw-card-btn.primary { background: var(--ink); color: var(--on-ink); }
.cw-chip { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 13px 0 11px; border: 0; border-radius: 999px; background: rgba(var(--card-rgb), .94); color: var(--ink-2); font-size: 13px; box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 10px 24px -18px rgba(29, 26, 22, .5); backdrop-filter: blur(6px); transition: transform .35s var(--ease, ease), background .25s var(--ease, ease); }
.cw-chip:hover { background: var(--card); transform: translateY(-1px); }
.cw-chip:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
.cw-chip b { font-family: var(--mono, monospace); font-size: 12.5px; font-weight: 500; color: var(--ink); }
.cw-chip i { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.cw-chip.work i { background: var(--violet); }
.cw-chip.ask i { background: #FFD84D; box-shadow: 0 0 0 2px rgba(255, 216, 77, .35); }
.cw-chip.queue i { background: #CFC6B4; }
.cw-chip.ship i { background: #90F0CB; }

/* Zoom sits top right, in one quiet group, away from the dock and the garden labels. */
.cw-controls { position: absolute; right: 14px; top: 14px; display: flex; gap: 2px; padding: 3px; border-radius: 14px; background: rgba(var(--card-rgb), .94); box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 10px 24px -18px rgba(29, 26, 22, .5); backdrop-filter: blur(6px); }
.cw.compact .cw-controls { top: 12px; right: 12px; padding: 0; background: none; box-shadow: none; }
.cw:not(.compact) .cw-controls .cw-btn { width: 44px; height: 44px; border-radius: 11px; background: transparent; box-shadow: none; }
.cw:not(.compact) .cw-controls .cw-btn:hover { background: var(--fill); transform: none; }
.cw-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 12px; background: rgba(var(--card-rgb), .94); color: var(--ink); box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 10px 24px -18px rgba(29, 26, 22, .5); transition: transform .35s var(--ease, ease), background .25s var(--ease, ease); }
.cw-btn:hover { background: var(--card); transform: translateY(-1px); }
.cw-btn:active { transform: translateY(0) scale(.96); }
.cw-btn:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

/* A small view (the Today strip, a side panel) gets smaller chrome so the garden keeps the room. */
.cw.small .cw-status { left: 8px; top: 8px; padding: 5px 10px; font-size: 11.5px; max-width: calc(100% - 56px); }
.cw.small .cw-controls { right: 8px; top: 8px; }
.cw.small:not(.compact) .cw-status { max-width: calc(100% - 128px); }
.cw.small .cw-btn, .cw.small:not(.compact) .cw-controls .cw-btn { width: 30px; height: 30px; border-radius: 10px; }

/* The Tour: a small pill at the start of the controls, dark while it runs. */
.cw-tour { height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px 0 10px; border: 0; border-radius: 11px; background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 600; transition: background .25s var(--ease, ease), color .25s var(--ease, ease); }
.cw-tour:hover { background: var(--fill); }
.cw-tour.on { background: var(--ink); color: var(--on-ink); }
.cw-tour:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

/* What the Tour is looking at, in plain words, along the bottom. */
.cw-caption { position: absolute; left: 50%; bottom: 16px; z-index: 2; width: max-content; max-width: min(560px, calc(100% - 28px)); transform: translateX(-50%); padding: 12px 16px 13px; border-radius: 18px; background: rgba(var(--card-rgb), .96); color: var(--ink); box-shadow: 0 1px 0 rgba(29, 26, 22, .05), 0 18px 36px -22px rgba(29, 26, 22, .55); backdrop-filter: blur(6px); pointer-events: none; }
.cw-caption.cw-opening { animation: cw-card-in .4s var(--ease, ease); }
.cw-caption[hidden] { display: none; }
.cw-caption-title { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: -0.01em; }
.cw-caption-title i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cw-caption ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; line-height: 1.4; }
.cw-caption li { display: flex; flex-wrap: wrap; gap: 0 8px; }
.cw-caption-label { color: var(--ink-3); }
.cw-caption small { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-3); }

/* The big view: the world over the whole window. It stays under the "needs you" pill and the chat (35 and up). */
.cw.big { position: fixed; inset: 0; z-index: 34; border-radius: 0; }
html.cw-big-open { overflow: hidden; }

/* From a small view (the Today strip) the same sheet opens as a box over the page; a phone gets it from the bottom. */
.cw-pop { width: min(420px, calc(100vw - 32px)); max-width: none; height: fit-content; max-height: none; margin: auto; padding: 0; border: 0; background: transparent; overflow: visible; }
.cw-pop::backdrop { background: rgba(29, 26, 22, .5); }
.cw-pop .cw-card { position: relative; inset: auto; width: 100%; height: auto; max-height: min(620px, calc(100dvh - 48px)); }
.cw-pop .cw-card.cw-opening { animation: cw-card-in .25s var(--ease, ease); }

/* An easel's picture full size: the picture, then where it is from and a way into its task. */
.cw-proof { width: min(1100px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0; border-radius: 22px; background: transparent; overflow: visible; }
.cw-proof::backdrop { background: rgba(29, 26, 22, .78); }
.cw-proof[open] { animation: cw-card-in .3s var(--ease, ease); }
.cw-proof-card { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); border-radius: 22px; background: var(--card); overflow: hidden; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .7); }
.cw-proof-img { display: block; width: 100%; min-height: 0; flex: 1 1 auto; object-fit: contain; background: var(--fill); }
.cw-proof-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 20px; flex: none; }
.cw-proof-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.cw-proof-words b { font-size: 16px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-proof-where { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-3); }
.cw-proof-where i { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.cw-proof .cw-card-btn { height: 44px; padding: 0 20px; flex: none; }
.cw-proof .cw-proof-close { width: 44px; height: 44px; flex: none; box-shadow: none; background: var(--fill); }
@media (max-width: 600px) {
  .cw-proof-head { flex-wrap: wrap; padding: 12px; }
  .cw-proof-words { flex-basis: calc(100% - 56px); }
  .cw-proof .cw-card-btn { order: 3; flex: 1; }
}

.cw-tip { position: absolute; left: 0; top: 0; max-width: min(260px, calc(100% - 16px)); padding: 9px 12px; border-radius: 12px; background: var(--ink); color: var(--on-ink); font-size: 13px; line-height: 1.4; pointer-events: none; opacity: 0; transition: opacity .2s var(--ease, ease); z-index: 2; }
.cw-tip.show { opacity: 1; }

/* The World page: the garden takes the rest of the screen under its heading. */
.world-page { display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.world-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.world-head .h1 { font-size: clamp(32px, 3.4vw, 48px); }
.world-head .lede { max-width: 560px; margin: 0; font-size: 16px; }
.world-tips { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-3); }
.world-tips li { display: inline-flex; align-items: center; gap: 6px; }
.world-tips kbd { font-family: var(--mono, monospace); font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--fill); color: var(--ink-2); }
/* Sized so the whole stage sits between the heading and the chat box, with nothing hidden under either. */
.world-stage { height: max(440px, calc(100dvh - var(--cw-stage-top, 222px) - 100px)); border-radius: var(--radius, 22px); box-shadow: 0 1px 0 rgba(29, 26, 22, .04), 0 30px 60px -48px rgba(29, 26, 22, .55); }

/* The live mini-view on Today. */
.world-mini { height: 280px; border-radius: var(--radius, 22px); box-shadow: 0 1px 0 rgba(29, 26, 22, .04), 0 24px 48px -40px rgba(29, 26, 22, .5); }

@media (max-width: 860px) {
  .world-stage { height: max(320px, calc(100dvh - var(--cw-stage-top, 180px) - 166px)); }
  /* The narrator says what is going on, so a phone gives the lede's room to the garden. */
  .world-head .lede { display: none; }
  /* Pinch zooms on a phone, so the zoom buttons step aside for the Tour. */
  .cw-zoom { display: none !important; }
  .cw-caption { bottom: 64px; padding: 10px 14px; border-radius: 16px; }
  /* A phone keeps the caption to what is being made and the first line about it. */
  .cw-caption-title { font-size: 14px; }
  .cw-caption ul { font-size: 13px; }
  .cw-caption li:nth-child(n+2), .cw-caption small { display: none; }
  .world-mini { height: 230px; }
  .cw-status { font-size: 12px; padding: 6px 10px; left: 10px; top: 10px; max-width: calc(100% - 70px); }
  .cw-controls { right: 10px; top: 10px; }
  /* On a phone the narrator takes the full width and the zoom buttons tuck under it. */
  .cw:not(.small) .cw-narrator { left: 10px; right: 10px; top: 10px; max-width: none; font-size: 13px; }
  .cw:not(.small) .cw-narrator-text { -webkit-line-clamp: 2; }
  .cw:not(.small) .cw-controls { top: var(--cw-top, 64px); }
  /* On a phone the sheet rises from the bottom, over the legend row. */
  .cw-card { left: 6px; right: 6px; top: auto; bottom: 6px; width: auto; max-height: 72%; border-radius: 22px; }
  .cw-card.cw-opening { animation-name: cw-sheet-up; }
  .cw-card::before { content: ''; display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 4px; background: var(--line-2); flex: none; }
  .cw-pop { width: calc(100vw - 12px); margin: auto auto 6px; }
  .cw-pop .cw-card { max-height: min(72dvh, 620px); }
  .cw-pop .cw-card.cw-opening { animation-name: cw-sheet-up; }
  /* On a phone the legend runs along the bottom as one swipeable row. */
  .cw-chips { left: 0; right: 0; top: auto; bottom: 10px; max-width: none; flex-wrap: nowrap; overflow-x: auto; padding: 0 10px; scrollbar-width: none; }
  .cw-chips::-webkit-scrollbar { display: none; }
  .cw-chip { flex: none; height: 44px; font-size: 13px; }
  .cw:not(.compact) .cw-controls .cw-btn { width: 44px; height: 44px; }
  .world-tips { display: none; }
}

@keyframes cw-sheet-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .cw-dot.live { animation: none; }
  .cw-card.cw-opening, .cw-pop .cw-card.cw-opening, .cw-caption.cw-opening { animation: none; }
  .cw-btn, .cw-tip { transition: none; }
}
