/* ThomasAI dashboard */
[hidden] { display: none !important; }

#shutter {
  position: fixed;
  top: 0;
  bottom: 0;
  left: -50vh;
  z-index: 5;
  width: calc(100vw + 100vh);
  background: var(--bone);
  transform: skewX(-36deg) translateX(-112%);
}

#shutter.is-running { will-change: transform; }

.app {
  position: relative;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: 100%;
}

/* Rail */
.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 12px 14px;
  background: rgb(9 9 11 / .9);
  border-right: 1px solid rgb(233 232 228 / .1);
}

.home {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
  border: 0;
  color: var(--bone);
  background: none;
  font: inherit;
  font-size: 1.14rem;
  font-weight: 600;
  letter-spacing: -.02em;
  text-align: left;
  cursor: pointer;
}

.tabs { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }

.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 0;
  color: var(--smoke);
  background: none;
  font: inherit;
  font-size: .96rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color .16s;
}

.tab svg {
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tab:hover { color: var(--bone); }

.tab[aria-current="page"] {
  color: var(--void);
  background: var(--bone);
  clip-path: polygon(0 0, 100% 0, calc(100% - 30px) 100%, 0 100%);
}

.rail__chats {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 18px;
}

.newchat {
  height: 38px;
  margin: 0 2px;
  border: 1px solid rgb(233 232 228 / .2);
  color: var(--bone);
  background: none;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
  transition: background-color .16s;
}

.newchat:hover { background: rgb(233 232 228 / .1); }

.rail__title {
  margin: 18px 12px 6px;
  color: var(--smoke);
  font-size: .8rem;
  font-weight: 400;
}

#recent {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: var(--ash) transparent;
}

.chatlink {
  display: block;
  width: 100%;
  padding: 7px 12px;
  overflow: hidden;
  border: 0;
  color: var(--smoke);
  background: none;
  font: inherit;
  font-size: .88rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.chatlink:hover, .chatlink[aria-current] { color: var(--bone); }
.chatlink[aria-current] { background: rgb(233 232 228 / .08); }

.rail__foot { margin-top: auto; padding-top: 12px; }

/* Main area */
.stage { position: relative; min-width: 0; min-height: 0; }

.page { height: 100%; }

.page--soon {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(28px, 7vw, 76px);
}

.page--soon h2 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 7rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.045em;
}

.page--soon p { margin: 14px 0 0; color: var(--smoke); font-size: 1.05rem; }

/* AI page: the composer sits mid-screen, then drops to the bottom once a chat starts. */
#page-ai {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto 1.25fr;
  min-height: 0;
  padding: 0 clamp(14px, 3vw, 32px) 18px;
}

#page-ai.has-chat { grid-template-rows: minmax(0, 1fr) auto; }

.empty { align-self: end; justify-self: center; width: min(100%, 760px); padding-bottom: 24px; }

.empty h2 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -.04em;
}

#thread {
  min-height: 0;
  overflow-y: auto;
  padding: 28px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--ash) transparent;
}

#page-ai:not(.has-chat) #thread { display: none; }

.msg {
  width: min(100%, 760px);
  margin: 0 auto 24px;
  font-size: 1rem;
  line-height: 1.62;
}

.msg--user { display: flex; flex-direction: column; align-items: flex-end; }

.msg__text {
  max-width: min(85%, 600px);
  margin: 0;
  padding: 11px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #1b1b1e;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

.msg__images { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.msg__images img { display: block; max-width: 220px; max-height: 220px; }
.msg__note { margin: 0 0 6px; color: var(--smoke); font-size: .84rem; }

.msg__status { margin: 0 0 6px; color: var(--smoke); }

.think { margin-bottom: 8px; color: var(--smoke); font-size: .9rem; }
.think summary { width: fit-content; cursor: pointer; }

.think__body {
  max-height: 260px;
  margin-top: 8px;
  padding-left: 14px;
  overflow-y: auto;
  border-left: 1px solid var(--ash);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote { margin: 0 0 .9em; }
.prose h1, .prose h2, .prose h3 { margin: 1.3em 0 .45em; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.28rem; }
.prose h3 { font-size: 1.08rem; }
.prose a { color: var(--bone); text-underline-offset: 3px; }
.prose hr { border: 0; border-top: 1px solid var(--ash); }
.prose blockquote { padding-left: 14px; border-left: 2px solid var(--ash); color: var(--smoke); }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.prose th, .prose td { padding: 6px 12px; border: 1px solid var(--ash); text-align: left; }

.prose code {
  padding: .1em .32em;
  font-family: Consolas, "Cascadia Mono", Menlo, monospace;
  font-size: .9em;
  background: rgb(233 232 228 / .1);
}

.prose pre {
  position: relative;
  padding: 14px 16px;
  overflow-x: auto;
  background: #101012;
  border: 1px solid rgb(233 232 228 / .1);
}

.prose pre code { padding: 0; background: none; font-size: .88rem; }

.copy {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 9px;
  border: 0;
  color: var(--smoke);
  background: #232326;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
}

.copy:hover { color: var(--bone); }

.msg__error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  border-left: 2px solid var(--bone);
  background: #18181b;
}

.msg__error p { flex: 1 1 200px; margin: 0; }

.msg__error button {
  padding: 5px 12px;
  border: 0;
  color: var(--void);
  background: var(--bone);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}

/* Composer */
#composer {
  justify-self: center;
  width: min(100%, 760px);
  padding: 1px;
  background: rgb(233 232 228 / .22);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 24px), calc(100% - 24px) 100%, 0 100%);
  transition: background-color .16s;
}

