/* The Alden web app (/alden/app/). Layout modelled on claude.ai: a side
   list on the left, the conversation in the middle, the composer at the
   bottom. Colours come from the site tokens in css/style.css. */

/* The site keeps space for a scrollbar on both edges (style.css, html).
   The app scrolls inside its own panels, so that space was a bare strip. */
html:has(body.app) { scrollbar-gutter: auto; overflow: hidden; }

body.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

/* Which half of the page shows depends on whether someone is signed in. */
body.app[data-state="out"] [data-signed-in-only],
body.app[data-state="in"] [data-signed-out-only] { display: none !important; }

/* ---------- Side list ---------- */

.app-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 14px 12px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--surface-border);
}

.app-side-top { display: flex; align-items: center; justify-content: space-between; }

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
}
.app-brand img { width: 28px; height: 28px; }

.app-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.app-icon-btn:hover { background: var(--surface); color: var(--text); }
.app-icon-btn svg { width: 20px; height: 20px; }

.app-new {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.app-new:hover { border-color: var(--accent); background: var(--accent-soft); }
.app-new svg { width: 16px; height: 16px; }

.app-side-links { display: flex; flex-direction: column; gap: 2px; }
.app-side-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.92rem;
}
.app-side-links a:hover,
.app-side-links a.is-current { background: var(--surface); color: var(--text); }
.app-side-links svg { width: 17px; height: 17px; }

.app-recents { flex: 1; min-height: 0; overflow-y: auto; }
.app-recents-title {
  margin: 0 0 6px;
  padding: 0 12px;
  color: var(--text-faint);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.app-recents-list { list-style: none; margin: 0; padding: 0; }
.app-recents-list button {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.88rem;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.app-recents-list button:hover,
.app-recents-list button.is-current { background: var(--surface); color: var(--text); }
.app-recents-empty { margin: 0; padding: 0 12px; color: var(--text-faint); font-size: 0.85rem; }

.app-side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-border);
}
.app-foot-note { margin: 0; color: var(--text-dim); font-size: 0.85rem; line-height: 1.45; }
.app-foot-btn { justify-content: center; text-align: center; }
.app-foot-link { color: var(--text-dim); font-size: 0.88rem; text-align: center; }
.app-foot-link:hover { color: var(--text); }

/* ---------- Account menu (bottom of the side list) ---------- */

.app-account { position: relative; }

.app-account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.app-account-btn:hover,
.app-account-btn[aria-expanded="true"] { background: var(--surface); }

.app-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--grad-alden);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
}
.app-account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.app-account-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-account-plan { color: var(--text-faint); font-size: 0.78rem; }
.app-chev { width: 16px; height: 16px; color: var(--text-faint); flex: none; }

.app-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  display: flex;
  flex-direction: column;
  padding: 6px;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  z-index: 20;
}
.app-menu[hidden] { display: none; }

.app-menu-email {
  margin: 0;
  padding: 6px 10px 8px;
  color: var(--text-faint);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-menu a,
.app-menu button,
.app-submenu a,
.app-submenu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: start;
  cursor: pointer;
}
.app-menu a:hover,
.app-menu button:hover,
.app-menu .app-menu-sub[aria-expanded="true"] { background: var(--surface); }
.app-menu hr { width: 100%; margin: 5px 0; border: 0; border-top: 1px solid var(--surface-border); }
.app-ext { color: var(--text-faint); }

/* "Learn more" and "Language" open beside the menu, as on claude.ai. */
.app-submenu {
  position: absolute;
  left: calc(100% + 6px);
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 230px;
  padding: 6px;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.app-submenu[hidden] { display: none; }
.app-submenu .is-on::after { content: "\2713"; color: var(--accent); }

/* ---------- Conversation ---------- */

.app-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 14px max(16px, env(safe-area-inset-left, 0px));
}

.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}
.app-side-open { visibility: hidden; }
.app-plan-pill,
.app-top-link {
  margin-inline-start: auto;
  padding: 6px 14px;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.app-top-link:hover { color: var(--text); border-color: var(--accent); }

.app-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto 0 26px;
  text-align: center;
}
.app-welcome[hidden] { display: none; }

/* A new chat: greeting and composer sit together in the middle, as on
   claude.ai. Once there are messages the composer drops to the bottom. */
.app-main.is-empty .app-composer { margin-bottom: auto; }
.app-main.is-empty .app-disclaimer { position: absolute; left: 0; right: 0; bottom: 14px; }
.app-welcome-mark { width: 44px; height: 44px; }
.app-greeting {
  margin: 0;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 500;
  text-wrap: balance;
}

.app-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 0 20px;
}
.app-chat:empty { display: none; }

