/* LoveDesk app sandbox. Built on design.css tokens. */

.topbar {
  height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 24px;
  border-bottom: 1px solid var(--line); background: rgba(8,9,12,.85); backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-tag { font-family: var(--font-mono); font-size: 11px; color: var(--warn); border: 1px solid rgba(217,178,111,.3); padding: 2px 8px; border-radius: 999px; }
.topbar-links { margin-left: auto; display: flex; gap: 4px; }

.stage {
  max-width: 1280px; margin: 0 auto; padding: 28px 24px 60px;
  display: grid; grid-template-columns: 404px minmax(0, 1fr); gap: 40px; align-items: start;
}

/* ---------- Device ---------- */
.device {
  width: 404px; border-radius: 54px; padding: 12px; position: sticky; top: 80px;
  background: linear-gradient(160deg, #2a2e38, #101217);
  box-shadow: 0 0 0 1px rgba(255,255,255,.07), 0 50px 100px -30px rgba(0,0,0,.85);
}
.screen {
  position: relative; height: 820px; border-radius: 43px; overflow: hidden;
  background: var(--ink-1); display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,.04);
}
.statusbar { height: 46px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 28px 0; font-size: 13px; font-weight: 600; }
.island { width: 98px; height: 26px; border-radius: 20px; background: #000; }
.view { flex: 1; overflow-y: auto; padding: 8px 18px 22px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: none; }
.view::-webkit-scrollbar { display: none; }
.tabbar {
  height: 72px; flex-shrink: 0; border-top: 1px solid var(--line); background: rgba(12,14,19,.96);
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px 16px;
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10.5px; color: var(--text-3); position: relative; }
.tab svg { width: 20px; height: 20px; }
.tab.on { color: var(--text); }
.tab.on svg { color: var(--accent); }
.tab .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent-strong); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; font-weight: 600; }

