:root{

  --dark:#101010;
  --light:#f9f9fa;
  --high-dark:#2d2d2d;
  --high-light:#feffff;


  --bg:var(--light);
  --text:var(--dark);
  --high-bg:var(--high-light);

  --text-op-low: color-mix(in srgb, transparent 90%, var(--text));
  --text-op: color-mix(in srgb, transparent 80%, var(--text));
  --text-op-high: color-mix(in srgb, transparent 20%, var(--text));

  --bg-prompt: color-mix(in srgb, transparent 50%, var(--high-bg));

  /* accents */
  --accent-white:var(--dark);
  --accent-green:#008b5d;
  --accent-blue:#007fbd;
  --accent-purple:#625da5;
  --accent-gold:#c98400;
  --accent-pink:#bd556b;
  --accent-red:#cc4a55;
  --accent-orange:#c95125;

	--green:#00CBA9;

  --accent:var(--accent-white);

  --accent-op-10: color-mix(in srgb, var(--accent) 10%, transparent 90%);
  --accent-op-20: color-mix(in srgb, var(--accent) 20%, transparent 80%);
  --accent-op-30: color-mix(in srgb, var(--accent) 30%, transparent 70%);
  --accent-op-40: color-mix(in srgb, var(--accent) 40%, transparent 60%);
  --accent-op-50: color-mix(in srgb, var(--accent) 50%, transparent 50%);

  --current-op-10:color-mix(in srgb, currentColor 10%, transparent 90%);
  --current-op-20:color-mix(in srgb, currentColor 20%, transparent 80%);
  --current-op-30:color-mix(in srgb, currentColor 30%, transparent 70%);
  --current-op-40:color-mix(in srgb, currentColor 40%, transparent 60%);
  --current-op-50:color-mix(in srgb, currentColor 50%, transparent 50%);
  --current-op-80:color-mix(in srgb, currentColor 80%, transparent 20%);
}

@import url('https://fonts.googleapis.com/icon?family=Material+Icons');


[data-mode=dark] {
  --bg: var(--dark) !important;
  --text: var(--light) !important;
  --high-bg: var(--high-dark) !important;
  --accent-white: #fafafa !important;
}

body {
    background:var(--bg);
    color:var(--text);
    font-family: sans-serif;
    height:100;
}

img.blob{
    position:fixed;
    top:0;
    left:0;
    opacity:.1;
    filter:blur(20px);
    z-index: -1;
    height:100%;
    pointer-events: none;
    user-select: none;
}

.prompt-wrap{
  background:var(--high-bg);
  border-radius: 1rem;
  backdrop-filter:blur(15px);

  background: var(--bg-prompt);
  overflow: scroll;


  border-radius: 1.5rem;

  color: var(--text);

  border:1px solid var(--text-op);

  overflow: hidden;

}

textarea, #prompt {
  outline: none;
  border: none;
  resize: none;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  color:var(--text);
  overflow:hidden;

  white-space: pre-wrap;
}


* {
    scrollbar-width: thin;
  scrollbar-color: var(--text-op) transparent;
  

  -ms-overflow-style: none;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent !important;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--text-op);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background: var(--text-op);
  }
}

.assistant{
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    img {
        max-width: 100px;
        filter:grayscale(90%);
        pointer-events: none;
        user-select: none;
        opacity:.5;
    }

    .accents{
      display: flex;
      align-items: center;
      gap:10px;
      margin:15px 0;
    }

    .accent{
      height:25px;
      width: 25px;
      border-radius: 50%;
      cursor:pointer;

      &.active{
        border: 1px solid var(--bg);
        box-shadow: 0 0 0 2px currentColor;
      }
    }
}

