.phone-wallpaper-layer,
.phone-site-background-label { display: none; }

body.is-authenticated {
  --book-ink: #193b32;
  --book-muted: #445f54;
  --book-line: rgba(39, 72, 52, .17);
  --book-safe-top: env(safe-area-inset-top, 0px);
  --book-safe-bottom: env(safe-area-inset-bottom, 0px);
  --book-safe-left: env(safe-area-inset-left, 0px);
  --book-safe-right: env(safe-area-inset-right, 0px);
  --book-gutter: clamp(24px, 5vw, 80px);
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.is-authenticated .topbar {
  position: relative;
  inset: auto;
  z-index: 11;
  padding: max(20px, var(--book-safe-top)) max(var(--book-gutter), var(--book-safe-right)) 0 max(var(--book-gutter), var(--book-safe-left));
}
.is-authenticated .wordmark {
  gap: 9px;
  min-height: 44px;
  padding: 4px 15px 4px 5px;
  border-radius: 14px;
}
.is-authenticated .wordmark-seal {
  width: 34px;
  height: 34px;
  color: #244c3f;
  background: #f4f3df;
  border-radius: 9px;
  font: 600 1.1rem/1 var(--font-display);
}
.is-authenticated .wordmark-copy strong { font-size: 1.04rem; }
.is-authenticated .topbar-actions {
  gap: 0;
  color: #fffdf4;
  background: rgba(22, 49, 42, .85);
  border: 1px solid rgba(255, 255, 255, .44);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(22, 44, 33, .12);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.is-authenticated .quiet-action {
  min-height: 44px;
  padding: 0 13px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 13px;
  box-shadow: none;
  backdrop-filter: none;
  transform: none;
}
.is-authenticated .topbar-actions form { position: relative; }
.is-authenticated .topbar-actions form::before {
  position: absolute;
  inset: 14px auto 14px 0;
  content: "";
  border-left: 1px solid rgba(255, 255, 255, .34);
}

.is-authenticated .workspace {
  flex: 1;
  min-height: 0;
  padding: clamp(20px, 4vh, 42px) max(var(--book-gutter), var(--book-safe-right)) max(32px, var(--book-safe-bottom)) max(var(--book-gutter), var(--book-safe-left));
}
.workspace-panel.book-launcher {
  display: grid;
  gap: clamp(22px, 2.4vw, 32px);
  width: min(100%, clamp(30.5rem, 47vw, 42rem));
  padding: clamp(20px, 2.2vw, 32px);
  color: var(--book-ink);
  border: 1px solid rgba(255, 255, 255, .84);
  border-radius: 24px;
  background: rgba(249, 250, 241, .85);
  box-shadow: 0 18px 54px rgba(21, 50, 39, .15), inset 0 1px rgba(255, 255, 255, .65);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.book-primary, .book-secondary { min-width: 0; }
#book-priorities {
  margin: 0 0 16px;
  color: var(--book-ink);
  font: 650 clamp(1.75rem, 2.5vw, 2.4rem)/1.2 var(--font-display);
  letter-spacing: .045em;
}
#book-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  color: var(--book-ink);
  font-size: 1rem;
  line-height: 1.4;
  letter-spacing: .045em;
}
#book-tools::after {
  flex: 1;
  border-top: 1px solid var(--book-line);
  content: "";
}
.book-favorites, .book-tool-list { display: grid; }
.book-favorites {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 14px);
}
.book-launcher .destination {
  min-width: 0;
  box-shadow: none;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform 160ms ease-out, box-shadow 160ms ease-out, border-color 160ms ease-out;
}
.book-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 1fr auto auto;
  align-items: start;
  min-height: 134px;
  padding: clamp(12px, 1.1vw, 17px);
  color: var(--card-ink);
  background: var(--card-surface);
  border: 1px solid var(--card-line);
  border-radius: 15px;
}
.book-record {
  --card-ink: #fffdf3;
  --card-surface: #29564a;
  --card-line: #244f43;
  --card-chip: rgba(255, 255, 255, .13);
}
.book-clip {
  --card-ink: #533720;
  --card-surface: #f0dfc5;
  --card-line: #d9c5a7;
  --card-chip: rgba(255, 255, 255, .47);
}
.book-alert {
  --card-ink: #254e56;
  --card-surface: #dbe9e8;
  --card-line: #b8d1d0;
  --card-chip: rgba(255, 255, 255, .48);
}
.book-card-icon, .book-tool-icon { display: grid; place-items: center; }
.book-card-icon {
  width: 36px;
  height: 36px;
  color: inherit;
  background: var(--card-chip);
  border-radius: 10px;
}
.book-card-icon svg { width: 23px; height: 23px; }
.book-forward {
  align-self: center;
  justify-self: end;
  color: inherit;
  pointer-events: none;
}
.book-card .book-forward { align-self: start; margin-top: 3px; }
.book-forward svg { width: 16px; height: 16px; }
.book-card strong, .book-card small { grid-column: 1 / -1; }
.book-card strong {
  margin-top: 12px;
  font-size: clamp(1rem, 1.4vw, 1.22rem);
  line-height: 1.4;
  letter-spacing: .025em;
}
.book-card small, .book-tool small {
  font-size: .78rem;
  line-height: 1.45;
  font-weight: 450;
}
.book-card small { margin-top: 3px; }
.book-tool-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
}
.book-tool {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 8px 11px;
  color: var(--book-ink);
  background: rgba(255, 255, 250, .61);
  border: 1px solid var(--book-line);
  border-radius: 12px;
}
.book-tool-icon {
  width: 33px;
  height: 33px;
  color: #315649;
  background: #e6ece0;
  border-radius: 9px;
}
.book-tool-icon svg { width: 19px; height: 19px; }
.book-tool-copy { display: grid; gap: 2px; overflow-wrap: anywhere; }
.book-tool strong { font-size: .98rem; font-weight: 650; line-height: 1.4; }
.book-tool small, .book-tool .book-forward { color: var(--book-muted); }
.book-tool .book-forward svg { width: 13px; height: 13px; }
.book-launcher > .status-message { grid-column: 1 / -1; margin: 0; }
.book-launcher .book-card:is(:hover, :focus-visible) { background: var(--card-surface); }
.book-launcher .book-tool:is(:hover, :focus-visible) { background: rgba(255, 255, 250, .83); }