#composer:focus-within, #composer.is-dropping { background: rgb(233 232 228 / .55); }

.composer__body {
  padding: 12px 12px 10px 14px;
  background: #101012;
  clip-path: inherit;
}

#tray { display: flex; gap: 8px; padding-bottom: 10px; }

.chip { position: relative; width: 62px; height: 62px; }
.chip img { display: block; width: 100%; height: 100%; object-fit: cover; }

.chip button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  color: var(--void);
  background: var(--bone);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

#prompt {
  display: block;
  width: 100%;
  min-height: 28px;
  padding: 2px;
  border: 0;
  resize: none;
  outline: none;
  color: var(--bone);
  background: none;
  font: inherit;
  font-size: 1.04rem;
  line-height: 1.5;
}

#prompt::placeholder { color: var(--smoke); }

.composer__row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

.iconbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  color: var(--bone);
  background: none;
  cursor: pointer;
}

.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn:hover { background: rgb(233 232 228 / .1); }

#models {
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  color: var(--smoke);
  font-size: .86rem;
}

.model {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 0;
  color: var(--smoke);
  background: none;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.model:hover { color: var(--bone); }

.model[aria-checked="true"] {
  color: var(--bone);
  background: rgb(233 232 228 / .13);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

#send {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 38px;
  border: 0;
  color: var(--void);
  background: var(--bone);
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}

#send svg { width: 18px; height: 18px; fill: currentColor; }
#send .icon-stop { display: none; }
#send.is-stop .icon-send { display: none; }
#send.is-stop .icon-stop { display: block; }
#send:disabled { color: var(--smoke); background: var(--ash); cursor: not-allowed; }

#notice {
  position: absolute;
  bottom: 110px;
  left: 50%;
  z-index: 2;
  padding: 8px 14px;
  background: var(--bone);
  color: var(--void);
  font-size: .9rem;
  transform: translateX(-50%);
}

/* Games: the wall stays edge to edge so the games are the page. */
.library { height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ash) transparent; }

.library__bar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px;
  background: var(--void);
  border-bottom: 1px solid rgb(233 232 228 / .14);
}

#game-search {
  display: block;
  width: min(100%, 460px);
  padding: 10px 14px;
  border: 1px solid rgb(233 232 228 / .24);
  color: var(--bone);
  background: var(--basalt);
  font: inherit;
  outline: 0;
}

#game-search:focus { border-color: var(--bone); }
#game-search::placeholder { color: var(--smoke); }

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 2px;
  background: var(--void);
}

.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--bone);
  background: var(--basalt);
  font: inherit;
  text-align: left;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 200px;
}

.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }

.tile span {
  position: absolute;
  inset: auto 0 0;
  padding: 18px 10px 8px;
  overflow: hidden;
  background: linear-gradient(rgb(6 6 7 / 0), rgb(6 6 7 / .92) 55%);
  font-size: .86rem;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tile--plain span {
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  background: none;
  font-size: 1.32rem;
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.12;
  white-space: normal;
}

.tile--plain:hover { background: #18181b; }

.tile:hover img { filter: brightness(1.14); }
.tile:hover span { white-space: normal; }

.library__note { margin: 0; padding: 28px 16px; color: var(--smoke); }
.library__retry { margin: 0 16px 28px; }
#wall-end { height: 1px; }

.player { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; background: #000; }

.player__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--void);
  border-bottom: 1px solid rgb(233 232 228 / .14);
}

.player__bar h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.player__bar button, .library__retry {
  flex: none;
  padding: 7px 13px;
  border: 0;
  color: var(--void);
  background: var(--bone);
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
}

#player-frame { display: block; width: 100%; height: 100%; border: 0; background: #000; }

/* Web: the browser lives on its own origin. */
#web-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--basalt); }

/* Context left */
.ring { flex: none; width: 22px; height: 22px; }

.ring svg { display: block; transform: rotate(-90deg); fill: none; stroke: var(--ash); stroke-width: 2.500; }
.ring__left { stroke: var(--smoke); stroke-dasharray: 100 100; transition: stroke-dasharray .4s var(--ease); }
.ring.is-low .ring__left { stroke: var(--bone); }

.compact { margin-bottom: 18px; padding: 8px 0; border-block: 1px solid rgb(233 232 228 / .14); color: var(--smoke); font-size: .9rem; }
.compact summary { width: fit-content; cursor: pointer; }
.compact .prose { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .ring__left { transition: none; }
}

/* Screen share */
.sharebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-self: center;
  gap: 10px 14px;
  width: min(100%, 760px);
  padding: 14px 16px;
  background: #101012;
  border: 1px solid rgb(233 232 228 / .3);
}

.sharebar p { flex: 1 1 220px; margin: 0; }

.sharebar button, .mini__stop {
  padding: 7px 13px;
  border: 0;
  color: var(--void);
  background: var(--bone);
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
}

.mini {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--void);
}

.mini__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgb(233 232 228 / .14);
}

.mini__live { flex: none; width: 64px; height: 36px; background: #000; object-fit: cover; }
.mini__label { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .86rem; }
.mini__stop { flex: none; padding: 6px 10px; font-size: .8rem; }

.mini__thread { min-height: 0; padding: 14px 12px 4px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ash) transparent; }
.mini__hint { margin: 0 0 14px; color: var(--smoke); font-size: .92rem; line-height: 1.5; }

.mini .msg { width: 100%; margin-bottom: 16px; font-size: .94rem; line-height: 1.55; }
.mini .msg__text { max-width: 92%; padding: 8px 12px; }
.mini .msg__images img { max-width: 132px; max-height: 88px; }

.mini__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 12px;
  border-top: 1px solid rgb(233 232 228 / .14);
}

.mini__form #prompt { flex: 1 1 auto; font-size: .96rem; }

.home:focus-visible, .tab:focus-visible, .newchat:focus-visible, .chatlink:focus-visible,
.iconbtn:focus-visible, .model:focus-visible, .copy:focus-visible, #send:focus-visible,
.sharebar button:focus-visible, .mini__stop:focus-visible, .compact summary:focus-visible,
.tile:focus-visible, .player__bar button:focus-visible, .library__retry:focus-visible,
.msg__error button:focus-visible, .chip button:focus-visible, .think summary:focus-visible {
  outline: 2px solid var(--bone);
  outline-offset: -2px;
}

#send:focus-visible, .msg__error button:focus-visible, .tab[aria-current="page"]:focus-visible,
.sharebar button:focus-visible, .mini__stop:focus-visible,
.player__bar button:focus-visible, .library__retry:focus-visible { outline-color: var(--void); }

/* Phones: the rail becomes a bottom bar. */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }

  .stage { grid-row: 1; }

  .rail {
    grid-row: 2;
    flex-direction: row;
    padding: 4px;
    border-top: 1px solid rgb(233 232 228 / .1);
    border-right: 0;
  }

  .home, .rail__chats, .rail__foot .tab__label, .tabs .tab__label { display: none; }

  .composer__row { flex-wrap: wrap; }
  #models { order: 1; flex-basis: 100%; }
  .ring { margin-left: auto; }

  .rail nav { flex: 5 1 0; min-width: 0; }
  .tabs { grid-auto-flow: column; grid-auto-columns: 1fr; }
  .rail__foot { flex: 1 1 0; min-width: 0; margin: 0; padding: 0; }

  .tab { justify-content: center; height: 48px; padding: 0; }
  .tab[aria-current="page"] { clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }

  .model { padding: 0 7px; font-size: .78rem; }
  .composer__row { gap: 4px; }
  #send { width: 42px; }
  .iconbtn { width: 30px; }
  #models { overflow-x: auto; scrollbar-width: none; }
  #page-ai { padding-bottom: 10px; }
}