.settings {
  font-size:85%;
  margin-top:1em;
  overflow:hidden;

  b {
    margin: 0 0 0.5rem 0;
    display: block;
    font-size: 1.1em;
    color: var(--text);
  }

  p {
    margin: 0 0 .5em 0;
    opacity: 0.8;
    line-height: 1.4;
  }

  textarea, input[type="text"] {
    background:var(--high-bg);
    outline:none;
    resize:vertical;
    font-family: inherit;
    font-size: 100%;
    border-radius: 10px;
    padding:.5rem;
    width:calc(100% - 1rem);
    min-height:100px;
  }

  input[type="text"]{
    color:var(--text);
    outline:none;
    border:none;
    min-height:unset;
  }
}

.skills label {
  user-select: none;
  padding:5px;
  cursor:pointer;
  box-shadow: 0 4px 24px 0 rgba(0,0,0,0.10), 0 1.5px 6px 0 rgba(0,0,0,0.08);
  border-radius: 5px;

  display: flex;
  align-items: center;

  background:var(--accent-op-20);
  border:1px solid var(--accent-op-20);

  a.delete{
    font-size:125%;
    margin-left:auto;
    height:100%;
    display: flex;
    align-items: center;
    justify-content: center;

    &:hover{
      color:var(--accent-red);
    }
  }
  a.delete::before {
    font-family: Material Icons;
    content:'delete_outline';

  }
}

.skills input[type="checkbox"]{
  display: none;
}

.skills .skill-content{
  max-height: 0;
  background:var(--accent-op-10);
  transition: max-height 0.2s ease;
  overflow:scroll;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  overflow: hidden;

  display: flex;
  justify-content: center;
  flex-direction: column;

  a {
    padding:5px 0;
    font-weight: bold;
  }


  input[type="text"], textarea {
    background:var(--bg-prompt);
    border:1px var(--text-op) solid;
    display: block;
    resize:none;
    width:auto;
  }

}

.skills label:has(input[type=checkbox]:checked) + .skill-content{
  max-height: 500px;
  padding:5px;
}

.skills label::before, .res-skill::before{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border:1px solid;
  border-radius:3px;

  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;

  height:1em;
  width:1em;
  content:'/';

  color:var(--text-op);
  margin-right:1em;

  padding:3px;

}

.skills label::after{
  font-family: 'Material Icons';
  content: 'chevron_right';

  font-size:150%;

  transition-duration:.2s;

  color:var(--text-op);
}

.skills label:has(input[type="checkbox"]:checked)::after{
  transform:rotate(90deg);
}

.create-skill{
  display: flex;
  align-items: center;
  justify-content: center;
  padding:5px;
  border-radius: 5px;

  user-select: none;

  font-weight: bold;
  cursor:pointer;

  background:var(--text-op);
  color:var(--text-op-high);

  margin-bottom:2em;
  transition-duration: .2s;

  &:hover{
    color:var(--text);
    background:var(--text-op);
  }

  &::before{
    content:'add';
    font-family: Material Icons;
    margin-right:5px;
    font-size:150%;
  }
}


.prompt-wrap .send-btn{
  background:var(--accent);
  border-radius: 50%;
  font-family: 'Material Icons';
  font-size:125%;
  cursor:pointer;
  user-select: none;

  display: flex;
  align-items: center;
  justify-content: center;

  width:1.6em;
  height:1.6em;

  color:var(--bg);

  &:not(.running)::after{
    content:'arrow_upward';
  }

  &.running::after{
    content:'stop';
  }

  &:not(.running).empty{
    opacity:.8;
    background:var(--text-op);
    color:var(--text-op);
    cursor:auto;
  }
}

.prompt-wrap .toolbox{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  margin-right: 1rem;
  gap:.5em;
}

.prompt-wrap .toolbox .add-btn{
  margin-left: 1rem;
  font-size: 150%;
  color:var(--text-op);
  margin-right: auto;
  font-family: Material Icons;
  user-select: none;
  cursor:pointer;
}

.prompt-wrap #prompt{
  padding:1rem;
  overflow:scroll;
  width:calc(100% - 2rem);

  caret-color: var(--accent);

  &::selection {
    background: var(--accent-op-30);
  }
}

.prompt-wrap {
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
  width:100%;
}

.prompt-wrap.wide, .prompt-wrap:has(.ctx-card){
  display: block;

  .toolbox{
    padding-bottom:1em;
  }
}




