/* Motion Graphic Studio — Editorial Precision Light Theme (ui-ux-design-pro) */

:root {
  --studio-font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --studio-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --studio-canvas: #F6F7F6;
  --studio-paper: #FFFFFF;
  --studio-subtle: #EFF2F1;
  --studio-border: rgba(15, 36, 38, 0.10);
  --studio-border-strong: rgba(15, 36, 38, 0.18);

  --studio-ink: #0F2426;
  --studio-ink-muted: #4B5E60;
  --studio-ink-faint: #758789;

  --studio-primary: #00897B;
  --studio-primary-text: #00695F;
  --studio-accent: #32A1A5;
  --studio-highlight: #E7B32B;
  --studio-alert: #C8553D;

  --studio-radius: 10px;
  --studio-radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--studio-font-sans);
  background: var(--studio-canvas);
  color: var(--studio-ink);
  -webkit-font-smoothing: antialiased;
}

.font-mono-data {
  font-family: var(--studio-font-mono);
  font-variant-numeric: tabular-nums;
}

.studio-card {
  background: var(--studio-paper);
  border: 1px solid var(--studio-border);
  border-radius: var(--studio-radius);
}

.studio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.5rem 0.9rem;
  border-radius: var(--studio-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 80ms ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.studio-btn:active {
  transform: scale(0.99);
}

.studio-btn:disabled,
.studio-input:disabled,
.studio-select:disabled,
.studio-textarea:disabled {
  opacity: 0.48;
  cursor: not-allowed !important;
  pointer-events: none;
  filter: grayscale(15%);
}

.studio-btn-primary {
  background: var(--studio-primary);
  color: #FFFFFF;
}

.studio-btn-primary:hover {
  filter: brightness(0.92);
}

.studio-btn-secondary {
  background: var(--studio-paper);
  color: var(--studio-ink);
  border-color: var(--studio-border-strong);
}

.studio-btn-secondary:hover {
  background: var(--studio-subtle);
}

.studio-btn-danger {
  background: #FFF5F3;
  color: var(--studio-alert);
  border-color: rgba(200, 85, 61, 0.25);
}

.studio-btn-danger:hover {
  background: #FCE6E2;
}

.studio-input, .studio-select, .studio-textarea {
  width: 100%;
  background: var(--studio-paper);
  color: var(--studio-ink);
  border: 1px solid var(--studio-border-strong);
  border-radius: var(--studio-radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  min-height: 40px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.studio-input:focus, .studio-select:focus, .studio-textarea:focus {
  outline: none;
  border-color: var(--studio-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--studio-primary) 16%, transparent);
}

.studio-textarea {
  resize: vertical;
  min-height: 44px;
  max-height: 45vh;
  line-height: 1.5;
}

/* Editorial Chat Bubbles (ui-ux-design-pro) */
.chat-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.chat-row-user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 2px;
}

.chat-avatar-assistant {
  background: color-mix(in srgb, var(--studio-primary) 12%, #FFFFFF);
  color: var(--studio-primary-text);
  border: 1px solid color-mix(in srgb, var(--studio-primary) 24%, transparent);
}

.chat-avatar-user {
  background: var(--studio-ink);
  color: #FFFFFF;
}

.chat-bubble {
  border-radius: 14px;
  padding: 0.85rem 1.05rem;
  font-size: 0.89rem;
  line-height: 1.62;
  max-width: min(86%, 760px);
  word-break: break-word;
}

.chat-bubble-assistant {
  background: #FFFFFF;
  color: var(--studio-ink);
  border: 1px solid var(--studio-border);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(15, 36, 38, 0.04), 0 4px 12px rgba(15, 36, 38, 0.025);
}

.chat-bubble-user {
  background: linear-gradient(145deg, var(--studio-ink) 0%, color-mix(in srgb, var(--studio-primary) 32%, var(--studio-ink)) 100%);
  color: #F7F9F9;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(15, 36, 38, 0.14);
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(15, 36, 38, 0.06);
  font-size: 0.72rem;
}

.chat-bubble-user .chat-meta {
  border-bottom-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.78);
}

/* Rendered Markdown inside Assistant Bubble */
.chat-prose {
  font-size: 0.875rem;
  line-height: 1.68;
  color: var(--studio-ink);
}
.chat-prose p { margin: 0 0 0.6rem 0; }
.chat-prose p:last-child { margin-bottom: 0; }
.chat-prose h3 {
  font-weight: 700;
  color: var(--studio-ink);
  margin: 1rem 0 0.45rem 0;
  font-size: 0.96rem;
  letter-spacing: -0.015em;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--studio-border);
}
.chat-prose h4, .chat-prose h5 {
  font-weight: 700;
  color: var(--studio-ink);
  margin: 0.9rem 0 0.4rem 0;
  font-size: 0.91rem;
  letter-spacing: -0.01em;
}
.chat-prose h3:first-child, .chat-prose h4:first-child { margin-top: 0.1rem; }
.chat-prose hr.chat-hr {
  border: 0;
  border-top: 1px solid var(--studio-border);
  margin: 0.95rem 0;
}
.chat-prose blockquote.chat-quote {
  margin: 0.65rem 0;
  padding: 0.55rem 0.85rem;
  border-left: 3px solid var(--studio-primary);
  background: color-mix(in srgb, var(--studio-primary) 5%, var(--studio-canvas));
  border-radius: 0 8px 8px 0;
  color: var(--studio-ink-muted);
  font-size: 0.83rem;
}
.chat-prose ul, .chat-prose ol {
  margin: 0.35rem 0 0.65rem 0;
  padding-left: 1.35rem;
}
.chat-prose ul { list-style-type: disc; }
.chat-prose ol { list-style-type: decimal; }
.chat-prose li { margin-bottom: 0.3rem; }
.chat-prose li.chat-subitem {
  list-style-type: circle;
  margin-left: 1.15rem;
  color: var(--studio-ink-muted);
  font-size: 0.84rem;
}
.chat-prose code {
  font-family: var(--studio-font-mono);
  font-size: 0.79em;
  background: var(--studio-subtle);
  color: var(--studio-primary-text);
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  border: 1px solid rgba(15, 36, 38, 0.06);
}
.chat-prose .chat-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  vertical-align: -1px;
  margin-right: 4px;
  border: 1px solid rgba(15, 36, 38, 0.22);
}
.chat-prose .chat-pill-pass {
  background: #E8F5F3;
  color: #005C52;
  border-color: #B4DDD7;
  font-weight: 700;
}
.chat-prose .chat-pill-warn {
  background: #FDECE9;
  color: #9A3320;
  border-color: #F3BFB5;
  font-weight: 700;
}
.chat-prose a.chat-link {
  color: var(--studio-primary-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.chat-prose .chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--studio-font-mono);
  font-size: 0.77em;
  background: var(--studio-canvas);
  color: var(--studio-primary-text);
  border: 1px solid var(--studio-border-strong);
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  font-weight: 500;
}
.chat-prose .chat-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.7rem 0;
  border: 1px solid var(--studio-border);
  border-radius: 8px;
  background: #FFFFFF;
}
.chat-prose table.chat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: left;
}
.chat-prose table.chat-table thead th {
  background: var(--studio-subtle);
  color: var(--studio-ink);
  font-weight: 700;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--studio-border-strong);
  white-space: nowrap;
}
.chat-prose table.chat-table tbody td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--studio-border);
  vertical-align: top;
}
.chat-prose table.chat-table tbody tr:last-child td {
  border-bottom: 0;
}
.chat-prose table.chat-table tbody tr:nth-child(even) {
  background: rgba(246, 247, 246, 0.65);
}
.chat-prose pre {
  font-family: var(--studio-font-mono);
  font-size: 0.78rem;
  background: #0F2426;
  color: #E5E6E5;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.55rem 0;
}
.chat-prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
}
.chat-prose strong { font-weight: 700; color: var(--studio-ink); }
.chat-prose em { font-style: italic; color: var(--studio-ink-muted); }