/* In-app browser (WebView stand-in) */
.webview { position: absolute; top: 46px; left: 0; right: 0; bottom: 72px; display: flex; flex-direction: column; background: #fff; }
.webview[hidden] { display: none; }
.webview.offscreen { visibility: hidden; pointer-events: none; }
.webview.watch-only iframe { pointer-events: none; }
.webview iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.webview-bar { background: var(--ink-1); padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.webview-bar .grow { flex: 1; min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Mobile type & surfaces ---------- */
.kicker { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.title { font-size: 25px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.15; }
.title .serif { font-size: 1.1em; }
.sub { font-size: 14px; color: var(--text-3); line-height: 1.5; }
.section-h { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-top: 4px; }
.section-h button { font-family: var(--font-sans); text-transform: none; letter-spacing: 0; color: var(--text-2); font-size: 12.5px; }
.card { background: var(--ink-2); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.card.accent { border-color: var(--accent-line); background: radial-gradient(260px 160px at 90% 0%, rgba(154,140,245,.18), transparent 70%), var(--ink-2); }
.card.warn { border-color: rgba(217,178,111,.35); background: var(--warn-soft); }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line-strong); color: var(--text-2); background: transparent; }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.chip.ok { color: var(--ok); border-color: rgba(124,196,164,.3); }
.chip.bad { color: var(--bad); border-color: rgba(217,130,130,.3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-block { width: 100%; }
.field { width: 100%; background: var(--ink-1); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: var(--text); outline: none; resize: none; }
.field:focus { border-color: var(--accent-line); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-weight: 600; font-size: 15px; background: linear-gradient(135deg, #3b3170, #6b4fb0); color: #fff; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--ink-2); border: 1px solid var(--line); text-align: left; width: 100%; }
.list-row:hover { border-color: var(--line-strong); }
.pill-status { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill-status.ok { background: var(--ok-soft); color: var(--ok); }
.pill-status.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; padding: 28px 12px; color: var(--text-3); font-size: 13.5px; }

/* Hero agent card */
.hero { position: relative; overflow: hidden; }
.hero-heart { width: 54px; height: 54px; border-radius: 16px; object-fit: cover; box-shadow: 0 0 30px rgba(154,140,245,.45); border: 1px solid rgba(255,255,255,.14); }
.hero-status { font-size: 17px; font-weight: 500; letter-spacing: -0.015em; }
.progress { height: 4px; border-radius: 2px; background: var(--ink-4); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-strong), #c7a7ff); border-radius: 2px; transition: width .4s var(--ease); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--ink-1); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; }
.stat b { font-size: 18px; font-weight: 500; display: block; letter-spacing: -0.02em; }
.stat small { font-size: 11px; color: var(--text-3); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(124,196,164,.6); animation: pulse 1.8s infinite; display: inline-block; }
.pulse.off { background: var(--text-4); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(124,196,164,0); } 100% { box-shadow: 0 0 0 0 rgba(124,196,164,0); } }

/* Conversation */
.convo-head { display: flex; align-items: center; gap: 10px; position: sticky; top: -8px; background: var(--ink-1); padding: 6px 0 10px; z-index: 2; border-bottom: 1px solid var(--line); }
.back { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; }
.thread { display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 16px; font-size: 14px; line-height: 1.4; }
.bubble.them { background: var(--ink-3); align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.me { background: var(--accent-strong); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.bubble.pending { background: transparent; border: 1px dashed var(--accent-line); color: var(--text-2); align-self: flex-end; }
.draft { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: var(--ink-2); text-align: left; width: 100%; transition: border-color .15s; }
.draft.on { border-color: var(--accent); background: var(--accent-soft); }
.draft-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.draft-text { font-size: 14.5px; line-height: 1.45; color: var(--text); }
.draft-why { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }
.checks { display: flex; gap: 6px; }
.check { font-size: 10.5px; color: var(--ok); font-family: var(--font-mono); }
.check.bad { color: var(--bad); }
.sendbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: grid; grid-auto-flow: column; background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { height: 30px; border-radius: 9px; font-size: 12.5px; color: var(--text-3); }
.seg button.on { background: var(--ink-4); color: var(--text); }

/* Onboarding */
.ob-progress { display: flex; gap: 4px; }
.ob-progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--ink-4); }
.ob-progress i.on { background: var(--accent); }
.promise { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink-2); cursor: pointer; }
.promise input { width: 18px; height: 18px; accent-color: var(--accent-strong); margin-top: 2px; }
.promise b { font-weight: 500; display: block; font-size: 14px; margin-bottom: 2px; }
.promise span { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.msg-agent, .msg-me { padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.45; max-width: 90%; }
.msg-agent { background: var(--ink-3); align-self: flex-start; }
.msg-me { background: var(--accent-soft); border: 1px solid var(--accent-line); align-self: flex-end; }
.msg-ack { font-size: 12px; color: var(--ok); align-self: flex-start; padding-left: 4px; }
.tier { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--ink-2); text-align: left; width: 100%; }
.tier.on { border-color: var(--accent); background: var(--accent-soft); }
.cal-photo { border-radius: 18px; overflow: hidden; aspect-ratio: 4/4.4; position: relative; background: #222; }
.cal-photo img { width: 100%; height: 100%; object-fit: cover; }
.cal-photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 14px 12px; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.cal-photo .cap h3 { font-size: 22px; font-weight: 600; }
.guess { position: absolute; top: 10px; left: 10px; font-size: 11.5px; background: rgba(0,0,0,.55); padding: 4px 9px; border-radius: 999px; backdrop-filter: blur(6px); }

/* Memory */
.fact { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact button { color: var(--text-4); font-size: 16px; line-height: 1; }
.fact button:hover { color: var(--bad); }

/* ---------- Dev panel ---------- */
.devpanel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dev-card { background: var(--ink-1); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.dev-card h3 { font-size: 13px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 400; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.dev-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dev-stat { background: var(--ink-2); border-radius: 10px; padding: 10px; }
.dev-stat b { display: block; font-size: 18px; font-weight: 500; }
.dev-stat small { color: var(--text-3); font-size: 11.5px; }
.dev-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.log { max-height: 320px; overflow-y: auto; font-family: var(--font-mono); font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.log-row { display: grid; grid-template-columns: 64px 56px 1fr; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.log-row:hover { background: var(--ink-2); }
.log-row .k { color: var(--text-3); }
.log-row.LIKE .k, .log-row.match .k, .log-row.sent .k { color: var(--ok); }
.log-row.PASS .k { color: var(--text-4); }
.log-row.REVIEW .k, .log-row.alert .k { color: var(--warn); }
.log-row.error .k { color: var(--bad); }
.log-row .why { color: var(--text-3); }
table.dev { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.dev th { text-align: left; font-weight: 400; color: var(--text-3); padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.dev td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.speed { display: flex; gap: 4px; }
.speed button { height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong); font-size: 12px; font-family: var(--font-mono); }
.speed button.on { background: var(--accent-soft); border-color: var(--accent-line); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink-3); border: 1px solid var(--line-strong); padding: 10px 16px; border-radius: 12px; font-size: 13.5px; z-index: 50; max-width: 90vw; }

@media (max-width: 980px) {
  .stage { grid-template-columns: 1fr; }
  .device { position: static; margin: 0 auto; width: min(404px, 100%); }
}
@media (max-width: 480px) {
  .stage { padding: 0; }
  .device { border-radius: 0; padding: 0; box-shadow: none; background: none; }
  .screen { border-radius: 0; height: calc(100vh - 56px); }
  .statusbar { display: none; }
  .webview { top: 0; }
  .topbar-links .btn:not(:first-child) { display: none; }
}
.tabbar[hidden] { display: none; }
.view > * { flex-shrink: 0; }
.pill-status.bad { background: var(--bad-soft); color: var(--bad); }

/* Inside the LoveDesk phone app (?shell=app): full screen, no device frame, no dev panel. */
body.shell .topbar, body.shell .devpanel, body.shell .statusbar, body.shell .webview { display: none !important; }
body.shell .stage { display: block; padding: 0; max-width: none; margin: 0; }
body.shell .device { width: 100%; border-radius: 0; padding: 0; position: static; background: none; box-shadow: none; }
body.shell .screen { height: 100vh; height: 100dvh; border-radius: 0; border: 0; }
body.shell .view { padding-top: 14px; }