#prompt {
  max-height:20vh;
}

[contenteditable][data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-op);
  pointer-events: none;
  cursor: text;
  display: block;
}

mark {
  color:var(--accent);
  font-weight: bold;
  background: transparent;
}

.prompt-area{
  position:fixed;
  bottom:1em;
  left:0;
  width:calc(100% - 2rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding:0 1rem;
}

.suggestions{
  background:var(--high-bg);
  width:calc(100% - 3rem);
  margin-left:auto;
  margin-right:auto;

  border-radius: 5px 5px 0 0;
  overflow: scroll;
  max-height: 200px;

  &::-webkit-scrollbar {
    display: none;
  }
  scrollbar-width: none;

  span {
    text-decoration: none;
    border-radius: 5px;
    padding:5px 5px;
    display: block;
    user-select: none;
    cursor:pointer;
    overflow: scroll;
    overflow: hidden;

    &:hover{
      background:var(--current-op-10);
    }

    &.active{
      background:var(--current-op-10);
      color:var(--accent);
    }

  }
}


.prompt-area .suggestions {
  display: none;
}

.prompt-area:focus-within .suggestions {
  display: block;
}


span.tab-results {
  display: flex;
  align-items: center;
  gap: 1em;

  img {
    height: 1.2em;
    width: 1.2em;
    user-select: none;
    display: block;
  }

  a {
    font-size: 80%;
    color: var(--text-op-high);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    max-width: 100%;
  }
}

.ctx-cards {
  display: flex;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  user-select: none;

  &::-webkit-scrollbar {
    display: none;
  }

  &:has(.ctx-card){
    padding-left: 15px;
    padding-top: 15px;
  }
}

.ctx-card{
  flex: 0 0 auto;
  height:40px;
  width:150px;
  background:var(--text-op);
  border-radius: 1rem;
  cursor:pointer;
  overflow: scroll;
  padding:8px;
  overflow:hidden;
  display: inline-flex;
  margin-right:10px;

  img {
    display: block;
    height: 100%;
    width: 16px;
    margin: auto 0;
    background: var(--bg);
    border-radius: 8px;
    object-fit: contain;
    align-self: center;
    padding:0 10px;
  }

  div {
    margin-top:auto;
    margin-bottom:auto;
    width:100%;
    padding-left:5px;
    gap:5px;

    overflow: hidden;
    white-space: nowrap;
  }

  a, span {
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size:90%;
  }

  a {
    color:var(--current-op-50);
    font-size: 80%;
    font-weight: 500;
    margin-top:5px;
  }
}

.ctx-card.active-tab {
  order: -1 !important;
  background: color-mix(in srgb, var(--accent) 5%, var(--text-op) 95%);
}

.ctx-cards.msgPrev{
  position:relative;

  &:has(.ctx-card){
    height:100px;
  }

  &:hover:has(.ctx-card:nth-child(2)){
    height:auto;
    padding-top:60px;
    .ctx-card{
      position:static;
      transform:none;
    }
  }


  .ctx-card{
    position: absolute;
    right:0;
    bottom: 0;

    background: var(--high-bg);
    box-shadow: 0 2px 6px 0 var(--current-op-10);


    --spread:calc(90deg / var(--n));

    transform: rotate(calc(var(--spread) * var(--idx)));
    z-index:calc(var(--n) - var(--idx));
  }
}

.ctx-cards.msgPrev .ctx-card .after{
  display: none;
}


.ctx-cards:not(.msgPrev) {
  .ctx-card:hover, .ctx-card.active-tab{
    position:relative;
    overflow: visible;

    .after{
      display: block;
    }

    .after::after{
      content:'close';
      font-family: Material Icons;
      position:absolute;
      top:-.25em;
      right:-.25em;
      background:var(--text-op);
      border-radius: 50%;

      font-style: normal;

      height:1em;
      width: 1em;

      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}

mjx-container {
  pointer-events: none;
}

.markdown-body{
  font-family: Helvetica, sans-serif;
  padding:5px;

  h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
  }

  img {
    max-width: 100%;
  }

  a[href] {
    color:var(--accent-op-30);
    text-decoration: underline;
  }

  ul > li {
    list-style-type: disc;
  }

  li::marker{
    color:var(--current-op-20);
  }

  table {
    border-collapse: collapse;
    width: 100%;
  }

  tr {
    border-bottom: 1px solid var(--current-op-20);
  }

  thead tr {
    border-bottom: 1px solid var(--current-op-50);
  }

  td, th {
    padding: 8px;
    text-align: left;
  }
  

  th {
    font-weight: bold;
  }

  :not(pre) > code {
    background:var(--high-bg);
    border:1px solid var(--current-op-10);
    color:var(--current-op-40);
    font-size: 90%;
    border-radius: 3px;
    padding:1px 1px;
  }

  blockquote {
    padding:unset;
    margin-left:.5em;
    border-left:2px solid;
    padding:5px .5em;
    color:var(--current-op-50);
  }

  pre > code > span, pre > code {
    font-size:12px !important;
  }

  pre:has(code) {

  }

  pre pre {
    background:transparent !important;
    background:var(--bg) !important;
    padding:5px;
    border-radius: 0 0 10px 10px;
    overflow:scroll;
    box-shadow: 0 4px 24px 0 rgba(0,0,0,0.10), 0 1.5px 6px 0 rgba(0,0,0,0.08);
  }

  .codeblock-bar {
    background:var(--high-bg);
    margin-bottom:-5px;
    font-family: Arial, Helvetica, sans-serif;
    color:var(--current-op-50);
    display: flex;
    align-items: center;
    font-size: 1.2em;
    gap:1em;
    padding:5px;
    border-radius: 10px 10px 0 0;

    &::before{
      font-family: Material Icons;
      content:'terminal'
    }
  }

}

.cb-copy {
  cursor: pointer;
  color: var(--text);
  margin-left: auto;
  --cb-copy-icon: 'content_copy';
  transition: .2s;

  &::before {
    font-family: Material Icons;
    content: var(--cb-copy-icon);
  }

  &:active{
    transform:scale(0.8);
  }

  &.active::before {
    --cb-copy-icon: 'check';
    color: var(--accent-green);
  }
}


.msgs {
  height: calc(100vh - 2em);
  padding-bottom: 30vh;

  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  overflow:scroll;
  width:100%;

}

.msg-user {
  --temp-mag:0;

  position: relative;
  z-index:15;
  background: linear-gradient(var(--accent-op-30), var(--accent-op-20));
  padding: 8px 15px;
  border-radius: 1rem;
  display: block;
  width: fit-content;
  max-width: 70%;
  margin: 5px 0 5px auto;
  white-space: pre-wrap;
  overflow: scroll;
  overflow: hidden;

  margin-bottom:var(--temp-mag);

  animation: msgUserAppear 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes msgUserAppear {
  from {
    opacity:0;
    transform: translateY(100vh) scale(3);
  }
  to {
    opacity:1;
    transform: translateY(0) scale(1);
  }
}


.task-container:not(.done) .loading-text, :not(.done).thinking label {
  display: inline;
  background: linear-gradient(90deg, var(--text-op) 0%, var(--text-op-high) 50%, var(--text-op) 100%);
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2s linear infinite;
  user-select: none;

  white-space: nowrap;
}

@keyframes shimmer {
  0% {
    background-position-x: -200%;
  }
  100% {
    background-position-x: 200%;
  }
}

.task-container.done .loading-text{
  display: inline;
  color:var(--text-op);
  user-select: none;

  white-space: nowrap; 

  display: flex;
  align-items: center;

  &::before{
    font-family: Material Icons;
    content:'check';
    color:var(--green);
    margin-right:.5em;
  }

}

.task-container.done.fail .loading-text::before{
  content:'close';
  color:var(--accent-red);
}



.assist {
  --dim: 30px;
  --pad: 8px;

  color:var(--text-op);

  font-family: Material Icons;
  border: 1px solid var(--current-op-30);
  height: var(--dim);
  width: var(--dim);
  border-radius: 50%;
  box-sizing: border-box;

  flex: 0 0 auto;
  position: relative;
  z-index: 1;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition-duration:.2s;
  cursor:pointer;

  &:hover{
    transform:scale(1.1);
    background:var(--current-op-30);

    &::after{
      animation: rotate-border 2s linear infinite;
    }
  }
}

.assist::after {
  content: "";
  
  height:calc(var(--dim) - var(--pad));
  width:calc(var(--dim) - var(--pad));

  border: 2px dotted var(--text-op);
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;

  animation: rotate-border 3s linear infinite;
}

@keyframes rotate-border {
  100% {
    transform: rotate(360deg);
  }
}


.done .assist{
  animation: none;
  display:flex;

  &::after {
    animation: none !important;
  }

  &::after{

    align-self: center;
    color:var(--text-op-high);
    font-size: calc(var(--pad) * 1.2);
    display: flex;
    align-items: center;
    justify-content: center;

    font-family: Material Icons;
    content:'bolt';

    padding:calc(var(--dim)  - 2.8 * var(--pad)) !important;
  }
}

.task-container{
  --icon:'ads_click';

  display: flex;
  align-items: center;
  gap:.5em;


  padding:5px;

 -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
  mask-image: linear-gradient(to right, black 80%, transparent 100%);
  overflow: hidden;
}


.thinking input[type="checkbox"] {
  display: none;
}

.thinking .think-content {
  max-height: 0;
  overflow: hidden;
  margin: 15px 0 0 0;
  list-style: none;
  position: relative;
  display: block;
  font-size:85%;

  color:var(--text-op-high);

  padding:0;

  filter:blur(5px);

  transition: .15s;

  padding-left:50px;



  li {
    position: relative;
    padding-bottom: 2em;
  }

  li::before{
    content: '';
    position: absolute;
    left: -1em;
    top: .25em;
    width: .5em;
    height: .5em;
    background:var(--current-op-50);
    border-radius: 50%;
    z-index: 1;
  }

  li.done::before{
    content:'check_circle_outlined';
    font-family: Material Icons;
    color:var(--current-op-50);
    background:none;
    left:-1.25em;
    top:-.125em;
  }

  li.asking {
    font-style: italic;
  }

  li:last-child:not(.done)::before {
    background:var(--green);
    animation:pulse 1.5s infinite;
  }

  li:last-child:not(.done){
    animation:1s opacipulse 1s infinite;
  }

  li:not(:last-child):after {
    content: '';
    position: absolute;
    left: calc(-.75em - 1px);
    top: 1em;
    width: 1px;
    height: calc(100% - 1em);
    background: var(--text-op);
  }

}

.thinking label:has(input[type="checkbox"]:checked) + .think-content {
  max-height: 200vh;
  padding: 0;
  padding-left:50px;
  filter:none;

}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 var(--green);
    opacity: 1;
  }
  70% {
    box-shadow: 0 0 0 10px transparent;
    opacity: 0.7;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
    opacity: 1;
  }
}

@keyframes opacipulse{
  0% {
    opacity:1;
  }
  50%{
    opacity:.75;
  }
  100%{
    opacity:1;
  }
}


/* .thinking label::before{
  font-family: Material Icons;
  content:'chevron_right';
  color:var(--text-op);
}

.thinking label:has(input[type="checkbox"]:checked)::before {
  transform:rotate(90deg);
} */

.thinking label{
  display: inline-flex !important;
  align-items: center;
  cursor:pointer;
  transition:.2s;
  padding:5px;
  gap:.5em;
  user-select: none;

  &::before{
    transition:.1s;
  }
}


.done.thinking label{

  display: inline-flex;
  color:var(--text-op-high);
  user-select: none;

  white-space: nowrap; 
  align-items: center;

  &::after{
    font-family: Material Icons;
    content:'check';
    color:var(--green);
    margin-right:.5em;
  }

}

.thinking{
  display: none;
}