:root {
  --bg: #fff;
  --panel: #ffffff;
  --text: #161616;
  --muted: #777;
  --line: #e4e4e4;
  --assistant: #ffffff;
  --user: #ececec;
  /* Squircle presets */
  --composer-radius-soft: 36px;
  --composer-squircle-soft: 60;
  --composer-radius-medium: 28px;
  --composer-squircle-medium: 95;
  --composer-radius-sharp: 22px;
  --composer-squircle-sharp: 140;

  /* Active preset (switch these two lines) */
  --composer-radius: var(--composer-radius-medium);
  --composer-squircle: var(--composer-squircle-medium);
  --content-width: 760px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

input,
button,
textarea {
  font-family: inherit;
}

.app-shell {
  height: 100dvh;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  padding-bottom: 10px;
}

.chat-header {
    width: 100%;
    justify-self: center;
    min-height: 30px;
    /* border: 1px solid var(--line); */
    /* border-radius: 999px; */
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px;
    position: relative;
    box-shadow: box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1) ;
}

.chat-header-left,
.chat-header-right {
  width: 50%;
  display: flex;
  align-items: center;
}

.chat-header-left {
  justify-content: flex-start;
}

.chat-header-right {
  justify-content: flex-end;
}

.chat-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
  line-height: 0;
}

.chat-menu-trigger {
  border: 0;
  background: transparent;
  color: #222;
  width: 20px;
  height: 20px;
  border-radius: 0;
  cursor: pointer;
  line-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.chat-menu-trigger:hover {
  opacity: 0.8;
}

.chat-menu-trigger[aria-expanded="true"] {
  opacity: 0.65;
}

.chat-menu-trigger-icon {
  width: 26px;
  height: 26px;
  margin-right:6px;
  object-fit: contain;
  display: block;
}

.chat-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  padding: 6px 3px 6px 3px;

  z-index: 12;
}

.chat-menu-item {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  font-size: 0.92rem;
  color: #222;
  cursor: pointer;
}

.chat-menu-item:hover {
  background: #f2f2f2;
  color:#000;
}

.chat-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-menu-item:disabled:hover {
  background: transparent;
}

.chat-feed {
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  scroll-behavior: smooth;
  padding: 0;
  padding-bottom: 60px;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 36px,
    #000 calc(100% - 72px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 36px,
    #000 calc(100% - 72px),
    transparent 100%
  );
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 120, 0.55) transparent;
}

.chat-feed::-webkit-scrollbar {
  width: 9px;
}

.chat-feed::-webkit-scrollbar-track {
  background: transparent;
}

.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 120, 0.5);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chat-feed::-webkit-scrollbar-thumb:hover {
  background: rgba(95, 95, 95, 0.65);
}

.chat-feed::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.chat-feed::-webkit-scrollbar-button:single-button {
  display: none;
  width: 0;
  height: 0;
}

.chat-feed::-webkit-scrollbar-button:vertical:decrement {
  display: none;
  width: 0;
  height: 0;
}

.chat-feed::-webkit-scrollbar-button:vertical:increment {
  display: none;
  width: 0;
  height: 0;
}

.chat-feed .msg:first-child {
  margin-top: calc(100vh * 200 / 1080);
}

.attachment-row {
  width: min(var(--content-width), 100%);
  justify-self: center;
}

.attachment-preview{
  width: min(var(--content-width), 100%);
}

