/* Regulations masthead and MERIDIAN workspace. */

#reg-layout {
  --ask-accent: #4f46c8;
  --ask-accent-dark: #3d35a7;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.reg-reading {
  min-width: 0;
  container: reg-reading / inline-size;
}

.reg-masthead-layout {
  display: grid;
  align-items: center;
  gap: clamp(1.25rem, 4cqw, 4.25rem);
  padding-block: clamp(1.5rem, 5cqw, 4.5rem);
}

.reg-chat-open .reg-masthead-layout {
  padding-block: clamp(1.5rem, 4cqw, 2.5rem);
}

.reg-browse-title {
  margin-bottom: 1rem;
  color: var(--reg-ink);
  font: 400 2rem/1 var(--font-display);
  letter-spacing: .025em;
  text-transform: uppercase;
}

@container reg-reading (min-width: 47rem) {
  .reg-masthead-layout {
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  }

  .reg-chat-open .reg-masthead-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container reg-reading (max-width: 59rem) {
  .reg-paths {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container reg-reading (max-width: 23rem) {
  .reg-paths {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ask-intro {
  min-width: 0;
  padding: clamp(1rem, 2.2cqw, 1.6rem);
  border: 1px solid #b2aff0;
  border-top: 4px solid #7974fb;
  border-radius: .875rem;
  background: #fff;
  color: var(--reg-ink);
  box-shadow: 0 15px 40px #08152645;
}

.ask-intro-heading,
.ask-panel-identity {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  min-width: 0;
}

.ask-intro-icon,
.ask-panel-icon {
  display: grid;
  flex: none;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  border-radius: .6rem;
  background: #eeebff;
  color: var(--ask-accent);
  font-size: 1.3rem;
}

.ask-intro-heading h2 {
  font-size: clamp(1.3rem, 2cqw, 1.8rem);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.15;
}

.ask-intro-heading p {
  margin-top: .2rem;
  color: var(--reg-muted);
  font-size: .85rem;
  line-height: 1.35;
}

.ask-label {
  display: block;
  margin-bottom: .35rem;
  color: var(--reg-ink);
  font-size: .85rem;
  font-weight: 700;
}

#ask-intro-form {
  margin-top: 1rem;
}

.ask-composer {
  display: flex;
  align-items: stretch;
  gap: .5rem;
}

.ask-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 3rem;
  max-height: 8rem;
  resize: vertical;
  border: 1px solid #a0b4ce;
  border-radius: .5rem;
  padding: .75rem;
  background: #f9fbff;
  color: var(--reg-ink);
  font-size: .9rem;
  line-height: 1.4;
}

.ask-composer textarea::placeholder {
  color: #536984;
}

.ask-send {
  display: inline-flex;
  flex: none;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  border-radius: .5rem;
  padding: .35rem .75rem;
  background: var(--ask-accent);
  color: #fff;
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
}

.ask-send:hover {
  background: var(--ask-accent-dark);
}

.ask-send:disabled,
.ask-chip:disabled,
.ask-text-button:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.ask-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-top: .625rem;
}

.ask-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-height: 2.5rem;
  border: 1px solid #cdc9f4;
  border-radius: .375rem;
  padding: .3rem .55rem;
  background: #f4f2ff;
  color: #3c328f;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}

.ask-chip iconify-icon {
  flex: none;
}

.ask-chip:hover {
  background: #e9e4ff;
}

.ask-text-button {
  color: var(--ask-accent-dark);
  font-size: .8rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .17em;
}

#ask-resume {
  min-height: 2.75rem;
  margin-top: .125rem;
}

#reg-layout.reg-chat-open {
  grid-template-columns: minmax(0, 1fr) var(--ask-width, min(39vw, 40rem));
}

.ask-meridian {
  position: sticky;
  top: var(--reg-nav-height, 4rem);
  display: flex;
  min-width: 0;
  height: calc(100dvh - var(--reg-nav-height, 4rem));
  flex-direction: column;
  border-left: 1px solid #b7c9dd;
  background: #f5f8fc;
  box-shadow: -8px 0 22px rgb(16 38 65 / .08);
}

.ask-intro[hidden],
.ask-meridian[hidden],
.ask-upsell[hidden] {
  display: none;
}

.ask-resize {
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 -.375rem;
  width: .75rem;
  cursor: col-resize;
  touch-action: none;
}

