/* ice-stories.css */
/* Only #ice. A text conversation, not a dashboard inside a phone. */
.ice .story-demo {
  --story-body: 14px;
  --story-small: 12px;
  --story-line: color-mix(in srgb, var(--message-text) 16%, transparent);
  width: 100%;
  min-width: 0;
  color: var(--message-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--story-body);
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
}

.ice .story-phone {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--new-chat-height, 650px);
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--story-line);
  border-radius: 28px;
  background: var(--surface);
}

.ice .story-phone .contact-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  padding: 8px 16px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--story-line);
  border-radius: 0;
}
.ice .story-phone .contact-header::before { content: none; }
.ice .story-phone .contact-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  text-align: center;
  font-family: inherit;
}
.ice .story-phone .contact-header img { width: 32px; height: 32px; border-radius: 50%; }
.ice .story-phone .contact-name { font-family: inherit; font-size: var(--story-body); font-weight: 500; line-height: 1.2; }
.ice .story-phone .contact-detail { margin-top: 2px; color: var(--muted); font-size: var(--story-small); line-height: 1.2; }

.ice .story-log {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
  padding: 14px 14px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--story-line) transparent;
  -webkit-overflow-scrolling: touch;
}
.ice .story-log::-webkit-scrollbar { width: 4px; }
.ice .story-log::-webkit-scrollbar-thumb { background: var(--story-line); border-radius: 4px; }
.ice .story-time { flex: 0 0 auto; margin: 0 0 16px; text-align: center; color: var(--muted); font-size: var(--story-small); font-weight: 400; }

.ice .story-message {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  min-width: 0;
  margin-top: 10px;
  animation: story-message-in 180ms ease-out both;
}
.ice .story-instant { animation: none; }
.ice .story-grouped { margin-top: 4px; }
.ice .story-out { align-items: flex-end; transform-origin: bottom right; }
.ice .story-in { align-items: flex-start; transform-origin: bottom left; }
.ice .story-bubble {
  display: block;
  width: fit-content;
  max-width: 84%;
  min-width: 0;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 17px 17px 17px 5px;
  color: var(--message-text);
  background: var(--message-in);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--story-body);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-align: left;
  text-wrap: pretty;
}
.ice .story-out .story-bubble { color: #fff; background: var(--message-out); border-radius: 17px 17px 5px 17px; }
.ice .story-delivered { display: block; margin-top: 3px; padding-right: 4px; color: var(--muted); font-size: var(--story-small); line-height: 1.2; font-weight: 400; }
.ice .story-photo {
  display: block;
  width: 220px;
  height: 120px;
  max-width: 80%;
  max-height: 120px;
  margin: 0;
  border-radius: 16px;
  object-fit: contain;
  background: #fff;
}
.ice .story-photo-card { width: 100px; object-fit: contain; }
.ice .story-photo-tv { width: 210px; }
.ice .story-photo-fallback { max-width: 80%; margin: 0; padding: 12px; border-radius: 16px; background: var(--surface-soft); font-size: var(--story-body); }

.ice .story-typing {
  display: flex;
  flex: 0 0 auto;
  align-self: flex-start;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 17px 17px 17px 5px;
  background: var(--message-in);
}
.ice .story-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: story-typing-pulse 1000ms ease-in-out infinite; }
.ice .story-typing span:nth-child(2) { animation-delay: 120ms; }
.ice .story-typing span:nth-child(3) { animation-delay: 240ms; }
.ice .story-paused .story-typing span { animation-play-state: paused; }

.ice .story-composer {
  flex: 0 0 auto;
  min-height: 64px;
  padding: 8px 12px 12px;
  background: var(--surface);
}
.ice .story-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding-left: 12px;
  border: 1px solid var(--story-line);
  border-radius: 24px;
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.ice .story-input-wrap:focus-within { border-color: var(--message-link); box-shadow: 0 0 0 1px var(--message-link); }
.ice .story-draft {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  color: var(--message-text);
  background: transparent;
  font: inherit;
  font-size: var(--story-body);
  font-weight: 400;
}
.ice .story-draft::placeholder { color: var(--muted); opacity: 1; }
.ice .story-draft:disabled { cursor: default; opacity: .7; }
.ice .story-send {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  cursor: pointer;
}
.ice .story-send span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--message-out); font-family: inherit; font-size: 23px; line-height: 1; font-weight: 400; }
.ice .story-send:disabled { cursor: default; }
.ice .story-send:disabled span { background: var(--surface-soft); color: var(--muted); }

.ice .story-reply-area {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  height: 94px;
  padding: 10px 0 0;
}
.ice .story-reply-prompt { margin: 0; font-size: var(--story-small); font-weight: 400; line-height: 1.3; color: var(--muted); }
.ice .story-replies { display: flex; flex-wrap: nowrap; gap: 6px; min-width: 0; }
.ice .story-reply {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  margin: 0;
  border: 1px solid var(--story-line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--message-link);
  font: inherit;
  font-size: var(--story-body);
  font-weight: 400;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.ice .story-reply:hover, .ice .story-reply[aria-pressed="true"] { background: var(--surface-soft); border-color: var(--message-link); }
.ice .story-feedback { min-height: 0; margin: 0; font-size: var(--story-small); font-weight: 400; line-height: 1.3; color: var(--message-link); }
.ice .story-feedback:empty { display: none; }
.ice .story-reply-area:has(.story-feedback:not(:empty)) { height: auto; min-height: 94px; }

.ice .story-tools {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0 4px;
  min-width: 0;
  min-height: 44px;
  font-size: var(--story-small);
  line-height: 1.3;
}
.ice .story-status { margin-right: auto; color: var(--muted); font-weight: 400; }
.ice .story-tools > button {
  min-width: 44px;
  min-height: 44px;
  padding: 10px 6px;
  border: 0;
  border-radius: 8px;
  color: var(--message-link);
  background: transparent;
  font-family: inherit;
  font-size: var(--story-small);
  font-weight: 400;
  line-height: 24px;
  cursor: pointer;
}
.ice .story-tools > button:hover { background: var(--surface-soft); }
.ice .story-tools > button:disabled { color: var(--muted); opacity: .65; cursor: default; }
.ice .story-demo :is(button, input, [tabindex]):focus-visible { outline: 2px solid var(--message-link); outline-offset: 2px; }
.ice .story-log:focus-visible { outline-offset: -3px; }
/* Keep keyboard focus visible on the whole pill, never as a nested rectangle. */
.ice .story-demo .story-draft:focus-visible { outline: none; border-radius: 0; }
.ice .story-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes story-message-in {
  from { opacity: 0; transform: scale(.985); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes story-typing-pulse {
  0%, 70%, 100% { opacity: .45; }
  35% { opacity: 1; }
}
@media (max-width: 390px) {
  .ice .story-log { padding-inline: 12px; }
  .ice .story-bubble { max-width: 84%; }
  .ice .story-reply { padding-inline: 6px; }
  .ice .story-tools { gap: 0; }
  .ice .story-tools > button { padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .ice .story-message, .ice .story-typing span { animation: none; }
  .ice .story-demo * { scroll-behavior: auto; transition: none; }
}

