/* safearly.com/saaf/playground: builds on styles.css tokens. */

.pg { padding: 40px 0 72px; }
.pg-intro { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.pg-intro h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); }
.pg-intro .lead { max-width: 640px; margin-top: 12px; }
.trust { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.trust li { display: flex; align-items: center; gap: 8px; }
.trust svg { width: 16px; height: 16px; color: var(--green); flex: none; }

.pg-tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.pg-tabs button { font: 500 0.95rem var(--font); border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 99px; padding: 10px 18px; cursor: pointer; white-space: nowrap; }
.pg-tabs button[aria-selected="true"] { background: var(--green-tint); color: var(--green); border-color: transparent; }

.pg-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .pg-grid { grid-template-columns: 1fr; } }
.side { display: grid; gap: 16px; }
@media (min-width: 901px) { .side { position: sticky; top: 80px; } }
.main-col { display: grid; gap: 16px; min-width: 0; padding: 0; }
.main-col[hidden] { display: none; }

.card { background: var(--tint); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-h { font-size: 1rem; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 12px; }
.fld { display: grid; gap: 6px; font-size: 0.86rem; font-weight: 500; color: var(--muted); margin-bottom: 12px; }
.fld output { font: 500 0.86rem var(--mono); color: var(--text); }
.fld input:not([type="range"]):not([type="file"]), .fld select {
  width: 100%; font: 400 0.92rem var(--font); color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; min-width: 0;
}
.fld input[type="file"] { font: 400 0.85rem var(--font); color: var(--muted); max-width: 100%; }
.fld input:focus, .fld select:focus { border-color: var(--green); outline: none; }
.fld input[type="range"] { width: 100%; accent-color: var(--green); }
.key { display: flex; gap: 6px; }
.key input { flex: 1; }
.mini { flex: none; width: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.mini svg { width: 18px; height: 18px; }
.mini[aria-pressed="true"] { color: var(--green); border-color: var(--green); }
.hint { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.hint.warn { color: var(--text); background: var(--saffron-tint); border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
.hint code { font-size: 0.78rem; background: var(--tint-2); border-radius: 6px; padding: 1px 5px; }
.btn.sm { height: 38px; padding: 0 16px; font-size: 0.9rem; }
.btn.sm svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-col { display: grid; gap: 8px; margin: 12px 0; }
.link-btn { font: 500 0.88rem var(--font); background: none; border: 0; padding: 0; color: var(--green); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.ents-box summary { cursor: pointer; font-size: 0.88rem; font-weight: 500; color: var(--text); padding: 4px 0; }
.ent-rules { display: grid; gap: 4px; margin-top: 8px; max-height: 320px; overflow-y: auto; padding-right: 4px; }
.ent-rule { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; font-size: 0.84rem; }
.ent-rule select { font: 400 0.8rem var(--font); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; }
.ent-rule .sev { font-size: 0.7rem; color: var(--muted); margin-left: 4px; }

.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: 0.86rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font: 500 0.86rem var(--mono); text-align: right; }
.stats.wide { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0 12px; }
.stats.wide div { background: var(--bg); border-radius: 14px; padding: 10px 14px; }
.stats.wide dd { text-align: left; font-size: 1.05rem; }

/* Thread */
.thread-card { display: flex; flex-direction: column; gap: 12px; }
.thread-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.thread-head .seg { align-items: center; }
.thread { display: flex; flex-direction: column; gap: 12px; min-height: 220px; max-height: 62vh; overflow-y: auto; padding: 4px 2px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 420px; font-size: 0.95rem; }
.empty strong { color: var(--text); font-weight: 500; }
.bubble { max-width: 88%; border-radius: 20px; padding: 12px 16px; background: var(--bg); white-space: pre-wrap; word-break: break-word; font-size: 0.95rem; line-height: 1.6; }
.bubble.user { align-self: flex-end; background: var(--green-tint); border-bottom-right-radius: 6px; }
.bubble.bot { align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font: 500 0.72rem var(--font); color: var(--muted); }
.bubble .meta span { background: var(--tint); border-radius: 99px; padding: 2px 8px; }
.bubble.user .meta span { background: var(--bg); }
.bubble.err { background: var(--saffron-tint); }
.bubble.blocked { background: var(--saffron-tint); }
.bubble mark { background: var(--saffron-tint); color: var(--text); border-radius: 4px; padding: 0 2px; }
.bubble.user mark { background: var(--bg); }
.bubble .tk { font-family: var(--mono); font-size: 0.86em; background: var(--green); color: var(--on-green); border-radius: 5px; padding: 0 4px; }
.bubble .rv { border-bottom: 2px solid var(--green); }
.who { font: 500 0.72rem var(--font); color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.cursor::after { content: "▍"; color: var(--green); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor::after { animation: none; } }
.view-model .bubble.user { background: var(--bg); border: 1px dashed var(--green); }

/* Composer */
.composer { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.samples { gap: 6px; }
.msg-box { display: grid; gap: 8px; }
.msg-box textarea { width: 100%; font: 0.95rem/1.6 var(--font); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; resize: vertical; min-height: 96px; }
.msg-box textarea:focus { border-color: var(--green); outline: none; }
.preview { font: 0.88rem/1.65 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--muted); padding: 0 4px; }
.preview:empty { display: none; }
.preview mark { background: var(--saffron-tint); color: var(--text); border-radius: 4px; padding: 0 2px; }
.preview mark small { font: 500 0.62rem var(--font); color: var(--violet); margin-left: 4px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Why table */
.why { font-size: 0.88rem; }
.why td, .why th { padding: 10px 14px; }
.why code { font-size: 0.84rem; }
.ok { color: var(--green); font-weight: 500; }

/* Files */
.drop { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 32px 16px; margin-top: 16px; border: 2px dashed var(--line); border-radius: 20px; background: var(--bg); cursor: pointer; transition: border-color 0.15s ease; }
.drop:hover, .drop.over { border-color: var(--green); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop svg { width: 28px; height: 28px; color: var(--green); }
.progress { height: 8px; border-radius: 99px; background: var(--tint-2); overflow: hidden; margin-top: 16px; }
.bar-in { height: 100%; width: 0; background: var(--green); transition: width 0.1s linear; }
.code-out { width: 100%; margin: 8px 0 16px; font: 0.82rem/1.6 var(--mono); background: var(--bg); border-radius: 16px; padding: 14px; max-height: 360px; overflow: auto; white-space: pre; }
.restore-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.pg-foot { margin-top: 32px; }

/* Phones: model picker, then the chat, then policy and session. */
@media (max-width: 900px) {
  .side { display: contents; }
  #model-card { order: 0; }
  .main-col { order: 1; }
  .side > .card:not(#model-card) { order: 2; }
}