/* Ask-Question Floating Dock above Composer (Antigravity IDE Style) */
.ask-dock {
  background: #FFFFFF;
  border-top: 2px solid var(--studio-primary);
  box-shadow: 0 -8px 24px rgba(15, 36, 38, 0.08);
  animation: askDockSlideUp 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes askDockSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.ask-opt-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--studio-border-strong);
  background: #FFFFFF;
  color: var(--studio-ink);
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
.ask-opt-btn:hover {
  border-color: var(--studio-primary);
  background: color-mix(in srgb, var(--studio-primary) 4%, #FFFFFF);
}
.ask-opt-btn.is-selected {
  border-color: var(--studio-primary);
  background: color-mix(in srgb, var(--studio-primary) 10%, #FFFFFF);
  box-shadow: 0 0 0 1px var(--studio-primary);
}
.ask-opt-num {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--studio-font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--studio-subtle);
  color: var(--studio-ink-muted);
  margin-top: 1px;
}
.ask-opt-btn.is-selected .ask-opt-num {
  background: var(--studio-primary);
  color: #FFFFFF;
}

/* Typing dots animation */
.typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--studio-primary);
  opacity: 0.35;
  animation: studioPulse 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes studioPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* Drag & Drop Media Zone */
.media-dropzone {
  border: 1.5px dashed var(--studio-border-strong);
  border-radius: var(--studio-radius);
  background: var(--studio-canvas);
  transition: border-color 140ms ease, background-color 140ms ease;
  cursor: pointer;
}
.media-dropzone:hover,
.media-dropzone.is-dragover {
  border-color: var(--studio-primary);
  background: color-mix(in srgb, var(--studio-primary) 7%, #FFFFFF);
}

.studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--studio-border);
  background: var(--studio-subtle);
  color: var(--studio-ink);
}

