/* P8 — real devices: viewport height that follows the keyboard, the
   notification prompt, the iPhone "add to Home Screen" guide, 診斷, the
   in-app notice for a card in another conversation. 墨 Mono tokens only;
   amber = something waits on you. */

/* ── Viewport ───────────────────────────────────────────────── */
@supports (height: 100dvh) {
  html,
  body {
    height: 100dvh;
  }
}

/* The keyboard: chat.ts lifts the dock by `--kb` (iOS keeps the layout
   viewport when it opens); device.ts undoes the page scroll iOS adds. */

/* ── Notification prompt / guides ───────────────────────────── */
.np-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-2) 0 var(--space-1);
}

.np-preview {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  margin: var(--space-2) 0 var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-xl);
  background: var(--c-surface-raised);
  box-shadow: var(--shadow-md);
  animation: rise var(--dur-slow) var(--ease-spring);
}

.np-app img {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 9px;
}

.np-text {
  flex: 1;
  min-width: 0;
}

.np-text p {
  margin: 0;
}

.np-head {
  display: flex;
  justify-content: space-between;
  color: var(--c-ink-muted);
  font-size: var(--text-xs);
}

.np-head b {
  color: var(--c-ink-soft);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
}

.np-title {
  margin-top: 2px !important;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.np-body {
  color: var(--c-ink-soft);
  font-size: var(--text-sm);
}

.np-hero {
  display: grid;
  place-items: center;
  margin-top: var(--space-2);
}

.np-bell {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--c-attention-soft);
  color: var(--c-attention);
}

.np-hero.muted .np-bell {
  background: var(--c-surface-sunken);
  color: var(--c-ink-muted);
}

.np-title-big {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.np-hero + .np-title-big {
  text-align: center;
}

.np-lead {
  margin: calc(-1 * var(--space-2)) 0 0;
  color: var(--c-ink-soft);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

.np-facts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  list-style: none;
  border-radius: var(--radius-lg);
  background: var(--c-surface-sunken);
  font-size: var(--text-sm);
}

.np-facts li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--c-ink-soft);
}

.np-facts .icon {
  margin-top: 3px;
  color: var(--c-success);
}

.np-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.np-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
}

.np-step p {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
}

.np-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--c-inverse);
  color: var(--c-inverse-ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.np-glyph {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  background: var(--c-surface-sunken);
  color: var(--c-accent);
}

.np-glyph .icon {
  transform: rotate(180deg);
}

.np-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.btn.ghost {
  background: transparent;
  color: var(--c-ink-muted);
}

.btn.ghost:active:not(:disabled) {
  background: var(--c-hover);
}

.np-error {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--c-danger-soft);
  color: var(--c-danger);
  font-size: var(--text-sm);
}

/* ── 裝置: this phone's rows ────────────────────────────────── */
.notif-group {
  margin: 0 0 var(--space-5);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
}

.notif-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 68px;
  padding: var(--space-2) var(--space-4);
  border: 0;
  background: transparent;
  text-align: left;
}

.notif-row + .notif-row {
  border-top: 1px solid var(--c-line);
}

.notif-row > .icon {
  color: var(--c-ink-faint);
}

.diag-row:active {
  background: var(--c-hover);
}

.notif-group .notif-row:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.notif-group .notif-row:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.nr-sub {
  margin: 2px 0 0;
  color: var(--c-ink-muted);
  font-size: var(--text-xs);
}

.nr-sub[data-state="denied"],
.nr-sub[data-state="needs-install"] {
  color: var(--c-attention);
}

/* ── Pairing: iPhone hint + 診斷 ────────────────────────────── */
.pair-install {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  background: var(--c-surface);
  color: var(--c-ink-soft);
  font-size: var(--text-sm);
  text-align: left;
}

.pair-install > .icon:first-child {
  color: var(--c-attention);
}

.pair-install span {
  flex: 1;
}

.pair-diag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding-left: 0;
  color: var(--c-ink-muted);
}

/* ── 診斷 ───────────────────────────────────────────────────── */
.dg-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--space-6);
}

.dg-acts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.dg-act {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: left;
}

.dg-act .icon {
  color: var(--c-ink-muted);
}

.dg-act:active {
  background: var(--c-hover);
}

.dg-sec {
  margin-bottom: var(--space-5);
}

.dg-list {
  margin: 0;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
}

.dg-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
}

.dg-row + .dg-row {
  border-top: 1px solid var(--c-line);
}

.dg-row dt {
  flex: none;
  width: 84px;
  color: var(--c-ink-muted);
  font-size: var(--text-sm);
}

.dg-row dd {
  display: flex;
  flex: 1;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: right;
  overflow-wrap: anywhere;
}

.dg-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-ink-faint);
  transform: translateY(-1px);
}

.dg-row dd[data-tone="ok"] .dg-dot {
  background: var(--c-success);
}

.dg-row dd[data-tone="warn"] .dg-dot {
  background: var(--c-attention);
}

.dg-row dd[data-tone="bad"] {
  color: var(--c-danger);
}

.dg-row dd[data-tone="bad"] .dg-dot {
  background: var(--c-danger);
}

.dg-loading {
  color: var(--c-ink-muted);
  font-size: var(--text-sm);
}

/* ── Card opened from a notification ────────────────────────── */
.from-push {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-start;
  margin: 0 0 var(--space-3);
  padding: 5px var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--c-attention) 35%, transparent);
  background: var(--c-attention-soft);
  color: var(--c-attention);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

/* ── In-app notice + toast in the chat ──────────────────────── */
.notify-banner {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  margin: 0 var(--phone-gutter) var(--space-2);
  min-height: var(--touch);
  padding: 0 var(--space-4);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-pill);
  background: var(--c-surface-raised);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
  text-align: left;
  animation: rise var(--dur-base) var(--ease-out);
}

.notify-banner .dot {
  background: var(--c-attention);
}

.notify-banner span {
  flex: 1;
}

.notify-banner b {
  color: var(--c-ink);
  font-weight: var(--weight-semibold);
}

.chat-toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--space-16) + var(--safe-bottom) + var(--kb, 0px) + var(--space-6));
  z-index: 5;
  max-width: calc(100% - 2 * var(--phone-gutter));
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--c-inverse);
  color: var(--c-inverse-ink);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  box-shadow: var(--shadow-md);
  animation: rise var(--dur-base) var(--ease-out);
}
