:root {
  --bg: #0b0b11;
  --panel: #14141f;
  --panel-alt: #1b1b28;
  --accent: #ff2fb9;
  --accent-glow: #ff74d1;
  --text: #e5e5ea;
  --danger: #ff3860;
  --warn: #ffaa2b;
  --muted: #7a7a86;
  --muted-alt: #6d6d78;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen;
}

* {
  box-sizing: border-box
}

html, body { height:100%; }
/* Establish single flex column layout so only main scrolls (avoid double page + inner scroll) */
body { margin:0; background: var(--bg); color: var(--text); font: 500 14px/1.5 var(--font, inherit); -webkit-font-smoothing: antialiased; display:flex; flex-direction:column; min-height:100%; overflow:hidden; }
/* Main is the scroll container (y) while header/footer stay fixed in flow */
main { flex:1 1 auto; overflow:auto; -webkit-overflow-scrolling:touch; }
body.modal-open main { filter:blur(0); }
body.modal-open { touch-action: none; }
main { width: min(900px, 94%); margin: 1.4rem auto 2.6rem; padding-bottom:1rem; }
@media (max-width:640px){ main { width:100%; margin: .9rem auto 1.2rem; } }
header.site-header {
  padding: 1.35rem 1.6rem 1.55rem;
  background: linear-gradient(90deg, #1d1d2b, #101018);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #242436;
}

header .site-title {
  margin: 0;
  font-size: 1.85rem;
  letter-spacing: .18em;
  font-weight: 700;
  position: relative;
  text-align: center
}

header .site-title span {
  display: inline-block;
  animation: glitch 3s infinite
}

@media (prefers-reduced-motion:reduce) {
  header h1 span {
    animation: none
  }
}

@keyframes glitch {

  0%,
  95%,
  100% {
    text-shadow: 0 0 0 rgba(255, 47, 185, 0)
  }

  10% {
    text-shadow: 2px -2px 0 #ff2fb9, -2px 2px 0 #5a84ff
  }

  11% {
    text-shadow: -2px 2px 0 #ff2fb9, 2px -2px 0 #5a84ff
  }

  12% {
    text-shadow: 1px -1px 0 #ff2fb9, -1px 1px 0 #5a84ff
  }
}

form {
  background: var(--panel);
  border: 1px solid #242436;
  padding: 1rem 1rem 1.25rem;
  border-radius: 14px;
  position: relative;
  box-shadow: 0 8px 30px -12px #ff2fb920, 0 2px 4px -1px #000 inset
}

form:before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, #ff2fb9, #5a84ff 55%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .55;
  pointer-events: none
}

label.visually-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden
}

.charline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .62rem;
  letter-spacing: .08em;
  color: var(--muted-alt);
  margin-top: .45rem;
  text-transform: uppercase
}

.cooldown {
  color: var(--warn);
  font-weight: 600
}

form textarea {
  width: 100%;
  background: #0f0f17;
  color: var(--text);
  border: 1px solid #2d2d40;
  border-radius: 10px;
  padding: .85rem 1rem;
  resize: vertical;
  min-height: 90px;
  font: 500 .95rem/1.35 var(--font, inherit);
  outline: none;
  box-shadow: 0 0 0 0 rgba(255, 47, 185, 0);
  transition: box-shadow .25s, border-color .25s;
  overflow-wrap: anywhere
}

form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #ff2fb922
}

form button {
  margin-top: .85rem;
  background: linear-gradient(120deg, var(--accent), #5a84ff);
  color: #fff;
  border: none;
  padding: .75rem 1.1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  font-size: .9rem;
  letter-spacing: .05em;
  box-shadow: 0 4px 18px -6px #ff2fb9aa;
  transition: transform .15s, box-shadow .3s, filter .3s, opacity .3s
}

form button[disabled] {
  cursor: not-allowed;
  filter: grayscale(.4) brightness(.7);
  opacity: .55
}

form button:hover {
  filter: brightness(1.15)
}

form button:active { transform: translateY(2px); box-shadow: 0 2px 10px -4px #ff2fb9aa }

footer { padding: 1rem 1.25rem 1.1rem; text-align:center; font-size:.7rem; color:var(--muted-alt); flex:0 0 auto; }

.legal-links {
  margin-top: .5rem;
  font-size: .65rem
}

.legal-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color .25s
}

.legal-links a:hover {
  color: var(--accent-glow);
  text-decoration: underline
}

a {
  color: var(--accent-glow);
  text-decoration: none
}

a:hover {
  text-decoration: underline
}

.tagline {
  font-size: 1.2rem;
  margin: .2rem 0 1rem;
  color: var(--muted);
  line-height: 1.3
}

.shake {
  animation: shake .4s linear
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  25% {
    transform: translateX(-3px)
  }

  50% {
    transform: translateX(3px)
  }

  75% {
    transform: translateX(-2px)
  }
}

.status {
  position: absolute;
  bottom: .55rem;
  right: .75rem;
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent-glow);
  opacity: .75;
  pointer-events: none
}