.attachment-pill {
  justify-self: auto;
  width: fit-content;
  max-width: min(var(--content-width), 100%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #d4d4d4;
  background: #f4f4f4;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: #111;
  margin: 0;
}

.pill-clear {
  border: 0;
  background: #111;
  color: #fff;
  border-radius: 999px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 12px;
  font-weight: 600;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols", "Segoe UI", sans-serif;
  padding: 0;
  cursor: pointer;
}

.msg {
  display: flex;
  margin: 60px 0px;
  width: min(var(--content-width), 100%);
  margin-left: auto;
  margin-right: auto;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 220ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.msg.entering {
  opacity: 0;
  transform: translateY(8px);
}

.msg.assistant {
  justify-content: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: min(680px, 86%);
  border: 1px solid var(--line);
  border-radius: 27px;
  padding: 9px 16px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.msg.assistant .bubble strong {
    text-shadow: none;
    font-weight: 600;
    color: #000000;
}

.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
}

.eclipse {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #424242 0%, #6d6d6d 70%);
  position: relative;
  overflow: hidden;
}

.eclipse::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.9) 48%, transparent 100%);
  transform: translateX(-120%);
  animation: riffle 1.1s linear infinite;
}

@keyframes riffle {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

.thinking-label {
  font-size: 0.9rem;
  color: #666;
}

.msg.assistant .bubble {
  background: var(--assistant);
  border: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.msg.assistant .bubble.assistant-enter {
  animation: assistantMessageIn 220ms ease-out both;
}

@keyframes assistantMessageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bubble.md {
  display: block;
}

.bubble.md p {
  margin: 0;
}

.bubble.md p + p {
  margin-top: 8px;
}

.bubble.md ul {
  padding-left: 18px;
}

.bubble.md li + li {
  
}

.bubble.md code {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 1px 5px;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
}

.quick-reply-inline {
    margin: 2px;
    border: 0;
    background: transparent;
    color: #000408;
    font: inherit;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-style: solid;
    text-decoration-color: #0080ff;
}

.quick-reply-inline::after {
  content: " \21AA";
  opacity: 0;
  transition: opacity 120ms ease;
}

.quick-reply-inline:hover {
  opacity: 0.75;
}

.quick-reply-inline:hover::after {
  opacity: 1;
}

.initial-assistant-message {
  transition: margin-top 420ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.initial-assistant-message .bubble {
  opacity: 1;
  transition: font-size 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    line-height 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    padding 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-radius 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    text-shadow 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.chat-feed .initial-assistant-message.hero:first-child {
  margin-top: calc(100vh * 360 / 1080);
  justify-content: center;
}

.initial-assistant-message.hero .bubble {
  background: transparent;
  border: 0;
  box-shadow: none;
  text-shadow: none;
  color: #171717;
  font-size: clamp(1.55rem, 2.2vw, 2rem);
  line-height: 1.2;
  padding: 0;
  max-width: min(820px, 96%);
  text-align: center;
}

.msg.user .bubble {
  font-weight: 400;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  background: var(--user);
  box-shadow: 0 1px 5px rgba(17, 24, 39, 0.08);
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: min(var(--content-width), 100%);
  justify-self: center;
  border: 1px solid #d6d6d6;
  border-radius: var(--composer-radius);
  background: var(--panel);
  padding: 13px 17px 13px 17px;
  box-shadow: 0 3px 7px rgba(17, 24, 39, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  margin-bottom: 0;
  --float-offset: 0px;
  --dock-start-offset: 0px;
  transform: translateY(0);
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1), padding 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
  /* Fallback squircle approximation for browsers without corner-shape support. */
  clip-path: superellipse(0.5 / calc(var(--composer-squircle) * 1%));
}

.composer.floating {
  transform: translateY(var(--float-offset)) scale(1.08);
  padding: 16px;
}

.composer.docking {
  animation: dockComposer 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dockComposer {
  0% {
    transform: translateY(var(--dock-start-offset)) scale(1.08);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@supports (corner-shape: squircle) {
  .composer {
    corner-shape: squircle;
    clip-path: none;
  }
}

.icon-btn,
.send-btn {
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-btn {
  background: #f4f4f4;
  color: #333;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 0;
  line-height: 0;
  padding: 0;
  position: relative;
  transition: background-color 160ms ease, color 160ms ease;
}

.icon-btn:hover {
  background: #111;
  color: #fff;
}

.icon-btn::before {
  content: "+";
  font-size: 30px;
  line-height: 1;
  transform: translateY(-1px);
}

.send-btn {
  background: #111;
  color: #fff;
  font-size: 14px;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

#prompt {
  resize: none;
  min-height: 24px;
  max-height: 180px;
  overflow-y: auto;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 1.03rem;
  color: var(--text);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

#prompt::placeholder {
  color: #999;
}

.meta {
  height: 18px;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 1;
  transition: opacity 240ms ease;
}

.meta.meta-fading {
  opacity: 0;
}

.hidden {
  display: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid #dedede;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  padding: 24px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.auth-card p {
  margin: 0 0 14px;
  color: #666;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input,
.auth-form button {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
}

.auth-form input {
  border: 1px solid #d9d9d9;
}

.auth-form button {
  border: 0;
  background: #111;
  color: #fff;
  cursor: pointer;
}

.auth-trust-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: #444;
}

.auth-trust-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.auth-toggle,
.auth-signout {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: var(--user);
  color: var(--text);
  border-radius: 27px;
  padding: 9px 16px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 400;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 5px rgba(17, 24, 39, 0.08);
}

.auth-status {
  min-height: 20px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #666;
}

.hidden-file-input {
  display: none;
}

.settings-shell {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  background:
    radial-gradient(circle at top left, rgba(0, 0, 0, 0.04), transparent 30%),
    linear-gradient(180deg, #fafafa 0%, #f2f2f2 100%);
}

.settings-page {
  min-height: 0;
  overflow-y: auto;
  padding: 28px 18px 36px;
}

.settings-grid {
  width: min(100%, 880px);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.settings-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
}

.settings-card h1,
.settings-card h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
  line-height: 1.1;
}

.settings-eyebrow {
  margin: 0 0 10px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #707070;
}

.settings-eyebrow-danger {
  color: #a43a3a;
}

.settings-copy {
  margin: 0 0 18px;
  color: #5f5f5f;
  line-height: 1.5;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-field {
  display: grid;
  gap: 8px;
}

.settings-field span {
  font-size: 0.92rem;
  font-weight: 600;
  color: #222;
}

.settings-field input {
  width: 100%;
  border: 1px solid #d7d7d7;
  border-radius: 14px;
  background: #fff;
  padding: 13px 14px;
  font-size: 0.98rem;
  color: #171717;
}

.settings-field input:focus {
  outline: none;
  border-color: #888;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.06);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.settings-primary,
.settings-danger {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
}

.settings-primary {
  background: #151515;
  color: #fff;
}

.settings-danger {
  background: #a73c3c;
  color: #fff;
}

.settings-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.92rem;
  color: #5f5f5f;
}

.settings-status.is-error {
  color: #a73c3c;
}

.settings-card-danger {
  border-color: rgba(167, 60, 60, 0.2);
}

.settings-back-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: #222;
  text-decoration: none;
  font-size: 0.92rem;
}

.settings-back-link:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
  .app-shell {
    height: 100dvh;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  }

  .chat-feed .msg:first-child {
    margin-top: 24px;
  }

  .chat-feed .initial-assistant-message.hero:first-child {
    margin-top: 24px;
    justify-content: flex-start;
  }

  .initial-assistant-message.hero .bubble {
    text-align: left;
    font-size: clamp(1.2rem, 6vw, 1.45rem);
    line-height: 1.25;
  }

  .msg {
    margin: 18px 0;
  }

  .chat-feed {
    padding-bottom: 16px;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .composer {
    margin-bottom: 0;
    padding: 10px;
  }

  .chat-header {
    min-height: 28px;
  }

  .icon-btn,
  .send-btn {
    width: 40px;
    height: 40px;
  }

  .bubble {
    max-width: 92%;
    padding: 6px 14px;
  }

  .settings-page {
    padding: 16px 12px 24px;
  }

  .settings-card {
    padding: 18px;
    border-radius: 20px;
  }

  .settings-actions {
    align-items: stretch;
  }

  .settings-primary,
  .settings-danger {
    width: 100%;
  }
}