@media (hover: hover) and (pointer: fine) {
  .book-launcher .destination:hover {
    transform: translateY(-2px);
    border-color: currentColor;
    box-shadow: 0 6px 15px rgba(31, 66, 46, .16);
  }
  .is-authenticated .quiet-action:hover { background: rgba(255, 255, 255, .14); }
}
.book-launcher .destination:active, .topbar .quiet-action:active { filter: brightness(.92); }
.book-launcher .destination:focus-visible, .is-authenticated .topbar :focus-visible {
  transform: none;
  outline: 3px solid #164e45;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fffef7;
}
@media (prefers-reduced-motion: reduce) {
  .book-launcher .destination, .book-launcher .destination:hover { transform: none; transition: none !important; }
}

@media (max-width: 720px), (pointer: coarse) and (max-height: 520px) and (max-width: 960px) {
  body.is-authenticated {
    --book-gutter: clamp(12px, 4vw, 22px);
    height: 100vh;
    height: 100svh;
    min-height: 0;
  }
  .is-authenticated::before {
    position: fixed;
    z-index: 2;
    inset: 0 0 auto;
    height: calc(92px + var(--book-safe-top));
    content: "";
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(22, 35, 34, .64), transparent);
  }
  body.is-authenticated .topbar {
    flex: none;
    gap: 8px;
    padding-top: max(8px, var(--book-safe-top));
  }
  .is-authenticated .wordmark {
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
  }
  .is-authenticated .wordmark-copy strong { color: #fffdf4; text-shadow: 0 1px 4px #203d32; }
  .is-authenticated .quiet-action { width: 44px; padding: 0; }
  .is-authenticated .quiet-action[data-drawer-open] { width: auto; gap: 6px; padding-inline: 11px; }
  .is-authenticated .quiet-action span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .is-authenticated .quiet-action[data-drawer-open] span {
    position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none;
  }
  .is-authenticated .workspace {
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    padding-bottom: max(clamp(10px, 2.4svh, 22px), var(--book-safe-bottom));
  }
  .workspace-panel.book-launcher {
    flex: none;
    width: 100%;
    max-width: 510px;
    margin-top: auto;
    gap: 16px;
    padding: clamp(12px, 3.8vw, 20px);
    border-radius: 20px;
    background: rgba(250, 249, 238, .64);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  #book-priorities { margin-bottom: 10px; font-size: 1.35rem; }
  #book-tools { margin-bottom: 6px; font-size: .94rem; }
  .book-favorites { gap: 7px; }
  .book-card { min-height: 78px; padding: 10px; border-radius: 12px; }
  .book-card-icon { width: 28px; height: 28px; border-radius: 8px; }
  .book-card-icon svg { width: 19px; height: 19px; }
  .book-card .book-forward svg { width: 13px; height: 13px; }
  .book-card strong { margin-top: 7px; font-size: clamp(.94rem, 4.1vw, 1.05rem); }
  .book-card small, .book-tool small, .book-tool .book-forward { display: none; }
  .book-tool-list { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 4px 6px; }
  .book-tool {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
    min-height: 44px;
    padding: 5px 7px;
    border-radius: 9px;
  }
  .book-tool-icon { width: 19px; height: 22px; background: none; }
  .book-tool strong { font-size: .94rem; }

  .phone-wallpaper-layer {
    position: fixed; inset: 0; z-index: 1; display: block; width: 100%; height: 100%;
    object-fit: cover; object-position: center 16%; pointer-events: none;
  }
  .is-authenticated[data-phone-scene] > .scene-root { display: none; }
  .phone-wallpapers { margin-top: 16px; }
  .phone-wallpaper-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .phone-wallpaper-heading h3, .phone-site-background-label { margin: 0; color: #20463c; font-size: 17px; }
  .phone-wallpaper-heading button {
    min-height: 44px; padding: 0 12px; color: #2d524a; background: rgba(220,235,224,.7); border-radius: 10px;
    font-size: 14px; font-weight: 600;
  }
  .phone-wallpaper-heading button[aria-pressed=true] { color: #fff; background: #285649; }
  .phone-wallpaper-choices { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 8px; }
  .phone-wallpaper-choice {
    position: relative; display: grid; gap: 5px; padding: 3px 3px 6px; overflow: hidden; color: #29453d;
    background: #f9fbf5; border: 2px solid #d9e2d8; border-radius: 12px; font-size: 14px; font-weight: 600;
  }
  .phone-wallpaper-choice img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center 14%; border-radius: 7px; }
  .phone-wallpaper-choice[aria-pressed=true] { border-color: #285649; background: #e5f0e8; }
  .phone-wallpaper-choice[aria-pressed=true]::after {
    position: absolute; top: 7px; right: 7px; display: grid; width: 23px; height: 23px; place-items: center;
    content: "✓"; color: #fff; background: #285649; border: 1px solid #fff; border-radius: 50%;
  }
  .phone-wallpapers button:focus-visible { outline: 3px solid #317665; outline-offset: 2px; }
  .phone-wallpaper-note, .phone-wallpaper-status { margin: 8px 0 0; color: #456255; font-size: 13px; }
  .phone-wallpaper-status:empty { display: none; }
  .phone-site-background-label { display: block; margin-top: 24px; }
  .phone-site-background-label + .background-preview { margin-top: 8px; }
}
@media (max-width: 720px) and (orientation: portrait) {
  :is([data-phone-scene="morning-linen"], [data-phone-scene="bookshop-afternoon"], [data-phone-scene="terrace-sunset"]) .phone-wallpaper-layer {
    object-position: 92% top;
  }
  [data-phone-scene="shore-smile"] .phone-wallpaper-layer { object-position: center 31%; }
  [data-phone-scene="rain-gaze"] .phone-wallpaper-layer { object-position: center 40%; }
}
@media (max-width: 720px) and (orientation: portrait) and (min-height: 620px) {
  /* Frame the whole terrace above the launcher, keeping the chair and figure together. */
  .workspace-composite {
    width: min(128vw, 72svh);
    right: calc((100vw - min(128vw, 72svh)) / 2);
  }
}
@media (max-width: 720px) and (orientation: portrait) and (max-height: 490px) {
  [data-phone-scene="shore-smile"] .phone-wallpaper-layer,
  [data-phone-scene="rain-gaze"] .phone-wallpaper-layer { object-position: center 28%; }
}
@media (pointer: coarse) and (orientation: landscape) and (min-width: 540px) and (max-width: 960px) and (max-height: 520px) {
  .workspace-panel.book-launcher {
    max-width: 780px;
    grid-template-columns: minmax(0, .78fr) minmax(0, 1.5fr);
    gap: 18px;
    padding: 12px 16px;
  }
  #book-priorities, #book-tools { margin-bottom: 6px; font-size: 1rem; line-height: 1.4; }
  .book-favorites { grid-template-columns: 1fr; gap: 4px; }
  .book-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 5px 10px;
    border-radius: 9px;
  }
  .book-card strong { grid-column: 2; grid-row: 1; margin: 0; font-size: .94rem; }
  .book-card .book-forward { grid-column: 3; grid-row: 1; align-self: center; margin: 0; }
}
@media (pointer: coarse) and (min-width: 540px) and (max-width: 960px) and (max-height: 275px) {
  body.is-authenticated .topbar { padding-top: max(2px, var(--book-safe-top)); }
  .is-authenticated .workspace { padding-top: 2px; padding-bottom: max(4px, var(--book-safe-bottom)); }
  .workspace-panel.book-launcher { padding-block: 5px; }
  .book-favorites, .book-tool-list { row-gap: 3px; }
}