.app-msg { max-width: 100%; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.app-msg-you {
  align-self: flex-end;
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}
.app-msg-alden { align-self: flex-start; color: var(--text); }
.app-msg-note {
  align-self: flex-start;
  padding: 10px 14px;
  border: 1px dashed var(--surface-border);
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.app-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px 10px 16px;
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  background: var(--bg-elevated);
}
.app-composer:focus-within { border-color: rgba(var(--accent-rgb), 0.55); }
.app-composer textarea {
  width: 100%;
  max-height: 220px;
  border: 0;
  outline: 0;
  resize: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
}
.app-composer textarea::placeholder { color: var(--text-faint); }
.app-composer-row { display: flex; align-items: center; justify-content: space-between; }
.app-model { color: var(--text-faint); font-size: 0.82rem; }
.app-send {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--grad-alden);
  color: #fff;
  cursor: pointer;
}
.app-send:disabled { opacity: 0.35; cursor: default; }
.app-send svg { width: 18px; height: 18px; }

.app-disclaimer {
  margin: 8px 0 0;
  color: var(--text-faint);
  font-size: 0.75rem;
  text-align: center;
}
.app-disclaimer a { color: var(--text-dim); text-decoration: underline; }

/* ---------- Keyboard shortcuts window ---------- */

.app-dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
}
.app-dialog[hidden] { display: none; }
.app-dialog-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.app-dialog-card h2 { margin: 0; font-size: 1.15rem; }
.app-dialog-card .btn { align-self: flex-end; }
.app-keys { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; margin: 0; }
.app-keys dt { color: var(--text-dim); }
.app-keys dd { margin: 0; }
.app-keys kbd {
  padding: 2px 7px;
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
  font-size: 0.8rem;
}

/* ---------- Phone width: the side list slides over ---------- */

@media (max-width: 820px) {
  body.app { grid-template-columns: minmax(0, 1fr); }
  .app-side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
    z-index: 40;
  }
  body.app.side-open .app-side { transform: none; }
  .app-side-open { visibility: visible; }
  .app-submenu { left: 8px; right: 8px; bottom: calc(100% + 6px); width: auto; }
}

/* ---------- Get the app (/alden/app/downloads.html) ---------- */

body.app-page { background: var(--bg); color: var(--text); }

.app-page-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--surface-border);
  background: var(--bg);
  z-index: 10;
}
.app-page-title { font-size: 1rem; }

.dl-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px max(16px, env(safe-area-inset-right, 0px)) 72px max(16px, env(safe-area-inset-left, 0px));
}
.dl-title {
  margin: 0 0 16px;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  font-weight: 500;
  text-align: center;
  text-wrap: balance;
}

.dl-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 30px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.dl-card h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.dl-card p { margin: 0; color: var(--text-dim); line-height: 1.55; }

.dl-card-wide {
  flex-direction: row;
  align-items: center;
  gap: 28px;
  background: radial-gradient(120% 140% at 100% 50%, rgba(var(--accent-rgb), 0.16), transparent 60%), var(--bg-elevated);
}
.dl-card-text { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 0; }
.dl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.dl-note { font-size: 0.85rem; }
.dl-small { font-size: 0.82rem; color: var(--text-faint) !important; }
.dl-small a { color: var(--text-dim); text-decoration: underline; }
.dl-art { display: grid; place-items: center; flex: none; width: 200px; }
.dl-art img { width: 120px; height: 120px; }

.dl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

.dl-rows { list-style: none; margin: 8px 0 0; padding: 0; }
.dl-rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--surface-border);
}
.dl-row-name { display: inline-flex; align-items: center; gap: 10px; }
.dl-row-name svg { width: 20px; height: 20px; color: var(--text-dim); }

@media (max-width: 720px) {
  .dl-grid { grid-template-columns: minmax(0, 1fr); }
  .dl-card-wide { flex-direction: column; align-items: stretch; }
  .dl-art { display: none; }
  .dl-card { padding: 22px; }
}
.dl-grid-one { grid-template-columns: minmax(0, 1fr); }
.app-keys-title { margin: 0; color: var(--text-faint); font-size: 0.78rem; font-weight: 500; letter-spacing: 0.04em; }

/* ---------- Turn on notifications (once, as Claude's web app asks) ---------- */

.app-notify-card { align-items: center; text-align: center; gap: 12px; width: min(380px, 100%); }
.app-notify-card p { margin: 0; color: var(--text-dim); }
.app-notify-bell { width: 28px; height: 28px; color: var(--text-dim); }
.app-notify-actions { display: flex; gap: 8px; justify-content: center; }
.app-notify-card .btn { align-self: auto; }
.app-notify-never {
  padding: 0; border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 0.85rem;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