.studio-badge-pass {
  background: #E8F5F3;
  border-color: #B4DDD7;
  color: #005C52;
}

.studio-badge-warn {
  background: #FEF6E0;
  border-color: #F0D27B;
  color: #7A5800;
}

.studio-badge-alert {
  background: #FDECE9;
  border-color: #F3BFB5;
  color: #9A3320;
}

.studio-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.studio-scroll::-webkit-scrollbar-thumb {
  background: rgba(15, 36, 38, 0.18);
  border-radius: 999px;
}

/* Dynamic Viewport & Native Mobile Polish */
.studio-shell {
  height: 100vh;
  height: 100dvh;
}

.mobile-bottom-nav {
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(15, 36, 38, 0.06);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--studio-ink-muted);
  border-radius: 8px;
  text-decoration: none;
  transition: color 120ms ease, background-color 120ms ease;
}

.mobile-nav-item.is-active {
  color: var(--studio-primary-text);
  background: color-mix(in srgb, var(--studio-primary) 10%, transparent);
}

.mobile-seg-wrap {
  background: var(--studio-subtle);
  padding: 3px;
  border-radius: 9px;
}

.mobile-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--studio-ink-muted);
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.mobile-seg-btn.is-active {
  background: #FFFFFF;
  color: var(--studio-ink);
  box-shadow: 0 1px 3px rgba(15, 36, 38, 0.10);
}

/* Mobile touch-target & spacious chat enforcement */
@media (max-width: 1023px) {
  /* Prevent iOS/Android auto-zoom on focus (requires >= 16px font-size) */
  input,
  textarea,
  select,
  .studio-input,
  .studio-select,
  .studio-textarea {
    font-size: 16px !important;
    touch-action: manipulation;
  }
  .chat-bubble {
    max-width: 94%;
    padding: 0.7rem 0.85rem;
    font-size: 0.86rem;
  }
  .chat-avatar {
    width: 26px;
    height: 26px;
    font-size: 14px;
    border-radius: 7px;
  }
  .chat-row {
    gap: 0.45rem;
  }
}

@media (max-width: 768px) {
  .studio-btn, .studio-input, .studio-select {
    min-height: 40px;
  }
}

/* =========================================================================
   Pull-to-Refresh Center Overlay & Cute Inchworm Loader
   ========================================================================= */