.ask-resize::after {
  position: absolute;
  top: calc(50% - 1.4rem);
  left: .25rem;
  width: .25rem;
  height: 2.8rem;
  border-radius: .25rem;
  background: #818aae;
  content: "";
}

.ask-resize:hover::after,
.ask-resize:focus-visible::after,
.reg-chat-resizing .ask-resize::after {
  background: var(--ask-accent);
}

.ask-resize:focus-visible {
  outline-offset: -2px;
}

.reg-chat-resizing,
.reg-chat-resizing * {
  cursor: col-resize !important;
  user-select: none;
}

.ask-panel-header {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1rem;
  background: #12283f;
  color: #fff;
}

.ask-panel-identity {
  align-items: center;
}

.ask-panel-icon {
  width: 2.25rem;
  height: 2.25rem;
  background: #7368ed;
  color: #fff;
  font-size: 1.25rem;
}

#ask-panel-title {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}

#ask-panel-title:focus {
  outline: none;
}

.ask-powered {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-top: .25rem;
  color: #c6d5e9;
  font-size: .7rem;
  line-height: 1.2;
}

.ask-powered img {
  width: auto;
  height: .8rem;
}

.ask-panel-controls {
  display: flex;
  flex: none;
  gap: .375rem;
}

.ask-panel-button {
  display: inline-flex;
  min-width: 2.75rem;
  min-height: 2.75rem;
  justify-content: center;
  align-items: center;
  gap: .35rem;
  border: 1px solid #a6c2dd60;
  border-radius: .5rem;
  padding-inline: .5rem;
  background: #ffffff12;
  color: #f0f7ff;
  font-size: .8rem;
  font-weight: 700;
}

.ask-panel-button iconify-icon {
  font-size: 1.1rem;
}

.ask-panel-button:hover,
.ask-panel-button[aria-pressed="true"] {
  background: #6576d858;
}

.ask-panel-header :focus-visible {
  outline-color: #9fe1ff;
}

.ask-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem 1rem 1.35rem;
}

.ask-messages {
  display: grid;
  gap: .75rem;
  width: min(100%, 45rem);
  margin-inline: auto;
  overflow-wrap: anywhere;
}

.ask-answer-card {
  min-width: 0;
  flex: 1;
  border: 1px solid #d2dcea;
  border-radius: .75rem .75rem .75rem .25rem;
  padding: 1rem;
  background: #fff;
}

.ask-answer-author {
  margin-bottom: .35rem;
  color: var(--ask-accent-dark);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ask-answer-card pre {
  max-width: 100%;
  overflow-x: auto;
}

.ask-answer-card th,
.ask-answer-card td {
  overflow-wrap: anywhere;
}

.ask-empty {
  padding: 1rem;
  border: 1px solid var(--reg-line);
  border-radius: .75rem;
  background: #fff;
  color: var(--reg-muted);
  font-size: .9rem;
}

.ask-upsell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  width: min(100%, 45rem);
  margin: .8rem auto 0;
  border: 1px solid #d7d4f9;
  border-radius: .55rem;
  padding: .75rem;
  background: #f0edff;
  color: #2d2c66;
}

.ask-upsell h3 {
  font-size: .875rem;
  font-weight: 800;
}

.ask-upsell p {
  font-size: .8rem;
  line-height: 1.4;
}

.ask-upsell a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .3rem;
  color: var(--ask-accent-dark);
  font-size: .85rem;
  font-weight: 800;
}

.ask-panel-footer {
  flex: none;
  border-top: 1px solid #cfdbea;
  padding: .65rem 1rem .75rem;
  background: #fff;
}

.ask-panel-footer > * {
  width: min(100%, 45rem);
  margin-inline: auto;
}

.ask-panel-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .3rem .8rem;
  margin-top: .4rem;
}

.ask-panel-note p {
  color: var(--reg-muted);
  font-size: .7rem;
  line-height: 1.35;
}

#ask-reset {
  min-height: 2.25rem;
}

@media (max-width: 820px) {
  #reg-layout.reg-chat-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .reg-chat-fullscreen,
  .reg-chat-fullscreen body {
    overflow: hidden;
  }

  .reg-chat-open .reg-reading {
    visibility: hidden;
  }

  .ask-meridian {
    position: fixed;
    z-index: 70;
    inset: 0;
    height: 100dvh;
    border: 0;
  }

  .ask-resize,
  .ask-widen {
    display: none;
  }

  .ask-panel-footer {
    padding-bottom: max(.75rem, env(safe-area-inset-bottom));
  }

  .ask-chip {
    min-height: 2.75rem;
  }
}

