/* ─── Friday floating launcher ───────────────────────────────────────────── */
.friday {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  font-family: var(--font);
}

.friday-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.friday-toggle:hover {
  transform: translateY(-1px);
  background: var(--bg-elev);
  border-color: var(--accent);
}

.friday-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: friday-pulse 2s ease-in-out infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes friday-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}

/* ─── Friday panel ───────────────────────────────────────────────────────── */
.friday-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(440px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 120px));
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.7);
  animation: friday-pop 180ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: bottom right;
}

/* Critical: the `hidden` attribute is overridden by `.friday-panel { display: flex }`
   without this rule, so the X close button appears to do nothing. */
.friday-panel[hidden] {
  display: none;
}

@keyframes friday-pop {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Full-screen on mobile */
@media (max-width: 560px) {
  .friday-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    border: none;
  }
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.friday-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  gap: 12px;
  flex-shrink: 0;   /* never let header collapse */
}

.friday-head-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.friday-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.friday-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.friday-sub {
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.friday-head-actions {
  display: flex;
  gap: 4px;
}

.friday-icon-btn {
  background: transparent;
  color: var(--fg-muted);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.friday-icon-btn:hover {
  background: var(--bg);
  color: var(--fg);
}
.friday-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Messages ───────────────────────────────────────────────────────────── */
.friday-messages {
  flex: 1 1 0;
  min-height: 0;     /* critical: lets the flex child actually shrink + scroll
                        instead of pushing siblings (form) out of view */
  overflow-y: auto;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.friday-messages::-webkit-scrollbar { width: 8px; }
.friday-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.friday-messages::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

.friday-msg {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 92%;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: msg-in 160ms ease-out;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.friday-msg.user {
  background: var(--accent);
  color: var(--bg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.friday-msg.friday {
  background: var(--bg-elev-2);
  color: var(--fg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.friday-msg.error {
  background: rgba(255, 91, 107, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 91, 107, 0.3);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.friday-msg.system {
  background: transparent;
  color: var(--fg-muted);
  font-size: 12px;
  text-align: center;
  align-self: center;
  padding: 4px 10px;
  font-style: italic;
}

/* Thinking dots */
.friday-msg.thinking {
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.friday-msg.thinking::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 4px;
  background-image: radial-gradient(circle, var(--fg-muted) 1.5px, transparent 1.5px);
  background-size: 8px 4px;
  background-repeat: repeat-x;
  animation: thinking-dots 1.2s linear infinite;
}
@keyframes thinking-dots {
  0%   { opacity: 0.3; }
  50%  { opacity: 1; }
  100% { opacity: 0.3; }
}

/* Friday's first welcome */
.friday-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 16px 16px;
  gap: 12px;
  margin: 0 auto;
  max-width: 320px;
}
.friday-welcome-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.friday-welcome-avatar .friday-dot {
  width: 14px;
  height: 14px;
}
.friday-welcome-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
}
.friday-welcome-sub {
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.5;
}
.friday-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}
.friday-suggestion {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease;
}
.friday-suggestion:hover {
  background: var(--bg);
  border-color: var(--accent);
}

/* ─── Composer ───────────────────────────────────────────────────────────── */
.friday-form {
  display: flex;
  gap: 8px;
  padding: 12px var(--pad);
  border-top: 1px solid var(--border);
  background: var(--bg-elev-2);
  align-items: center;
  flex-shrink: 0;   /* never let composer collapse */
}
.friday-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  transition: border-color 120ms ease;
}
.friday-form input:focus {
  border-color: var(--accent);
  outline: none;
}
.friday-form button {
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.friday-form button:disabled { opacity: 0.4; }

/* ─── Phase 2.5 — Friday tool-call cards ─────────────────────────────── */
.friday-tool-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
  font-size: 12px;
  align-self: stretch;
  max-width: 100%;
}
.friday-tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, monospace;
}
.friday-tool-icon { font-size: 13px; opacity: 0.7; flex-shrink: 0; }
.friday-tool-name { font-weight: 600; color: var(--fg); flex: 1; }
.friday-tool-status {
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: lowercase;
}
.friday-tool-status.done { color: var(--accent, #00d97e); }
.friday-tool-status.failed, .friday-tool-status.denied { color: var(--danger, #ff5b6b); }
.friday-tool-status.running…, .friday-tool-status[class*="awaiting"] { color: var(--warn, #ffa500); }

.friday-tool-args, .friday-tool-result {
  margin-top: 6px;
  font-size: 11px;
}
.friday-tool-args summary, .friday-tool-result summary {
  cursor: pointer;
  color: var(--fg-muted);
  font-family: ui-monospace, monospace;
  padding: 2px 0;
}
.friday-tool-args summary:hover, .friday-tool-result summary:hover { color: var(--fg); }
.friday-tool-args pre, .friday-tool-result pre {
  margin: 4px 0 0;
  padding: 6px 8px;
  background: var(--bg-elev);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  color: var(--fg);
}
.friday-tool-error {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(255, 91, 107, 0.1);
  color: var(--danger, #ff5b6b);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
}

.friday-tool-confirm {
  margin-top: 8px;
  padding: 10px;
  background: rgba(255, 165, 0, 0.08);
  border: 1px solid rgba(255, 165, 0, 0.3);
  border-radius: 6px;
}
.friday-confirm-text { font-size: 12px; line-height: 1.5; margin-bottom: 8px; }
.friday-confirm-actions { display: flex; gap: 6px; justify-content: flex-end; }
.friday-confirm-actions .btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.friday-confirm-actions .btn-sm:hover { border-color: var(--accent, #00d97e); }
.friday-confirm-actions .btn-sm.btn-danger {
  background: rgba(255, 91, 107, 0.15);
  border-color: rgba(255, 91, 107, 0.4);
  color: var(--danger, #ff5b6b);
}
.friday-confirm-actions .btn-sm.btn-danger:hover { background: rgba(255, 91, 107, 0.25); }
