/* ALY — the workspace.
   Everything here builds on the shared ALYSSIUN tokens in style.css. No brand
   colour, font or shadow is hard-coded, and no local theme system exists: LUX
   (Ceramic Mist) is the default and ALYSSIUN OS owns the LUX/NEO switch.

   ALY is an AI workspace, not a page: the app shell is a fixed-height grid, the
   conversation is the only thing that scrolls, and the composer is always
   reachable. */

.aly-body {
  height: 100dvh;
  padding-bottom: 0;            /* the shell owns launcher clearance, not the body */
  overflow: hidden;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--void); color: var(--text); padding: 12px 18px; border: 1px solid var(--hair-2);
}
.skip-link:focus { left: 12px; top: 12px; }

.aly-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* Focus is never removed, only styled. */
:where(button, a, textarea, input, [tabindex]):focus-visible {
  outline: 2px solid var(--text); outline-offset: 2px; border-radius: 3px;
}

/* --- Shell ---------------------------------------------------------------- */
.aly-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}
.aly-shell[hidden] { display: none; }

/* --- Sidebar -------------------------------------------------------------- */
.aly-sidebar {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--hair);
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  gap: 18px;
}
.aly-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.aly-brand { display: inline-flex; align-items: center; }
.aly-brand:hover { text-decoration: none; }
.aly-wordmark { width: 150px; height: auto; display: block; }
:root[data-alyssiun-atmosphere="neo"] .aly-wordmark,
:root[data-atmosphere="void"] .aly-wordmark {
  content: url("https://assets.lozanocorp.com/alyssiun/png/alyssiun-name-ffffff.png");
}

.aly-new { width: 100%; justify-content: center; }