.status.busy:after {
  content: 'TYPING...'
}

.status.idle:after {
  content: 'IDLE';
  color: #555
}

.status.cooldown:after {
  content: 'COOLDOWN';
  color: var(--warn)
}

.credits {
  margin-top: .8rem;
  font-size: .8rem;
  opacity: .6
}

.limit-hit {
  color: var(--warn);
  font-weight: 600
}

/* History now grows naturally; uses global scrollbar theme */
.history { margin-top:1.2rem; display:flex; flex-direction:column; gap:.55rem; padding:.6rem .65rem .75rem; background:var(--panel-alt); border:1px solid #242436; border-radius:12px; font-size:.75rem; line-height:1.25; }

.history h2 {
  margin: .15rem 0 .35rem;
  font-size: .55rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-alt)
}

.bubble {
  padding: .55rem .65rem .6rem;
  border-radius: 8px;
  position: relative;
  background: #181823;
  border: 1px solid #272a3a;
  animation: fadeIn .3s ease;
  cursor: pointer
}

.bubble.user {
  background: #202034;
  border-color: #303652
}

.bubble.assistant {
  background: #191a27
}

.bubble:hover {
  border-color: var(--accent)
}

.bubble small {
  display: block;
  font-size: .55rem;
  opacity: .55;
  margin-top: .35rem;
  letter-spacing: .05em
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.history-limit {
  font-size: .55rem;
  text-align: right;
  margin-top: .3rem;
  color: var(--muted-alt)
}

.history-limit span {
  color: var(--accent-glow)
}

.tw-cursor {
  display: inline-block;
  width: .65ch;
  background: linear-gradient(120deg, var(--accent), #5a84ff);
  animation: blink 1s steps(1, end) infinite;
  margin-left: 2px
}

@keyframes blink {

  0%,
  50% {
    opacity: 1
  }

  51%,
  100% {
    opacity: 0
  }
}

.history-section {
  margin-top: 1rem
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .2rem .3rem
}

.history-head h2 {
  margin: 0;
  font-size: .6rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-alt)
}

.btn-ghost {
  background: #1f1f2c;
  border: 1px solid #33364a;
  color: var(--muted);
  font-size: .55rem;
  padding: .35rem .55rem;
  border-radius: 7px;
  cursor: pointer;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: background .25s, color .25s
}

.btn-ghost:hover {
  background: #272a38;
  color: var(--accent-glow)
}

body.history-collapsed #history {
  display: none
}

body.history-collapsed #history-toggle {
  color: var(--accent-glow)
}

/* Adjust form / textarea for mobile */
@media (max-width:640px) {
  header.site-header {
    padding: .75rem .7rem .85rem
  }

  header .site-title {
    font-size: 1.25rem;
    letter-spacing: .12em
  }

  .tagline {
    font-size: .95rem;
    line-height: 1.25;
    margin: .3rem 0 .8rem
  }

  main {
    margin: .4rem auto 1rem;
    padding: 0 .7rem
  }

  form {
    padding: .8rem .8rem 1rem
  }

  form textarea {
    min-height: 130px;
    font-size: .88rem;
    padding: .75rem .85rem
  }

  .actions-row {
    display: flex;
    align-items: stretch;
    gap: .55rem;
    margin-top: .6rem
  }

  #ask-btn {
    flex: 1 1 auto;
    margin-top: 0
  }

  .fresh-btn {
    margin-left: 0;
    padding: .55rem .65rem;
    font-size: .5rem;
    letter-spacing: .16em
  }

  .status {
    position: static;
    margin-top: .5rem;
    font-size: .5rem;
    letter-spacing: .14em;
    display: inline-block
  }


  /* Let history expand; overall scroll handled by main */
  .history { max-height:none; }

  .copy-btn {
    top: .45rem;
    right: .45rem
  }
}