/* Ask MERIDIAN widget ----------------------------------------------------- */

.ask-md > :first-child { margin-top: 0; }
.ask-md > :last-child { margin-bottom: 0; }
.ask-md p { margin-block: 0.55rem; }
.ask-md ul,
.ask-md ol { margin-block: 0.55rem; padding-inline-start: 1.25rem; }
.ask-md ul { list-style: disc; }
.ask-md ol { list-style: decimal; }
.ask-md li { margin-block: 0.2rem; }
.ask-md h2,
.ask-md h3,
.ask-md h4 {
  color: var(--reg-ink);
  font-weight: 700;
  margin-block: 0.8rem 0.3rem;
}
.ask-md blockquote {
  border-inline-start: 3px solid var(--reg-line);
  color: var(--reg-muted);
  margin-block: 0.55rem;
  padding-inline-start: 0.75rem;
}
.ask-md code {
  background: var(--reg-panel);
  border-radius: 0.25rem;
  font-size: 0.85em;
  padding: 0.1rem 0.3rem;
}
.ask-md hr {
  border-color: var(--reg-line);
  margin-block: 0.8rem;
}
.ask-md a { color: var(--reg-link); font-weight: 600; }
.ask-md table { border-collapse: collapse; margin-block: 0.55rem; width: 100%; }
.ask-md th,
.ask-md td {
  border: 1px solid var(--reg-line);
  padding: 0.35rem 0.5rem;
  text-align: start;
}

.ask-source {
  align-items: baseline;
  background: var(--reg-panel);
  border: 1px solid var(--reg-line);
  border-radius: 9999px;
  color: var(--reg-muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 600;
  gap: 0.2rem;
  padding: 0.25rem 0.65rem;
  text-decoration: none;
}
a.ask-source:hover {
  border-color: var(--reg-link);
  color: var(--reg-link);
}

/* Ask MERIDIAN — agent identity, reasoning, upsell ------------------------ */

.ask-avatar {
  background: #6366f1; /* Meridian's color across AYNA (portal roster) */
  height: 2.25rem;
  width: 2.25rem;
}
.ask-propeller {
  display: block;
  height: 1.75rem;
  width: 1.75rem;
}

.ask-thinking-label {
  animation: ask-shimmer 1.4s linear infinite;
  background: linear-gradient(90deg, #6b7280 30%, #a5b4fc 50%, #6b7280 70%);
  background-clip: text;
  background-size: 200% 100%;
  color: transparent;
}
@keyframes ask-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.ask-reasoning {
  border-block-start: 1px solid var(--reg-line);
  padding-block-start: 0.6rem;
}
.ask-reasoning-toggle {
  align-items: center;
  color: #6366f1;
  cursor: pointer;
  display: flex;
  font-size: 0.75rem;
  font-weight: 700;
  gap: 0.35rem;
  list-style: none;
}
.ask-reasoning-toggle::-webkit-details-marker { display: none; }
.ask-reasoning-caret { margin-inline-start: auto; transition: transform 0.15s ease; }
.ask-reasoning[open] .ask-reasoning-caret { transform: rotate(180deg); }
.ask-reasoning-body {
  color: var(--reg-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  margin-block-start: 0.5rem;
  max-height: 15rem;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Ask MERIDIAN — live streaming states ------------------------------------ */

.ask-live-reasoning {
  border-block-start: 1px dashed var(--reg-line);
  color: var(--reg-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  margin-block-start: 0.5rem;
  max-height: 10rem;
  overflow-y: auto;
  padding-block-start: 0.5rem;
  white-space: pre-wrap;
}

.ask-tool-flash {
  color: #6366f1;
  font-size: 0.75rem;
  font-style: italic;
  font-weight: 600;
  margin-block-start: 0.5rem;
}

/* Ask MERIDIAN — copy affordance ------------------------------------------- */

.ask-copy-btn {
  align-items: center;
  border-radius: 0.375rem;
  color: var(--reg-muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 600;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.ask-copy-btn:hover {
  background: var(--reg-panel);
  color: #6366f1;
}
.ask-copy-btn.ask-copied {
  color: #059669;
}
