/* Agent Share — Agentic Live house style (shared with pks-agent-coach):
   near-black canvas, Agentic Orange, mono chrome, soft corner glow. */

:root {
  --bg: #0a0a0a;
  --panel: #141418;
  --panel-2: #1c1c20;
  --fg: #ededef;
  --muted: #a1a1aa;
  --faint: #71717a;
  --hairline: #27272a;

  --orange: #f87f2e;       /* Agentic Orange — never raw tailwind orange */
  --ember: #ffa85e;
  --forge: #d66a1f;
  --orange-12: rgba(248, 127, 46, 0.12);
  --orange-22: rgba(248, 127, 46, 0.22);
  --orange-35: rgba(248, 127, 46, 0.35);

  --success: #34d399;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", "Cascadia Code", monospace;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, "Inter", sans-serif;

  --tabbar-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overscroll-behavior-y: contain;
}

.glow {
  position: fixed;
  top: -220px; left: -220px;
  width: 620px; height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--orange-12) 0%, rgba(248,127,46,0) 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 16px) 20px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 14px;
  border-bottom: 1px solid var(--hairline);
}
.brand { font-family: var(--mono); font-size: 14px; letter-spacing: .02em; color: var(--fg); }
.brand-dot { color: var(--orange); }
.status { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.status.ok { color: var(--success); }
.status.err { color: #f87171; }

/* ---- views ---- */
.view { padding-top: 18px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.hint { color: var(--faint); font-size: 12.5px; line-height: 1.5; margin: 14px 2px 0; }
.hint.nomargin { margin: 2px 0 0; }

/* ---- cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.card-label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 8px; }

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  padding: 12px;
  resize: vertical;
}
.input:focus { outline: none; border-color: var(--orange-35); }

.row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.row.spread { justify-content: space-between; }
.filehint { font-family: var(--mono); font-size: 12px; color: var(--ember); margin-top: 8px; min-height: 14px; }

/* ---- buttons ---- */
.btn { font-family: var(--sans); font-size: 14px; font-weight: 600; border: none; border-radius: 11px; padding: 11px 16px; cursor: pointer; }
.btn-primary { background: var(--orange); color: #1a0f06; margin-left: auto; }
.btn-primary:active { background: var(--forge); }
.btn-ghost { background: var(--panel-2); color: var(--fg); border: 1px solid var(--hairline); }
.btn-block { display: block; width: 100%; margin-top: 12px; }

/* ---- segmented control ---- */
.seg { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--hairline); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg-btn { flex: 1; background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 8px; border-radius: 9px; cursor: pointer; }
.seg-btn.is-active { background: var(--orange-12); color: var(--ember); }

/* ---- timeline list ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--faint); text-align: center; padding: 48px 0; font-size: 14px; }
.item {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.item.to_phone { border-left-color: var(--orange); }
.item.to_agent { border-left-color: #3b82f6; }
.item.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: var(--orange-22); } 100% { background: var(--panel); } }
.item-ico { font-size: 20px; line-height: 1.2; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.item-body { font-size: 13px; color: var(--muted); word-break: break-word; }
.item-body a { color: var(--ember); }
.item img.thumb { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }
.item-meta { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 6px; display: flex; gap: 8px; }
.item-del { background: none; border: none; color: var(--faint); font-size: 16px; cursor: pointer; padding: 2px 4px; }

/* ---- snippet ---- */
.snippet {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ember);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.mono-faint { font-family: var(--mono); font-size: 12px; color: var(--faint); word-break: break-all; }
.recipe { color: var(--muted); font-size: 12.5px; line-height: 1.6; padding-left: 18px; margin: 12px 0 4px; }
.recipe code { font-family: var(--mono); font-size: 11.5px; color: var(--ember); background: var(--bg); padding: 1px 5px; border-radius: 5px; }

/* ---- switch ---- */
.switch { width: 48px; height: 28px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--hairline); position: relative; cursor: pointer; transition: background .15s; }
.switch span { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--faint); transition: transform .15s, background .15s; }
.switch[aria-checked="true"] { background: var(--orange-22); border-color: var(--orange-35); }
.switch[aria-checked="true"] span { transform: translateX(20px); background: var(--orange); }

/* ---- tab bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(10,10,10,.86);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  z-index: 5;
  max-width: 540px; margin: 0 auto;
}
.tab { flex: 1; background: none; border: none; color: var(--faint); font-size: 12px; font-weight: 600; cursor: pointer; }
.tab.is-active { color: var(--orange); }

/* ---- setup guide sheet ---- */
.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
/* the [hidden] attribute must win over display:flex */
.sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%; max-width: 540px;
  max-height: 92dvh;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column;
  animation: sheetup .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--hairline);
}
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-x { background: var(--panel-2); border: 1px solid var(--hairline); color: var(--fg); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.sheet-body { padding: 18px 20px calc(env(safe-area-inset-bottom) + 24px); overflow-y: auto; }

.guide-intro { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 18px; }
.guide-done { color: var(--success); font-size: 13.5px; line-height: 1.5; margin: 18px 0 0; padding: 12px 14px; background: rgba(52,211,153,.08); border: 1px solid rgba(52,211,153,.25); border-radius: 12px; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step .num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--orange-12); color: var(--ember);
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  display: grid; place-items: center; margin-top: 1px;
}
.step > div { font-size: 14px; line-height: 1.5; color: var(--fg); }
.step code { font-family: var(--mono); font-size: 12px; color: var(--ember); background: var(--panel); padding: 1px 6px; border-radius: 5px; }

.field {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 8px 8px 8px 12px;
}
.field code {
  flex: 1; min-width: 0; background: none; padding: 0;
  font-size: 11.5px; color: var(--ember);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mini { flex: none; background: var(--orange); color: #1a0f06; border: none; border-radius: 8px; padding: 7px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--hairline); color: var(--fg);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 20;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---- auth gate (federated mode) ---- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.gate-card {
  width: 100%; max-width: 360px;
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: 18px; padding: 30px 22px; text-align: center;
}
.gate-brand { font-family: var(--mono); font-size: 18px; letter-spacing: .02em; color: var(--fg); margin-bottom: 20px; }
.gate-brand .brand-dot { color: var(--orange); }
.gate-lede { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 22px; }
.gate .btn-block { text-align: center; text-decoration: none; margin-top: 0; }
.gate .btn-primary { margin-left: 0; }