.ptr-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 36, 38, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.ptr-overlay.is-visible {
  opacity: 1;
}

.ptr-overlay.is-refreshing {
  opacity: 1;
  pointer-events: auto;
  background: rgba(15, 36, 38, 0.36);
}

.ptr-card {
  width: min(260px, 84vw);
  background: #FFFFFF;
  border: 1px solid var(--studio-border-strong);
  border-radius: 22px;
  padding: 20px 20px 18px;
  box-shadow: 0 18px 44px rgba(15, 36, 38, 0.18), 0 2px 8px rgba(15, 36, 38, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: scale(0.9) translateY(-10px);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), border-color 180ms ease;
}

.ptr-overlay.is-visible .ptr-card,
.ptr-overlay.is-refreshing .ptr-card {
  transform: scale(1) translateY(0);
}

.ptr-overlay.is-ready .ptr-card {
  border-color: var(--studio-primary);
}

.ptr-worm-stage {
  width: 150px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ptr-worm-svg {
  width: 144px;
  height: 72px;
  overflow: visible;
}

/* Cute Inchworm Crawl Animation */
.ptr-worm-body {
  transform-origin: 72px 54px;
  animation: wormArch 1.05s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.ptr-overlay.is-refreshing .ptr-worm-body {
  animation-duration: 0.68s;
}

.ptr-worm-head {
  transform-origin: 112px 46px;
  animation: wormHeadBob 1.05s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.ptr-overlay.is-refreshing .ptr-worm-head {
  animation-duration: 0.68s;
}

.ptr-worm-tail {
  transform-origin: 28px 50px;
  animation: wormTailInch 1.05s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.ptr-overlay.is-refreshing .ptr-worm-tail {
  animation-duration: 0.68s;
}

.ptr-worm-eye {
  transform-origin: center;
  transform-box: fill-box;
  animation: wormBlink 2.8s ease-in-out infinite;
}

.ptr-worm-shadow {
  transform-origin: 72px 62px;
  animation: wormShadow 1.05s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.ptr-overlay.is-refreshing .ptr-worm-shadow {
  animation-duration: 0.68s;
}

.ptr-progress-track {
  width: 120px;
  height: 5px;
  border-radius: 999px;
  background: var(--studio-subtle);
  overflow: hidden;
}

.ptr-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--studio-primary), var(--studio-accent), var(--studio-highlight));
  transition: width 90ms linear;
}

.ptr-overlay.is-refreshing .ptr-progress-fill {
  width: 100% !important;
  animation: ptrShimmer 0.9s ease-in-out infinite;
}

.ptr-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--studio-ink);
  text-align: center;
  line-height: 1.3;
}

.ptr-sublabel {
  font-size: 10.5px;
  color: var(--studio-ink-muted);
  text-align: center;
}

@keyframes wormArch {
  0%, 100% {
    transform: scaleX(1.06) scaleY(0.92) translateY(2px);
  }
  45% {
    transform: scaleX(0.84) scaleY(1.16) translateY(-7px);
  }
  75% {
    transform: scaleX(1.03) scaleY(0.96) translateY(0px);
  }
}

@keyframes wormHeadBob {
  0%, 100% {
    transform: translate(0px, 1px) rotate(0deg);
  }
  45% {
    transform: translate(-5px, -6px) rotate(-10deg);
  }
  75% {
    transform: translate(4px, -2px) rotate(6deg);
  }
}

@keyframes wormTailInch {
  0%, 100% {
    transform: translateX(-3px);
  }
  45% {
    transform: translateX(9px);
  }
  75% {
    transform: translateX(2px);
  }
}

@keyframes wormBlink {
  0%, 42%, 48%, 100% {
    transform: scaleY(1);
  }
  45% {
    transform: scaleY(0.12);
  }
}

@keyframes wormShadow {
  0%, 100% {
    transform: scaleX(1.05);
    opacity: 0.24;
  }
  45% {
    transform: scaleX(0.74);
    opacity: 0.14;
  }
}

@keyframes ptrShimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