.aly-recents { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.aly-recents-label { margin: 0 0 2px; }
.aly-conversation-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.aly-conversation-list a {
  display: block; padding: 9px 10px; border-radius: 6px; font-size: 14px;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aly-conversation-list a:hover { background: var(--glass-2); color: var(--text); text-decoration: none; }
.aly-conversation-list a[aria-current="page"] { background: var(--glass-2); color: var(--text); }
.aly-recents-empty { font-size: 13px; margin: 4px 0 0; }

.aly-sidebar-foot { border-top: 1px solid var(--hair); padding-top: 14px; }
.aly-account { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.aly-account-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aly-account a { color: var(--muted); font-size: 12px; }

/* --- Main column ---------------------------------------------------------- */
.aly-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }

.aly-topbar {
  display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 0 clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--hair);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.aly-title {
  margin: 0; font-size: 15px; font-weight: 400; letter-spacing: 0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.aly-topbar-actions { display: flex; gap: 6px; }

.aly-icon-btn {
  border: 1px solid transparent; background: none; color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer; padding: 7px 10px; border-radius: 6px;
  line-height: 1;
}
.aly-icon-btn:hover:not(:disabled) { color: var(--text); background: var(--glass-2); }
.aly-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.aly-icon-btn.aly-danger:hover { color: var(--danger); }
.aly-sidebar-open, .aly-sidebar-close { display: none; font-size: 16px; }

/* --- Transcript ----------------------------------------------------------- */
.aly-transcript { overflow-y: auto; overscroll-behavior: contain; padding: 0 clamp(14px, 4vw, 28px); }
.aly-messages {
  width: min(760px, 100%); margin: 0 auto;
  padding: 22px 0 8px; display: flex; flex-direction: column; gap: 26px;
}

/* The identity area. Reserved space for the official ALY sphere (Prompt 2) —
   a typographic mark holds it now, deliberately not a mascot or a glowing orb. */
.aly-identity {
  width: min(760px, 100%); margin: 0 auto;
  min-height: 46vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 12px;
  padding: 32px 0 12px;
}
.aly-identity[hidden] { display: none; }
.aly-identity-mark {
  width: 108px; height: 108px; display: grid; place-items: center;
  border: 1px solid var(--hair-2); border-radius: 50%;
  background: var(--glass-2); box-shadow: var(--card-shadow);
  margin-bottom: 6px;
}
.aly-identity-mark span {
  font-size: 26px; font-weight: 200; letter-spacing: 0.22em; text-indent: 0.22em; color: var(--text);
}
.aly-identity-title { margin: 0; font-size: clamp(28px, 5vw, 40px); font-weight: 200; }
.aly-identity-sub { margin: 0; max-width: 46ch; font-size: 15px; }

/* Messages. ALY's turns are unadorned prose — the answer is the interface. The
   person's own turns carry a light surface so the exchange stays scannable. */
.aly-message { display: flex; flex-direction: column; gap: 8px; }
.aly-message-role { font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.aly-message-body { font-size: 15.5px; line-height: 1.72; overflow-wrap: anywhere; }
.aly-message-body > *:first-child { margin-top: 0; }
.aly-message-body > *:last-child { margin-bottom: 0; }
.aly-message-body p { margin: 0 0 14px; }
.aly-message-body ul, .aly-message-body ol { margin: 0 0 14px; padding-left: 22px; }
.aly-message-body li { margin-bottom: 5px; }
.aly-message-body pre {
  background: var(--void-2); border: 1px solid var(--hair); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 14px; font-size: 13.5px; line-height: 1.6;
}
.aly-message-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.aly-message-body :not(pre) > code { background: var(--void-2); padding: 1px 5px; border-radius: 4px; }

.aly-message.is-user .aly-message-body {
  background: var(--glass-2); border: 1px solid var(--hair);
  border-radius: var(--radius); padding: 14px 17px; white-space: pre-wrap;
}
.aly-message.is-failed .aly-message-body { border-left: 2px solid var(--danger); padding-left: 13px; }

/* Streaming cursor — a hairline, not a blinking block. */
.aly-cursor {
  display: inline-block; width: 2px; height: 1.05em; vertical-align: text-bottom;
  background: var(--text); margin-left: 2px; animation: aly-blink 1.1s steps(2, start) infinite;
}
@keyframes aly-blink { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .aly-cursor { animation: none; } }

.aly-message-files { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }

/* --- Composer ------------------------------------------------------------- */
.aly-composer-region {
  padding: 10px clamp(14px, 4vw, 28px)
           calc(12px + env(safe-area-inset-bottom, 0px) + var(--alyssiun-os-launcher-clearance, 0px));
  background: linear-gradient(to top, var(--void) 62%, transparent);
}
.aly-composer {
  width: min(760px, 100%); margin: 0 auto;
  border: 1px solid var(--hair-2); border-radius: var(--radius);
  background: var(--input-2); box-shadow: var(--card-shadow);
  padding: 10px 12px 9px; display: flex; flex-direction: column; gap: 8px;
}
.aly-composer:focus-within { border-color: var(--btn-hover-border); }

.aly-input {
  width: 100%; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 15.5px; line-height: 1.6; resize: none;
  /* The shared ALYSSIUN stylesheet gives every textarea a 92px min-height,
     which is right for a form field and wrong for a composer that grows with
     what you type. It starts at one line and autosizes from there. */
  min-height: 0; max-height: 40vh; overflow-y: auto; padding: 6px 4px 2px;
}
.aly-input:focus { outline: none; }
.aly-input::placeholder { color: var(--placeholder); }

.aly-composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.aly-composer-left { display: flex; align-items: center; gap: 2px; }
.aly-composer-left .aly-icon-btn { font-size: 16px; padding: 6px 9px; }
.aly-send { min-width: 92px; }
.aly-send[disabled] { opacity: 0.45; cursor: not-allowed; }

.aly-attachments { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 7px; }
.aly-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px;
  border: 1px solid var(--hair-2); border-radius: 6px; background: var(--glass-2);
  padding: 5px 7px 5px 10px; font-size: 12.5px; color: var(--muted);
}
.aly-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aly-chip.is-pending { opacity: 0.6; }
.aly-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 3px; }
.aly-chip button:hover { color: var(--danger); }

.aly-fineprint { width: min(760px, 100%); margin: 8px auto 0; text-align: center; font-size: 11.5px; }

/* Errors speak as ALY, never as infrastructure. */
.aly-notice {
  width: min(760px, 100%); margin: 0 auto 10px;
  border: 1px solid var(--hair-2); border-left: 2px solid var(--danger);
  border-radius: 6px; background: var(--glass-2); padding: 11px 14px; font-size: 13.5px;
}
.aly-notice[hidden] { display: none; }

/* --- Signed-out gate ------------------------------------------------------ */
.aly-gate { height: 100dvh; display: grid; place-items: center; padding: 24px; }
.aly-gate[hidden] { display: none; }
.aly-gate-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 460px; }
.aly-gate-mark { width: 180px; margin-bottom: 10px; }
.aly-gate-title { margin: 0; font-size: clamp(44px, 9vw, 68px); font-weight: 200; letter-spacing: 0.16em; text-indent: 0.16em; }
.aly-gate-sub { margin: 0; font-size: 15px; }

/* --- Responsive ----------------------------------------------------------- */
.aly-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; }
.aly-scrim[hidden] { display: none; }

@media (max-width: 900px) {
  .aly-shell { grid-template-columns: minmax(0, 1fr); }
  .aly-sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(304px, 86vw); z-index: 50;
    background: var(--void); transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .aly-sidebar.is-open { transform: none; }
  .aly-sidebar-open, .aly-sidebar-close { display: inline-block; }
  .aly-identity { min-height: 38vh; }
  .aly-identity-mark { width: 88px; height: 88px; }
}
@media (prefers-reduced-motion: reduce) { .aly-sidebar { transition: none; } }
