/* Wren: Hollowmead's example AI assistant (ivy and brass, hairline detail) */

.wr-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Launcher ---------- */
.wr-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 60px;
  padding: 8px 22px 8px 8px;
  border: 1px solid rgba(210, 181, 126, .45); border-radius: 999px;
  background: var(--ivy, #1E5B4F); color: #FBF8F2;
  font-family: var(--sans, system-ui, sans-serif);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 18px 40px -16px rgba(15, 47, 41, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .3s var(--ease, ease), background-color .3s var(--ease, ease), opacity .2s, visibility .2s;
}
.wr-launcher img { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.wr-launcher__text { display: flex; flex-direction: column; line-height: 1.15; }
.wr-launcher__name { font-family: var(--serif, Georgia, serif); font-size: 1.125rem; letter-spacing: .01em; }
.wr-launcher__sub { margin-top: 3px; font-size: .625rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: #D2B57E; }
.wr-launcher:hover { transform: translateY(-2px); background: var(--ivy-deep, #143F37); }
.wr-launcher:focus-visible { outline: 3px solid var(--brass, #B08A4A); outline-offset: 4px; }
.wr-is-open .wr-launcher { opacity: 0; visibility: hidden; pointer-events: none; transform: scale(.92); }
@media (max-width: 600px) {
  .wr-launcher { right: 14px; bottom: 14px; min-height: 54px; padding: 6px 16px 6px 6px; }
  .wr-launcher img { width: 40px; height: 40px; }
  .wr-launcher__sub { display: none; }
}

/* ---------- Panel ---------- */
.wr-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 70;
  width: min(410px, calc(100vw - 32px));
  height: min(660px, calc(100vh - 48px));
  height: min(660px, calc(100dvh - 48px));
  display: flex; flex-direction: column;
  background: var(--paper, #F7F4EE);
  border: 1px solid var(--line-strong, rgba(27, 38, 35, .18));
  border-radius: 20px;
  box-shadow: 0 40px 90px -30px rgba(15, 47, 41, .5), 0 2px 6px rgba(15, 47, 41, .08);
  overflow: hidden;
  font-family: var(--sans, system-ui, sans-serif);
  color: var(--ink, #1B2623);
  opacity: 0; transform: translateY(16px) scale(.98); transform-origin: bottom right;
  transition: opacity .28s var(--ease, ease), transform .32s var(--ease, ease);
}
.wr-panel[hidden] { display: none; }
.wr-panel.is-open { opacity: 1; transform: none; }

.wr-head {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 10px 14px 16px;
  background: var(--ivy, #1E5B4F); color: #FBF8F2;
}
.wr-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--brass, #B08A4A), #D2B57E 60%, transparent);
}
.wr-avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(210, 181, 126, .5); }
.wr-title { flex: 1; min-width: 0; }
.wr-title h2 { margin: 0; font-family: var(--serif, Georgia, serif); font-size: 1.375rem; font-weight: 400; line-height: 1.1; color: #FBF8F2; }
.wr-title p { margin: 3px 0 0; font-size: .6875rem; letter-spacing: .14em; text-transform: uppercase; color: #D2B57E; }
.wr-icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: #FBF8F2;
  cursor: pointer;
  transition: background-color .2s;
}
.wr-icon-btn svg { width: 20px; height: 20px; }
.wr-icon-btn:hover { background: rgba(255, 255, 255, .12); }
.wr-icon-btn:focus-visible { outline: 2px solid #D2B57E; outline-offset: -2px; }

/* ---------- Log ---------- */
.wr-log {
  flex: 1; overflow-y: auto;
  padding: 20px 16px 10px;
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 100% 0, rgba(176, 138, 74, .07), transparent 40%),
    var(--paper, #F7F4EE);
}
.wr-log:focus-visible { outline: 2px solid var(--ivy, #1E5B4F); outline-offset: -3px; }
.wr-msg {
  max-width: 88%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: .9375rem; line-height: 1.55;
  overflow-wrap: anywhere;
}
@media (prefers-reduced-motion: no-preference) {
  .wr-msg { animation: wr-rise .32s var(--ease, ease) both; }
  @keyframes wr-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
.wr-msg p { margin: 0; }
.wr-msg p + p, .wr-msg p + ul, .wr-msg ul + p, .wr-msg dl + p, .wr-msg p + dl { margin-top: 8px; }
.wr-msg ul { margin: 6px 0 0; padding-left: 18px; }
.wr-msg li + li { margin-top: 4px; }
.wr-msg a { color: var(--ivy, #1E5B4F); font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.wr-msg a:focus-visible { outline: 2px solid var(--ivy, #1E5B4F); outline-offset: 2px; border-radius: 2px; }
.wr-msg--bot { align-self: flex-start; background: #FFFFFF; border: 1px solid var(--line, rgba(27, 38, 35, .1)); border-bottom-left-radius: 4px; }
.wr-msg--user { align-self: flex-end; background: var(--ivy, #1E5B4F); color: #FBF8F2; border-bottom-right-radius: 4px; }
.wr-msg--note { background: var(--stone, #EDE7DB); border-color: transparent; font-size: .8125rem; color: var(--ink-soft, #44524E); }
/* Safety messages stay clearly distinct */
.wr-alert { background: #FBEDE6; border: 1px solid #C98A72; color: #4F1D10; }
.wr-alert a { color: #7A2A15; }
.wr-care { background: #EEF3EF; border-color: #B9CFC5; }

.wr-summary { margin: 8px 0 0; padding: 10px 12px; border: 1px solid rgba(176, 138, 74, .45); border-radius: 10px; background: #FBF8F2; }
.wr-summary div { display: grid; grid-template-columns: 7.2em 1fr; gap: 8px; padding: 4px 0; }
.wr-summary div + div { border-top: 1px dashed rgba(27, 38, 35, .12); }
.wr-summary dt { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brass-ink, #8C6A33); padding-top: 2px; }
.wr-summary dd { margin: 0; font-size: .875rem; }

.wr-typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 14px 16px; background: #FFFFFF; border: 1px solid var(--line, rgba(27, 38, 35, .1)); border-radius: 16px; border-bottom-left-radius: 4px; }
.wr-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ivy, #1E5B4F); opacity: .45; }
@media (prefers-reduced-motion: no-preference) {
  .wr-typing span { animation: wr-dot 1s infinite ease-in-out; }
  .wr-typing span:nth-child(2) { animation-delay: .15s; }
  .wr-typing span:nth-child(3) { animation-delay: .3s; }
  @keyframes wr-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
}

/* ---------- Chips ---------- */
.wr-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 12px; max-height: 136px; overflow-y: auto; }
.wr-chips:empty { display: none; }
.wr-chip {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--ivy, #1E5B4F);
  border-radius: 999px;
  background: #FFFFFF;
  color: var(--ivy, #1E5B4F);
  font: 500 .8125rem/1.2 var(--sans, system-ui, sans-serif);
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}
@media (prefers-reduced-motion: no-preference) {
  .wr-chip { animation: wr-rise .3s var(--ease, ease) both; }
}
.wr-chip:hover { background: var(--ivy, #1E5B4F); color: #FBF8F2; }
.wr-chip:focus-visible { outline: 2px solid var(--brass, #B08A4A); outline-offset: 2px; }
.wr-chip--quiet { border-color: rgba(27, 38, 35, .25); color: var(--ink-soft, #44524E); background: transparent; }
.wr-chip--quiet:hover { background: var(--stone, #EDE7DB); color: var(--ink, #1B2623); }

/* ---------- Input ---------- */
.wr-form { display: flex; gap: 8px; padding: 12px 12px 8px 14px; border-top: 1px solid var(--line, rgba(27, 38, 35, .1)); background: #FFFFFF; }
.wr-input {
  flex: 1; min-width: 0; min-height: 46px;
  padding: 10px 16px;
  border: 1px solid rgba(27, 38, 35, .2); border-radius: 999px;
  background: var(--paper, #F7F4EE); color: var(--ink, #1B2623);
  font: 1rem/1.3 var(--sans, system-ui, sans-serif);
}
.wr-input::placeholder { color: #6E7A76; }
.wr-input:focus { outline: none; border-color: var(--ivy, #1E5B4F); box-shadow: 0 0 0 3px rgba(30, 91, 79, .18); background: #FFFFFF; }
.wr-send {
  width: 46px; height: 46px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--ivy, #1E5B4F); color: #FBF8F2;
  cursor: pointer; transition: background-color .2s;
}
.wr-send svg { width: 20px; height: 20px; }
.wr-send:hover { background: var(--ivy-deep, #143F37); }
.wr-send:focus-visible { outline: 3px solid var(--brass, #B08A4A); outline-offset: 2px; }
.wr-foot { margin: 0; padding: 0 16px 12px; background: #FFFFFF; font-size: .75rem; line-height: 1.45; color: var(--muted, #5E6A66); }

@media (max-width: 600px) {
  .wr-panel { inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
  .wr-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .wr-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .wr-is-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .wr-panel, .wr-launcher { transition: none; }
}
