/* ---------- BLCK.CHAT terminal console ---------- */

html, body.pchat-lock-scroll {
  overflow: hidden;
  height: 100%;
}

.pchat-app {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  margin: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: var(--pchat-bg, #000);
  color: var(--pchat-fg, #00ff66);
  font-family: var(--pchat-font, "SFMono-Regular", Consolas, monospace);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  box-sizing: border-box;
}
.pchat-app *,
.pchat-app *::before,
.pchat-app *::after {
  box-sizing: border-box;
}

/* Fixed accent colors for detected content types -- stay constant so they
   read as distinct categories, not just "the theme color". */
.pchat-app {
  --pchat-link: #4fc3f7;
  --pchat-email: #ffee58;
  --pchat-phone: #ff80ab;
  --pchat-crypto: #b388ff;
  --pchat-dim: rgba(255, 255, 255, 0.35);
  --pchat-danger: #ff4d4d;
}

/* ---------- boot / terminate sequence ---------- */

.pchat-boot {
  flex: 1;
  padding: clamp(14px, 4vw, 28px);
  font-size: clamp(12px, 2.6vw, 15px);
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--pchat-fg);
  overflow-y: auto;
}
.pchat-boot .pchat-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--pchat-fg);
  margin-left: 2px;
  animation: pchat-blink 1s steps(1) infinite;
  vertical-align: text-bottom;
}
@keyframes pchat-blink { 50% { opacity: 0; } }

.pchat-ended {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--pchat-fg);
  font-size: clamp(13px, 3vw, 16px);
}
.pchat-ended .pchat-dim { color: var(--pchat-dim); font-size: 0.85em; margin-top: 6px; }

/* ---------- header ---------- */

.pchat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.pchat-title {
  font-weight: 700;
  letter-spacing: 1px;
  font-size: clamp(12px, 3vw, 14px);
  color: var(--pchat-fg);
}
.pchat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pchat-dim);
  margin-right: auto;
  flex-shrink: 0;
}
.pchat-status-dot.pchat-status-online { background: var(--pchat-fg); }

.pchat-icons {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.pchat-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--pchat-dim);
  background: transparent;
  color: var(--pchat-fg);
  border-radius: 4px;
  cursor: pointer;
}
.pchat-icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.pchat-terminate-btn {
  color: var(--pchat-danger);
  border-color: var(--pchat-danger);
}
.pchat-terminate-btn:hover { background: rgba(255, 77, 77, 0.15); }

/* ---------- settings panel ---------- */

.pchat-panel {
  position: absolute;
  top: 46px;
  right: 8px;
  z-index: 5;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--pchat-fg);
  width: min(240px, 80vw);
}
.pchat-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pchat-panel input[type="text"],
.pchat-panel select {
  background: #000;
  border: 1px solid var(--pchat-dim);
  color: inherit;
  font-family: inherit;
  padding: 5px 6px;
  border-radius: 3px;
}
.pchat-panel input[type="color"] {
  width: 100%;
  height: 28px;
  border: 1px solid var(--pchat-dim);
  background: none;
  padding: 0;
  border-radius: 3px;
}
.pchat-pref-row { display: flex; align-items: center; justify-content: space-between; }
.pchat-presets { display: flex; gap: 6px; }
.pchat-preset-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

/* ---------- log ---------- */

.pchat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px clamp(8px, 3vw, 16px);
  font-size: clamp(13px, 2.4vw, 14px);
  min-height: 0;
}
.pchat-line { margin-bottom: 6px; line-height: 1.5; word-break: break-word; }
.pchat-time { color: var(--pchat-dim); font-size: 11px; margin-right: 6px; }
.pchat-name { color: var(--pchat-dim); }
.pchat-me .pchat-text { color: var(--pchat-fg); }
.pchat-them .pchat-text { color: var(--pchat-fg); opacity: 0.85; }
.pchat-system { opacity: 0.8; }
.pchat-system .pchat-text { color: var(--pchat-dim); font-style: italic; }

.pchat-copyable {
  cursor: pointer;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 1px;
}
.pchat-link   { color: var(--pchat-link); }
.pchat-email  { color: var(--pchat-email); }
.pchat-phone  { color: var(--pchat-phone); }
.pchat-btc,
.pchat-eth    { color: var(--pchat-crypto); }
.pchat-copyable.pchat-copied {
  outline: 1px solid currentColor;
  border-radius: 2px;
}

/* ---------- input ---------- */

.pchat-form {
  display: flex;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}
.pchat-form::before {
  content: ">";
  color: var(--pchat-fg);
  padding: 10px 0 10px 12px;
  font-weight: 700;
}
.pchat-input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 10px 8px;
  font-size: 16px; /* >=16px avoids iOS auto-zoom on focus */
  outline: none;
  background: transparent;
  color: var(--pchat-fg);
  font-family: inherit;
  caret-color: var(--pchat-fg);
}
.pchat-input::placeholder { color: var(--pchat-dim); }
.pchat-form button {
  padding: 10px 16px;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--pchat-fg);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.pchat-form button:hover { background: rgba(255, 255, 255, 0.08); }

/* "minimize" toggles this so the console can be shrunk back into the page
   flow instead of permanently covering the whole viewport. */
.pchat-app.pchat-app-windowed {
  position: relative;
  inset: auto;
  height: 480px;
  max-width: 720px;
  margin: 20px auto;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
}

/* ---------- small screens ---------- */

@media (max-width: 480px) {
  .pchat-icon-btn { width: 34px; height: 34px; }
  .pchat-header { padding: 6px 8px; }
  .pchat-panel { right: 4px; left: 4px; width: auto; }
}