@media (max-width:480px) {
  form textarea {
    min-height: 120px
  }


  #history-toggle {
    font-size: .5rem;
    padding: .3rem .5rem
  }

  header .site-title {
    font-size: 1.15rem;
    letter-spacing: .12em
  }

  .fresh-btn {
    font-size: .48rem;
    padding: .5rem .6rem
  }

  .status {
    font-size: .48rem
  }
}

/* Safe area adjustments for iOS inside Telegram */
@supports(padding:max(0px)) {
  footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* Usage bar */
.usage-bar {
  margin: .4rem 0 .6rem;
  font-size: .6rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: #1d1d2a;
  padding: .45rem .65rem;
  border: 1px solid #272a3a;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: .6rem
}

.usage-bar span {
  color: var(--accent-glow)
}

/* Elevated badge (admin/tester unlimited) */
.elevated-badge {
  display: inline-block;
  background: linear-gradient(120deg, #ff2fb9, #5a84ff);
  padding: .35rem .6rem;
  font-size: .55rem;
  letter-spacing: .12em;
  font-weight: 600;
  border-radius: 10px;
  margin: 0 0 .6rem;
  border: 1px solid #2d2d40;
  box-shadow: 0 4px 14px -6px #ff2fb955;
  text-transform: uppercase;
}

/* Legal modal */
.legal-modal {
  position: fixed;
  inset: 0;
  background: rgba(10,10,16,.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}
.legal-modal[hidden]{ display:none !important; }
.legal-modal-inner {
  width: min(900px, 94%);
  max-height: 88vh;
  background: #161623;
  border: 1px solid #2d2f40;
  border-radius: 18px;
  box-shadow: 0 10px 48px -18px #000, 0 0 0 1px #24263a inset;
  padding: 1.2rem 1.25rem 1.6rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.legal-modal-inner h2 { margin: .1rem 0 1rem; font-size: 1.1rem; letter-spacing: .05em; }
.legal-modal-body { flex: 1 1 auto; overflow:auto; font-size: .75rem; line-height: 1.45; padding: .6rem .4rem .4rem .1rem; }
.legal-modal-body h1, .legal-modal-body h2, .legal-modal-body h3 { margin-top: 1.2rem; }
.legal-modal-body h1 { font-size: 1.05rem; }
.legal-modal-body h2 { font-size: .95rem; }
.legal-modal-body h3 { font-size: .85rem; }
.legal-modal-body p { margin: .5rem 0 .9rem; }
.legal-modal-body ul { margin: .4rem 0 .9rem; padding-left: 1.1rem; }
.legal-modal-body li { margin: .25rem 0; }
.legal-modal-body .effective-date { color: #888; font-style: italic; }
.legal-modal-body .warning, .legal-modal-body .highlight { background:#1f1f2c; border:1px solid #30364a; padding:.75rem .85rem; border-radius:8px; font-size:.7rem; }
.legal-close { position:absolute; top:.55rem; right:.6rem; background:#222432; border:1px solid #34384c; color:#aaa; width:34px; height:34px; border-radius:50%; cursor:pointer; font-size:1.1rem; line-height:1; display:flex; align-items:center; justify-content:center; }
.legal-close:hover { color:#fff; border-color:var(--accent); }
.legal-modal-inner:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width:640px){
  .legal-modal-inner { padding: .9rem .9rem 1.2rem; border-radius:16px; }
  .legal-modal-body { font-size: .72rem; }
}

/* Payment overlay */
.pay-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 16, .78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500
}

/* Ensure hidden attribute actually hides overlay (was still flex due to default rule) */
.pay-overlay[hidden] {
  display: none !important
}

.pay-card {
  width: min(420px, 92%);
  background: #161623;
  border: 1px solid #272a3a;
  border-radius: 18px;
  padding: 1.25rem 1.15rem 1.4rem;
  position: relative;
  box-shadow: 0 6px 38px -12px #000, 0 0 0 1px #202030 inset
}

.pay-card h3 {
  margin: .1rem 0 .55rem;
  font-size: 1rem;
  letter-spacing: .04em
}

.pay-card p {
  margin: .2rem 0 .9rem;
  font-size: .75rem;
  line-height: 1.4;
  color: var(--muted)
}

.pay-details {
  font-size: .65rem;
  letter-spacing: .08em;
  margin-bottom: 1rem;
  color: var(--muted-alt)
}

.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem
}

.pay-actions button {
  flex: 1 1 auto
}

.pay-actions .primary {
  background: linear-gradient(120deg, var(--accent), #5a84ff);
  color: #fff;
  border: none
}

.pay-actions .ghost {
  background: #1f1f2c;
  border: 1px solid #34384c;
  color: var(--muted)
}

.pay-actions .ghost:hover {
  color: var(--accent-glow);
  border-color: var(--accent)
}

.pay-card button.primary:hover {
  filter: brightness(1.15)
}

.pay-card .close {
  position: absolute;
  top: .55rem;
  right: .6rem;
  background: #222432;
  border: 1px solid #34384c;
  color: #aaa;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center
}

.pay-card .close:hover {
  color: #fff;
  border-color: var(--accent)
}

/* Fresh toggle & context indicator */
.actions-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .85rem
}

#ask-btn {
  flex: 1 1 auto
}

.fresh-btn {
  margin-left: .75rem;
  background: #1f1f2c;
  border: 1px solid #33364a;
  color: var(--muted);
  font-size: .55rem;
  padding: .6rem .8rem;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: .14em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .25s, color .25s, border-color .25s, filter .25s;
  min-width: 84px;
  justify-content: center
}

.fresh-btn:hover {
  color: var(--accent-glow);
  border-color: var(--accent)
}

.fresh-btn.on {
  background: linear-gradient(120deg, var(--accent), #5a84ff);
  color: #fff;
  border-color: #5a84ff;
  box-shadow: 0 0 0 1px #ff2fb94a, 0 4px 14px -6px #ff2fb9aa
}

/* NSFW (uncensored) toggle variant when active */
#uncensored-toggle.on {
  background: linear-gradient(120deg, #ff3860, #ff2fb9);
  border-color: #ff3860;
  box-shadow: 0 0 0 1px #ff38604a, 0 4px 14px -6px #ff386099;
}
#uncensored-toggle.on:hover { filter:brightness(1.08); }

/* Mode badge inside response modal */
.mode-badge.nsfw {
  background: linear-gradient(120deg,#ff3860,#ff2fb9);
  color:#fff;
  font-size:.55rem;
  letter-spacing:.14em;
  text-transform:uppercase;
  padding:.4rem .55rem;
  border-radius:8px;
  border:1px solid #ff5174;
  box-shadow:0 0 0 1px #ff2fb94a, 0 2px 10px -4px #ff2fb977;
  font-weight:600;
}

.fresh-btn.on:hover {
  filter: brightness(1.07)
}

.ctx-indicator {
  position: fixed;
  bottom: .85rem;
  right: .85rem;
  background: #1d1d2a;
  border: 1px solid #303549;
  padding: .45rem .6rem;
  font-size: .55rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-radius: 9px;
  color: var(--accent-glow);
  opacity: .85;
  backdrop-filter: blur(3px);
  z-index: 200
}

.ctx-indicator.off {
  color: var(--muted);
  border-style: dashed;
  opacity: .55
}

/* Markdown / code styling */
.response-body code {
  background: #1f1f2c;
  border: 1px solid #2d2f42;
  padding: .15rem .35rem;
  border-radius: 6px;
  font-size: .8em;
  font-family: ui-monospace, Consolas, "SFMono-Regular", Menlo, monospace
}

.response-body pre {
  background: #10131d;
  border: 1px solid #2a2d3f;
  padding: .9rem 1rem;
  border-radius: 10px;
  overflow: auto;
  font-size: .75em;
  line-height: 1.4;
  font-family: ui-monospace, Consolas, "SFMono-Regular", Menlo, monospace;
  position: relative
}

.response-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit
}

.response-body h1,
.response-body h2,
.response-body h3 {
  margin: 1rem 0 .4rem;
  font-weight: 600;
  line-height: 1.2
}

.response-body h1 {
  font-size: 1.05em;
  border-bottom: 1px solid #26293a;
  padding-bottom: .3rem
}

.response-body h2 {
  font-size: .95em;
  border-bottom: 1px solid #26293a;
  padding-bottom: .25rem
}

.response-body h3 {
  font-size: .9em
}

.response-body ul,
.response-body ol {
  margin: .5rem 0 .8rem;
  padding-left: 1.3rem
}

.response-body li {
  margin: .25rem 0
}

.response-body blockquote {
  margin: .7rem 0;
  padding: .6rem .9rem;
  border-left: 3px solid var(--accent);
  background: #181a26;
  border-radius: 6px;
  font-style: italic;
  color: #c8c8d2
}

.response-body table {
  width: 100%;
  border-collapse: collapse;
  margin: .9rem 0;
  font-size: .75rem
}

.response-body th,
.response-body td {
  border: 1px solid #303347;
  padding: .4rem .55rem;
  text-align: left
}

.response-body th {
  background: #1e1f2b;
  font-weight: 600
}

.response-body hr {
  border: none;
  border-top: 1px solid #2a2d3c;
  margin: 1rem 0
}

/* Response modal (reading overlay) */
.response-modal { position:fixed; inset:0; background:rgba(12,12,18,.86); backdrop-filter: blur(10px); display:flex; align-items:center; justify-content:center; z-index:800; }
.response-modal[hidden]{ display:none !important; }
.response-modal-inner { width:min(980px,95%); max-height:90vh; background:#14141f; border:1px solid #24263a; border-radius:22px; box-shadow:0 14px 60px -22px #000,0 0 0 1px #272a3a inset; display:flex; flex-direction:column; padding:1rem 1.1rem 1.2rem; animation:popIn .35s ease; position:relative; }
@keyframes popIn { from { transform:translateY(8px) scale(.96); opacity:0;} to { transform:translateY(0) scale(1); opacity:1;} }
.response-modal-head { display:flex; align-items:center; justify-content:space-between; gap:.6rem; padding: .15rem .1rem .55rem; border-bottom:1px solid #1f1f2c; }
.response-title { margin:0; font-size:1rem; letter-spacing:.06em; font-weight:600; }
.response-head-actions { display:flex; gap:.5rem; align-items:center; }
.resp-btn { background:#1f1f2c; border:1px solid #303549; color:var(--muted); font-size:.55rem; letter-spacing:.11em; padding:.5rem .75rem; border-radius:8px; cursor:pointer; text-transform:uppercase; font-weight:600; transition:background .25s,color .25s,border-color .25s,filter .25s; }
.resp-btn:hover:not([disabled]) { background:#272a38; color:var(--accent-glow); }
.resp-btn.secondary { background:#24263a; border-color:#303549; }
.resp-btn.secondary:hover { background:#2c3044; }
.resp-btn:disabled { opacity:.45; cursor:not-allowed; }
.resp-close { background:#222432; border:1px solid #34384c; color:#aaa; width:34px; height:34px; border-radius:50%; font-size:1.05rem; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.resp-close:hover { color:#fff; border-color:var(--accent); }
.response-question { font-size:.65rem; letter-spacing:.09em; text-transform:uppercase; color:var(--muted-alt); margin:.65rem .1rem .4rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.response-body { flex:1 1 auto; overflow:auto; font-size:.78rem; line-height:1.45; padding:.4rem .2rem .6rem .1rem; scrollbar-width: thin; }
/* Response body uses global scrollbar theme */
.response-body.loading { opacity:.35; }
/* width adjustments handled globally */
.response-footer-bar { display:flex; justify-content:flex-end; gap:.6rem; padding:.55rem .2rem 0; border-top:1px solid #1f1f2c; margin-top:.4rem; }
@media (max-width:640px){
  .response-modal-inner { padding:.85rem .85rem 1rem; border-radius:18px; }
  .response-body { font-size:.74rem; }
  .response-title { font-size:.9rem; }
  .resp-close { width:30px; height:30px; }
}

/* Upgrade button inside modal footer */
.upgrade-btn { background:linear-gradient(120deg,#ff2fb9,#5a84ff); color:#fff; border:none; padding:.55rem .85rem; border-radius:8px; font-size:.6rem; letter-spacing:.1em; font-weight:600; text-transform:uppercase; cursor:pointer; box-shadow:0 4px 16px -6px #ff2fb966; }
.upgrade-btn:hover { filter:brightness(1.12); }

/* === Mobile Accessibility & Readability Enhancements (Aug 2025 incremental, non-breaking) === */
/* Rationale: Many meta/timestamp/button texts were below ~11px effective size hurting readability on high-density mobile screens.
   This block raises minimum sizes, adjusts letter-spacing, improves line-height, and adds safe-area & overflow robustness.
   All changes are conservative and can be reverted by removing this section. */

/* Base adjustments: raise smallest reused tokens */
@media (max-width:640px) {
  body { font-size: 16px; }
  main { padding: 0 .8rem 1.25rem; }
  form { padding: .9rem .9rem 1.1rem; }
  form textarea { line-height: 1.5; font-size: .95rem; }
  form button { font-size: 1rem; padding:.8rem 1.15rem; }
  .history { font-size: .84rem; line-height: 1.38; }
  .bubble small { font-size: .62rem; letter-spacing: .035em; }
  .charline, .history h2, .history-limit, .btn-ghost, .fresh-btn, .resp-btn, .response-question { letter-spacing: .075em; }
  .btn-ghost, .fresh-btn, .resp-btn { font-size: .66rem; }
  .fresh-btn { padding: .6rem .75rem; min-height: 40px; }
  .response-body { font-size: .86rem; line-height: 1.6; }
  .response-body p { margin: .6rem 0 1rem; }
  .response-modal-inner { max-height: 93vh; }
  .ctx-indicator { padding: .6rem .8rem; font-size: .62rem; bottom: calc(.9rem + env(safe-area-inset-bottom)); }
}

/* Extremely small width devices */
@media (max-width:360px) {
  body { font-size: 15px; }
  main { padding: 0 .65rem 1.1rem; }
  .response-body { font-size: .84rem; }
  .history { max-height:none; }
}

/* Allow long unbroken content to wrap in bubbles & response areas */
.bubble, .response-body { overflow-wrap: anywhere; word-break: break-word; }

/* Improve focus visibility on interactive small elements */
button:focus-visible, .fresh-btn:focus-visible, .resp-btn:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Slightly brighter muted text for tiny font usage for contrast */
@media (max-width:640px) {
  :root { --muted: #8a8a96; --muted-alt: #80808c; }
}

/* Prefer reduced motion: disable shake/glitch animations fully */
@media (prefers-reduced-motion: reduce) {
  .shake { animation: none !important; }
  header .site-title span { animation: none !important; }
}

/* Scrollbar subtle tweak on mobile to reduce visual noise */
@media (max-width:640px) {
  /* mobile overrides already handled globally */
}

/* === Unified Scrollbar Theme === */
/* Applies to any element that can scroll. Uses accent-infused gradient thumb with subtle hover elevation. */
* {
  scrollbar-width: thin;
  scrollbar-color: #394254 #121317; /* thumb track */
}
/* WebKit */
*::-webkit-scrollbar { width:12px; height:12px; }
*::-webkit-scrollbar-track { background:#121317; }
*::-webkit-scrollbar-thumb { background:
  linear-gradient(180deg, rgba(255,47,185,.18), rgba(90,132,255,.18)),
  linear-gradient(180deg,#262c37,#313a47); border-radius:10px; border:1px solid #1a1e26; box-shadow:0 0 0 1px #1a1e26 inset, 0 2px 4px -2px #000; }
*::-webkit-scrollbar-thumb:hover { background:
  linear-gradient(180deg, rgba(255,47,185,.32), rgba(90,132,255,.34)),
  linear-gradient(180deg,#2f3844,#394351); }
*::-webkit-scrollbar-corner { background:#121317; }
@media (max-width:640px){
  *::-webkit-scrollbar { width:10px; height:10px; }
}

/* End accessibility enhancements */

