:root {
  --primary-color: #000000;
  --secondary-color: #4a4a4a;
  --background-color: #fffdf2;
  --chat-bg: #fffdf2;
  --text-color: #333333;
  --border-color: rgb(155, 155, 155);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Karla', sans-serif;
}

body {
  background-color: var(--background-color);
  /* overflow: hidden; */
  margin: 0;
  padding: 0;
  /* height: 100vh; */
}

.page-wrapper {
  display: flex;
  flex-direction: column;
/*  height: 100vh; */
}

.content-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
/*  padding-bottom: 170px; */
  /* Space for fixed footer */
}

.container {
  width: 100%;
  margin: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  background: var(--chat-bg);
  border-radius: 0;
  padding: 20px;
  height: 100vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-left: none;
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  z-index: 1002;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar.active {
  left: 0 !important;
}

.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  pointer-events: none;
}

.overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.main-content {
  margin-left: 0;
  background: var(--chat-bg);
  border-radius: 10px;
  padding: 0;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  border: none;
  position: relative;
  flex: 1;
  /* overflow: hidden; */
}





.user-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-left: auto;
  font-size: 16px;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 0px 60px 160px 60px;
  width: 100%;
}

.center-content {
  /* این کد بخش خوشامدگویی را در مرکز صفحه شناور می‌کند */
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);

  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;

  width: 90%;
  max-width: 600px;
  z-index: 10;
}

.logo-container {
  margin-bottom: 0;
}

.logo {
  width: 100px;
  height: auto;
}

.welcome-text {
  text-align: left;
}

.welcome-text h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.welcome-text p {
  font-size: 1.2rem;
  color: var(--secondary-color);
  margin-bottom: 0;
}

.reading-history {
  margin-left: 50px;
  padding-top: 8px;
}

.reading-history h3 {
  margin-bottom: 15px;
  color: var(--text-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 5px;
  margin-left: -45px;
  padding-left: 45px;
}

.clear-history {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  font-size: 20px;
  margin-top: 2px;
  padding: 0;
  transition: color 0.3s;
  display: flex;
  align-items: center;
}

.clear-history:hover {
  color: var(--primary-color);
}

.history-item {
  padding: 10px 0;
  margin-top: 40px;
  margin-bottom: -30px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  border: 1px solid var(--border-color);
  margin-left: -45px;
  padding-left: 10px;
  display: flex;
  align-items: center;
}

.history-item:hover {
  background-color: var(--background-color);
}

.history-item>* {
  margin: 0;
  padding: 0;
  width: 100%;
}

.message {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.message-header {
  font-weight: bold;
  margin-bottom: 5px;
}

.message-content {
  background: var(--chat-bg);
  padding: 15px;
  border-radius: 10px;
  max-width: 80%;
  overflow: visible;
}

.user-message .message-content {
  align-self: flex-end;
  background: var(--primary-color);
  color: white;
}

.bot-message .message-content {
  align-self: stretch;
  background: var(--chat-bg);
  padding: 0;
  border-radius: 0;
  max-width: 100%;
}

.input-area {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  transition: transform 0.5s ease, top 0.5s ease, width 0.5s ease, padding 0.5s ease;
  width: 100%;
  max-width: 70%;
  padding: 20px;
  z-index: 1000;
  /* Above footer */
  /* Initial center position - moved 65px down */
  top: calc(50% + 65px);
  transform: translate(-50%, -50%);
  display: flex;
  gap: 20px;
  background: var(--chat-bg);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09);
  
    flex-wrap: wrap;
}

.input-area.moved {
  position: fixed;
  /* <-- تغییر از absolute به fixed */
  bottom: 15px;
  /* <-- نشستن در پایین صفحه موبایل */
  top: auto;
  left: 50%;
  /* <-- اضافه کردن این خط */
  transform: translateX(-50%);
  background: var(--chat-bg);
  padding: 10px 15px;
  /* کمی فشرده‌تر کردن پدینگ */
  width: calc(100% - 30px);
  /* کمی تغییر در عرض */
  max-width: 600px;
  animation: expandBox 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Desktop - stick to footer top */
@media (min-width: 769px) {
  .input-area.moved {
    bottom: 60px;
    /* width: calc(100% - 40px);
              padding: 15px 20px;*/
  }
}

@keyframes expandBox {
  0% {
    transform: translate(-50%, 50%) scale(0.9);
    opacity: 0;
  }

  100% {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
  }
}

.input-area .message-input {
  padding: 15px 25px;
}

.sidebar.active~.main-content .input-area.moved {
  max-width: none;
  /* This was calc(100% - 20px); revert to none for wider input when sidebar open */
  margin-left: 0;
  /* this seems fine */
}

.message-input {
  flex-grow: 1;
  padding: 15px;
  border: none;
  border-radius: 12px;
  outline: none;
  font-size: 16px;
  background: var(--chat-bg);
  text-align: left;
  padding-left: 0;
}

.message-input:focus {
  border-color: var(--primary-color);
}

.send-button {
  background: #000000;
  color: white;
  border: none;
  width: 80px;
  height: 80px;
  cursor: pointer;
  display: flex;
  margin-top: 0px;
  /* Added margin to move the button down */
  font-size: 24px;
  transition: background-color 0.3s;
  border-radius: 8px;
  /* Changed from 0 */
  position: relative;
}

.send-button:hover {
  background: var(--secondary-color);
}

.send-button::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline></svg>');
  /* Corrected SVG for upward arrow */
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px;
  /* Adjusted size for better centering */
}

/* Typing animation for AI responses */
.typing-animation {
  display: inline-block;
  white-space: pre-wrap;
  width: 100%;
  line-height: 1.6;
  /* Added for better readability during typing */
}

.typing-animation p {
  overflow: hidden;
  border-right: .15em solid black;
  white-space: nowrap;
  margin: 0 0 0.8em 0;
  /* Added bottom margin for spacing between typing paragraphs */
  letter-spacing: .15em;
  animation: typing 1.75s steps(40, end),
    blink-caret .75s step-end infinite;
  animation-fill-mode: forwards;
  line-height: 1.5;
  /* Ensuring consistent line height within a paragraph */
}

.typing-animation p:last-child {
  margin-bottom: 0;
  /* Remove margin from the last paragraph */
}

.typing-animation p.typed {
  border-right: none;
  animation: none;
  white-space: pre-wrap;
  letter-spacing: normal;
}

/* Apply markdown styles to typed content */
.typing-animation p.typed strong {
  font-weight: bold;
}

.typing-animation p.typed em {
  font-style: italic;
}

.typing-animation p.typed code {
  background: #f0f0f0;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: monospace;
}

.typing-animation p.typed pre {
  background: #f0f0f0;
  padding: 1em;
  border-radius: 5px;
  overflow-x: auto;
}

.typing-animation p.typed blockquote {
  border-left: 4px solid #ddd;
  margin: 0;
  padding-left: 1em;
  color: #666;
}

@keyframes typing {
  from {
    width: 0
  }

  to {
    width: 100%
  }
}

@keyframes blink-caret {

  from,
  to {
    border-color: transparent
  }

  50% {
    border-color: black;
  }
}

.analysis-loading-container {
  display: flex;
  flex-direction: row;
  /* Changed from column */
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  margin: 20px auto;
  /* Changed from 20px 0 to center horizontally */
  background-color: var(--chat-bg);
  border-radius: 10px;
  gap: 15px;
  /* New */
  max-width: 80%;
  /* Limit width for better appearance */
}

.analysis-loading-text {
  margin-bottom: 0;
  /* Changed from 20px */
  font-size: 18px;
  color: var(--text-color);
}

/* Loading animation using the provided GIF */
.ai-loading {
  /* For generic bot message loading */
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto;
  /* Changed from 20px 0 to center horizontally */
  width: 100%;
  /* Ensure full width of container */
}

.ai-loading img {
  width: 60px;
  /* Increased from 50px for better visibility */
  height: 60px;
}

.action-button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
}

.action-button:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
}

.action-button.new-question {
  background-color: #4a4a4a;
}

.action-button.follow-up {
  background-color: #000000;
}

.hexagram-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-button {
  flex: 1;
  min-width: 120px;
  padding: 10px 20px;
  border: 1px solid var(--primary-color);
  background: var(--chat-bg);
  color: var(--primary-color);
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.3s;
  text-align: center;
  white-space: nowrap;
}

.tab-button.active {
  background: var(--primary-color);
  color: white;
}

@media (max-width: 940px) {
  .container {
    padding: 0;
    overflow-x: hidden;
  }

  .analysis-loading-container {
    max-width: 90%;
    /* Adjust for mobile */
    padding: 15px;
  }

  .analysis-loading-container img {
    width: 50px;
    /* Slightly smaller on mobile */
    height: 50px;
  }

  .ai-loading img {
    width: 50px;
    /* Adjust size for mobile */
    height: 50px;
  }

  .main-content {
    padding: 10px;
   /* height: 100vh;
    overflow-y: auto; */
  }

  .sidebar {
    width: 85%;
    max-width: 320px;
    left: -85%;
  }

  .input-area {
    padding: 15px;
    gap: 10px;
    max-width: calc(100% - 20px);
  }

  .input-area .message-input {
    padding: 12px 20px;
  }

  .sidebar.active~.main-content .input-area.moved {
    max-width: calc(100% - 20px);
    margin-left: 0;
  }

  .chat-history {
    padding-bottom: 200px;
    /* More space for input area + footer */
    margin-top: 40px;
    /* Initial margin before chat starts */
  }

  /* When chat starts (input moved), increase top margin */
  .main-content.chat-started .chat-history {
    margin-top: 0;
    padding: 0 0 100px 0;
  }

  /* When footer is hidden on mobile, reduce padding */
  .page-wrapper.footer-hidden .content-wrapper {
    padding-bottom: 20px;
    /* Less padding when footer is hidden */
  }

  .page-wrapper.footer-hidden .chat-history {
    padding-bottom: 100px;
    /* Less padding when footer is hidden */
  }

  .input-area.moved {
    width: calc(100% - 20px);
    padding: 10px;
    /* bottom position inherited from main rule */
    top: auto;
  }

  /* When footer is hidden, move input to bottom */
  .page-wrapper.footer-hidden .input-area.moved {
    bottom: 15px !important;
  }

  .hexagram-tabs {
    flex-direction: column;
    /* Removed typo 'فق' */
  }

  .tab-button {
    width: 100%;
    min-width: 0;
  }

  .message-content {
    max-width: 100%;
  }

  .reading-history {
    margin-left: 40px;
    margin-top: -8px;
  }

  .reading-history h3 {
    margin-left: -40px;
    padding-left: 40px;
  }

  .history-item {
    margin-left: -40px;
    padding-left: 10px;
  }

  .welcome-text {
    text-align: left;
  }

  .welcome-text h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
  }

  .welcome-text p {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-bottom: 0;
  }

  /* make logo-container and logo itself smaller: */
  .logo-container {
    width: 40%;
    height: 40%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
  }

  .logo {
    /* width: 100%;
    height: 100%; */
  }
}

.hexagram-container {
  margin-top: 20px;
  width: 100%;
}

.tab-content {
  background: #fffdf2;
  padding: 20px;
  border-radius: 5px;
  margin-top: 10px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* --- stacked tabs mode: show all panes vertically --- */
.hexagram-container.stacked-tabs .tab-pane {
  display: block;
}

.hexagram-container.stacked-tabs .tab-button.active {
  /* دکمه فعال فقط استایل می‌گیرد، نمایش مخفی نداریم */
}

.hexagram-visual-container h4 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hexagram-content {
  font-family: monospace;
  white-space: pre-wrap;
  margin: 20px 0;
  word-break: break-word;
}

.hexagram-content h3 {
  margin-bottom: 15px;
  color: var(--primary-color);
}

.hexagram-meaning {
  margin-top: 20px;
  font-family: Arial, sans-serif;
  white-space: pre-wrap;
  line-height: 1.6;
  word-wrap: break-word;
}

.hexagram-meaning p {
  margin-bottom: 0;
  margin-top: 1.5em;
  line-height: 1.4;
  font-size: 18px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.hexagram-line {
  cursor: pointer;
  margin: 5px 0;
  transition: opacity 0.3s;
}

.hexagram-line:hover {
  opacity: 0.8;
}

.hexagram-line-info {
  margin-top: 10px;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 5px;
  display: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  max-width: 100%;
  font-size: 14px;
  line-height: 1.6;
}

.markdown-content {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  padding: 10px 20px;
  /* کاهش پدینگ بالا و پایین */
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  margin: 0.5em 0 0.5em;
}

.markdown-content p {
  margin: 0.2em 0;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0.5em 0;
  padding-left: 2em;
}

.markdown-content code {
  background: #f0f0f0;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: monospace;
}

.markdown-content pre {
  background: #f0f0f0;
  padding: 1em;
  border-radius: 5px;
  overflow-x: auto;
}

.markdown-content blockquote {
  border-left: 4px solid #ddd;
  margin: 0;
  padding-left: 1em;
  color: #666;
}

.loading-dots {
  /* This animation is not currently used in JS, but kept */
  display: inline-block;
  font-size: 24px;
  letter-spacing: 2px;
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {

  0%,
  20% {
    content: "...";
  }

  40% {
    content: "..";
  }

  60% {
    content: ".";
  }

  80%,
  100% {
    content: "...";
  }
}

.loading-dots::after {
  content: "...";
  animation: loadingDots 1.5s infinite;
}

/* New washing machine animation styles */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 2000;
  font-size: 24px;
  color: var(--primary-color);
  transition: opacity 0.3s ease-out;
  opacity: 1;
  overflow: hidden;
  /* Prevent any overflow */
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-overlay * {
  position: absolute;
}

.loading-overlay *::before,
.loading-overlay *::after {
  position: absolute;
}

.playground {
  --bottom-elements: 2.4em;
  --main-width: 30em;
  /* This will be 30rem if playground font-size is 1rem */
  width: var(--main-width);
  height: var(--main-width);
  position: relative;
  /* Changed to relative for flex centering */
  transform-origin: center center;
  transform: scale(0.45);
  /* Desktop scale */
  margin: 0;
  /* Centered by flex parent */
  font-size: 1rem;
  /* Base em units on root font-size for predictability */
}

/* Responsive adjustments */
@media (max-width: 940px) {
  .playground {
    transform: scale(0.30);
    /* Scale down more on mobile */
    /* position: relative and font-size: 1rem are inherited */
  }
}

/* Shadow */
.shadow {
  width: calc(var(--main-width) + 5em);
  height: 1em;
  border-radius: 0.5em;
  bottom: 2em;
  left: 0.5em;
  background-color: rgba(0, 0, 0, 0.2);
  z-index: -1;
}

/* Washing machine */
.washing-machine {
  --delay-animation: 500ms;
  width: 17.5em;
  height: 25em;
  animation: shake-machine 2500ms infinite ease;
  bottom: var(--bottom-elements);
  left: 4em;
  border-radius: 2.5em 2.5em 1em 1em;
  background: linear-gradient(#F2FBFF 82%, #E5EBEE 82%, #E5EBEE 83%, #F2FBFF 83%);
  box-shadow: 4.25em 0 #C5C7C8;
  z-index: 1;
}

@keyframes shake-machine {

  10%,
  12%,
  14%,
  16%,
  18%,
  20%,
  22%,
  24%,
  26%,
  28%,
  30%,
  32%,
  34%,
  36%,
  38%,
  40%,
  42%,
  44%,
  46%,
  48%,
  50%,
  52% {
    transform: translateY(-0.125em);
  }

  11%,
  13%,
  15%,
  17%,
  19%,
  21%,
  23%,
  25%,
  27%,
  29%,
  31%,
  33%,
  35%,
  37%,
  39%,
  41%,
  43%,
  45%,
  47%,
  49%,
  51%,
  53% {
    transform: translateY(0);
  }
}

.washing-machine .board {
  width: 90%;
  height: 2.5em;
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding-inline: 1.5em;
  top: 2.25em;
  left: 5%;
  border-radius: 1em;
  background-color: #E8F1F4;
}

.washing-machine .button {
  width: 1.5em;
  height: 0.65em;
  position: static;
  border-radius: 0.15em;
  background-color: #D9DDDF;
  box-shadow: 0.15em 0 #C2C4C6;
}

.washing-machine .button:nth-of-type(2) {
  margin-right: auto;
}

.washing-machine .button.circle {
  width: 1.2em;
  height: 1.2em;
  border-radius: 50%;
}

.washing-machine .badge {
  width: 3.25em;
  height: 1.85em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding-block: 0.35em;
  bottom: 0.65em;
  right: 2em;
  background-color: #E5EBEE;
  box-shadow: -0.15em 0 #C5C7C8;
  border-radius: 0.25em;
}

.washing-machine .badge::before {
  width: 1.25em;
  height: 0.2em;
  content: '';
  top: -0.2em;
  background-color: #D4D8DA;
  border-radius: 0.05em 0.05em 0 0;
  z-index: -1;
}

.washing-machine .badge .line {
  width: 65%;
  height: 0.175em;
  flex: none;
  position: static;
  border-radius: 0.1em;
  background-color: #D4D8DA;
}

/* Clothes */
.clothes {
  right: -2em;
  /* Adjusted based on previous feedback, might need further tuning */
  bottom: var(--bottom-elements);
}

.clothes .shirt {
  --bg: #FCB900;
  --shadow: #D59800;
  --extra-bg: linear-gradient(transparent, transparent);
  --shadow-size: 85%;
  --height: 0.75em;
  width: 7em;
  height: var(--height);
  position: static;
  border-radius: calc(var(--height) / 2);
  background: var(--extra-bg),
    radial-gradient(circle calc(var(--height) / 2) at var(--shadow-size) 50%, var(--bg) 100%, transparent 0),
    linear-gradient(90deg, var(--bg) var(--shadow-size), var(--shadow) var(--shadow-size));
}

.clothes .shirt.orange {
  --bg: #EE6E02;
  --shadow: #C55602;
}

.clothes .shirt.white {
  --extra-bg-color: #CCD0D2;
  --bg: #F7EAEA;
  --shadow: #CCD0D2;
  --extra-bg: linear-gradient(90deg, transparent 60%, var(--extra-bg-color) 60%, var(--extra-bg-color) 63%, transparent 63%),
    linear-gradient(90deg, transparent 65%, var(--extra-bg-color) 65%, var(--extra-bg-color) 68%, transparent 68%);
}

/* Window */
.window {
  --border-color: #E5EBEE;
  --bg-color: #6E6D71;
  width: 12.25em;
  height: 12.25em;
  left: 9em;
  top: 7em;
  transform: translateX(-50%);
  border-radius: 50%;
  box-shadow: 0.6em 0 #C5C7C8;
  background-color: var(--bg-color);
  overflow: hidden;
  z-index: 1;
}

.window::before {
  width: 100%;
  height: 100%;
  --opacity-color: rgba(255, 255, 255, 0.15);
  content: '';
  box-shadow: 0 0 0 1.5em var(--border-color) inset;
  border-radius: 50%;
  z-index: 10;
  background: linear-gradient(-45deg, transparent 53%, var(--opacity-color) 53%, var(--opacity-color) 55%, transparent 55%, transparent 59%, var(--opacity-color) 59%, var(--opacity-color) 65%, transparent 65%);
}

.window::after {
  width: 4em;
  height: 4em;
  content: '';
  right: -0.55em;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 50%;
  background-color: var(--border-color);
}

.content {
  width: 100%;
  height: 100%;
  animation: content-rotate 2500ms infinite ease-in-out;
}

@keyframes content-rotate {

  0%,
  55% {
    transform: rotate(-3turn);
  }

  24%,
  48% {
    filter: blur(0.075em);
  }

  48% {
    filter: none;
  }

  55% {
    transform: initial;
  }
}

.cat {
  --bg-cat: #2A2538;
  width: 4.5em;
  height: 6.5em;
  left: 3.95em;
  bottom: 1em;
  transform-origin: center top;
}

.cat .head {
  width: 100%;
  height: 2em;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.15em;
  top: 0.75em;
  border-radius: 1em;
  background-color: var(--bg-cat);
}

.cat .head .eye {
  width: 0.75em;
  height: 0.75em;
  position: static;
  margin-top: -0.325em;
  border-radius: 50%;
  clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  background: radial-gradient(circle 0.15em at 50% 50%, black 100%, transparent 0), white;
}

.cat .head .ear {
  --height: 0.75em;
  --width: 0.45em;
  --position: 1.1em;
  width: 0;
  border-style: solid;
  border-width: 0 var(--width) var(--height) var(--width);
  border-color: transparent transparent var(--bg-cat) transparent;
  top: calc(var(--height) * -1);
  left: var(--position);
}

.cat .head .ear.right {
  left: initial;
  right: var(--position);
  z-index: 5;
  transform-origin: bottom left;
  animation: ear-animation 2500ms infinite ease;
}

@keyframes ear-animation {

  0%,
  68%,
  78%,
  86% {
    transform: skew(0);
  }

  74%,
  82% {
    transform: skew(-40deg);
  }
}

.cat .body {
  width: 70%;
  height: 3.35em;
  top: 2.65em;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-cat);
}

.cat .feet {
  width: 4.75em;
  height: 1.25em;
  bottom: 0.7em;
  right: -0.25em;
  border-radius: 0.75em;
  background-color: var(--bg-cat);
}

.cat .tail {
  width: 4.5em;
  height: 4.5em;
  left: -2.25em;
  bottom: 1.25em;
  border-radius: 50%;
  background: radial-gradient(circle 0.3em at 30% 11.5%, var(--bg-cat) 100%, transparent 0),
    radial-gradient(circle 1.65em at 50% 50%, var(--bg-color) 100%, transparent 0),
    conic-gradient(transparent 152deg, var(--bg-cat) 152deg 330deg, transparent 330deg);
  z-index: -1;
}

.sock {
  --bg-color: #F8A11E;
  --line-color: #EE6D02;
  --x: 0;
  --y: 0;
  --deg: 0;
  width: 2.25em;
  height: 3em;
  transform: rotate(var(--deg)) translate(var(--x), var(--y));
  z-index: 5;
}

.sock::before {
  width: 1.15em;
  height: 1.925em;
  content: '';
  border-radius: 0.1em 0.1em 0 0.1em;
  background: linear-gradient(var(--bg-color) 25%, var(--line-color) 25%, var(--line-color) 35%, var(--bg-color) 35%, var(--bg-color) 45%, var(--line-color) 45%);
}

.sock::after {
  width: 1.15em;
  height: 1.75em;
  content: '';
  background: radial-gradient(circle 0.55em at 50% 100%, var(--bg-color) 100%, transparent 0), var(--line-color);
  bottom: -0.2em;
  border-radius: 0.1em 0 1em 1em;
  transform-origin: center top;
  transform: rotate(-45deg) translateX(-0.15em);
}

.sock.orange {
  --deg: 60deg;
  bottom: -0.35em;
  left: 5em;
  animation: sock-falling 2500ms infinite ease;
}

.sock.orange::after {
  transform: rotate(-45deg) translate(-0.15em, -0.1em);
}

@keyframes sock-falling {
  50% {
    bottom: 10em;
  }

  70%,
  73% {
    transform: rotate(60deg);
    left: 4.75em;
    bottom: 5em;
  }

  80% {
    transform: rotate(20deg);
  }

  100% {
    bottom: 0;
    transform: rotate(-80deg);
  }
}

.sock.green {
  --bg-color: #387D45;
  --line-color: #4BB15F;
  --deg: 120deg;
  bottom: -0.15em;
  left: 2.5em;
}

.sock.red {
  --bg-color: #EE6B77;
  --line-color: #EA3949;
  --deg: 45deg;
  bottom: 0;
  left: 1.5em;
}

.bubbles {
  width: 4em;
  height: 1em;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 5;
  left: 45%;
}

.bubbles .bubble {
  width: var(--size, 0.5em);
  height: var(--size, 0.5em);
  border-radius: 50%;
  background-color: #fff;
  animation: bounce-bubble 2500ms infinite ease;
}

@keyframes bounce-bubble {

  0%,
  15%,
  25%,
  40% {
    transform: translateY(0);
  }

  10%,
  35% {
    transform: translateY(var(--bounce, -1em));
  }

  20% {
    transform: translateY(var(--bounce, -1em));
  }
}

/* Random positions for bubbles */
.bubbles .bubble:nth-of-type(1) {
  --bounce: -1.1em;
  --size: 0.5em;
  --delay: 13ms;
  left: 57%;
}

.bubbles .bubble:nth-of-type(2) {
  --bounce: -1.7em;
  --size: 0.6em;
  --delay: 26ms;
  left: 23%;
}

.bubbles .bubble:nth-of-type(3) {
  --bounce: -1.4em;
  --size: 0.7em;
  --delay: 39ms;
  left: 82%;
}

.bubbles .bubble:nth-of-type(4) {
  --bounce: -1.2em;
  --size: 0.5em;
  --delay: 52ms;
  left: 16%;
}

.bubbles .bubble:nth-of-type(5) {
  --bounce: -1.8em;
  --size: 0.9em;
  --delay: 65ms;
  left: 48%;
}

.bubbles .bubble:nth-of-type(6) {
  --bounce: -1.3em;
  --size: 0.6em;
  --delay: 78ms;
  left: 74%;
}

.bubbles .bubble:nth-of-type(7) {
  --bounce: -1.6em;
  --size: 0.7em;
  --delay: 91ms;
  left: 33%;
}

.bubbles .bubble:nth-of-type(8) {
  --bounce: -1.5em;
  --size: 0.8em;
  --delay: 104ms;
  left: 65%;
}

.bubbles .bubble:nth-of-type(9) {
  --bounce: -1.1em;
  --size: 0.5em;
  --delay: 117ms;
  left: 19%;
}

.bubbles .bubble:nth-of-type(10) {
  --bounce: -1.9em;
  --size: 0.6em;
  --delay: 130ms;
  left: 90%;
}

.bubbles .bubble:nth-of-type(11) {
  --bounce: -1.4em;
  --size: 0.8em;
  --delay: 143ms;
  left: 42%;
}

.bubbles .bubble:nth-of-type(12) {
  --bounce: -1.2em;
  --size: 0.7em;
  --delay: 156ms;
  left: 11%;
}

.bubbles .bubble:nth-of-type(13) {
  --bounce: -1.6em;
  --size: 0.9em;
  --delay: 169ms;
  left: 76%;
}

.bubbles .bubble:nth-of-type(14) {
  --bounce: -1.3em;
  --size: 0.6em;
  --delay: 182ms;
  left: 38%;
}

.bubbles .bubble:nth-of-type(15) {
  --bounce: -1.7em;
  --size: 0.5em;
  --delay: 195ms;
  left: 59%;
}

/* Responsive adjustments */
@media (max-width: 940px) {
  .playground {
    transform: scale(0.30);
    /* Scale down more on mobile */
  }
}

.ai-analysis-button {
  /* This is for the button itself */
  background: #FF0000;
  /* رنگ قرمز */
  color: white;
  border: 1px solid #FF0000;
  /* برای هماهنگی بیشتر */
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  margin: 20px auto;
  /* برای وسط‌چین شدن */
  transition: all 0.3s ease;
  display: block;
  width: 33.33%;
  /* عرضی مشابه تب‌ها */
  min-width: 150px;
  font-size: 16px;
  /* برای هماهنگی با فونت تب‌ها */
  font-weight: 500;
}

.ai-analysis-button:hover {
  background: #a93226;
  /* رنگ قرمز تیره‌تر در حالت هاور */
  border-color: #a93226;
  transform: translateY(-2px);
  /* افکت حرکتی کوچک */
}

/* Credits System Styles */

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--chat-bg);
  border-radius: 15px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-color);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 10px;
  color: var(--text-color);
}

.modal-content p {
  text-align: center;
  margin-bottom: 20px;
  color: var(--secondary-color);
}

.credit-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.credit-option {
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.credit-option:hover {
  border-color: var(--primary-color);
  background: rgba(0, 0, 0, 0.02);
}

.credit-option-left {
  flex: 1;
}

.credit-option h3 {
  margin: 0 0 5px 0;
  font-size: 1.2em;
  color: var(--text-color);
}

.credit-option p {
  margin: 0;
  color: var(--secondary-color);
  text-align: left;
}

.credit-option-price {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--primary-color);
}

.login-button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  width: 100%;
  transition: background-color 0.3s;
}

.login-button:hover {
  background: var(--secondary-color);
}

/* Follow-up System Styles */
.followup-container {
  background: var(--chat-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
}

.followup-prompt h3 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-color);
}

.followup-input-area {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.followup-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  font-size: 16px;
  background: var(--chat-bg);
}

.followup-input:focus {
  border-color: var(--primary-color);
}

.followup-send-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
}

.followup-send-btn:hover {
  background: var(--secondary-color);
}

.followup-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.remaining-credits {
  text-align: center;
  color: var(--secondary-color);
  font-size: 14px;
}

@media (max-width: 940px) {
  .modal-content {
    padding: 20px;
    margin: 20px;
  }

  .credit-option {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .credit-option p {
    text-align: center;
  }
}

/* Header Styles */
.site-header {
  background: var(--background-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1004;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.site-header-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 60px;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 15px;
}

.site-logo {
  height: 50px;
  width: auto;
}

.header-history-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--chat-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  color: var(--primary-color);
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.header-history-btn:hover {
  background: var(--primary-color);
  color: white;
}

.header-credits {
  display: flex;
  align-items: center;
  background: var(--chat-bg);
  padding: 8px 15px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 30px;
  flex: 0 0 auto;
}

.mobile-menu-toggle {
  display: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--primary-color);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--chat-bg);
  border: none;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}



.main-navigation {
  display: flex;
  align-items: center;
}

.main-navigation ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 25px;
}

.main-navigation a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  padding: 8px 0;
  position: relative;
  transition: color 0.3s ease;
}

.main-navigation a:hover {
  color: var(--primary-color);
}

.main-navigation a.current {
  color: var(--primary-color);
}

.main-navigation a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

.main-navigation a:hover::after,
.main-navigation a.current::after {
  width: 100%;
}

.header-button {
  background: var(--primary-color);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.3s ease;
}

.header-button:hover {
  background: var(--secondary-color);
}

.header-icons {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-icon {
  width: 24px;
  height: 24px;
  color: var(--text-color);
  cursor: pointer;
  transition: color 0.3s ease;
}

.header-icon:hover {
  color: var(--primary-color);
}

.cart-icon,
.account-icon {
  position: relative;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* Footer Styles */
.site-footer {
  background: var(--background-color);
  border-top: 1px solid var(--border-color);
  padding: 15px 20px;
  margin-top: 0;
  text-align: center;
  flex-shrink: 0;
  width: 100%;
  min-height: auto;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  transition: transform 0.3s ease;

}

.site-footer.hidden {
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.substack-embed iframe {
  width: 100%;
  max-width: 700px;
  height: 70px;
  border: 1px solid var(--border-color);
  background: var(--background-color);
}

/* Desktop only - 60% width for footer iframe */
@media (min-width: 769px) {
  .substack-embed iframe {
    width: 50%;
    max-width: 420px;
    transform: scale(0.6);
    height: 130px;
    margin-bottom: -40px;
    margin-top: -40px;
  }

  .site-footer {
    min-height: auto;
  }
}

.copyright {
  color: var(--secondary-color);
  font-size: 14px;
  margin-top: 0px;
}

/* Mobile Menu Styles */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1005;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 280px;
  height: 100%;
  background: var(--background-color);
  z-index: 1006;
  transition: right 0.3s ease;
  padding: 20px;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
}

.mobile-menu.active {
  right: 0;
}

.mobile-menu-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-color);
}

.mobile-menu-content {
  margin-top: 50px;
}

.mobile-menu nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu nav li {
  margin-bottom: 15px;
}

.mobile-menu nav a {
  display: block;
  padding: 15px 0;
  color: var(--text-color);
  text-decoration: none;
  font-size: 16px;
  border-bottom: 1px solid var(--border-color);
}

.mobile-menu nav a:hover,
.mobile-menu nav a.current {
  color: var(--primary-color);
}

.mobile-menu .header-button {
  display: block;
  margin: 20px 0;
  text-align: center;
}

.mobile-menu .header-icons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.mobile-credits {
  display: block;
  background: var(--primary-color);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  margin: 15px 0;
}


  .history-toggle-mobile {
    display: none !important;
    /* Force hide by default for desktop */
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    pointer-events: none !important;
    align-items: center;
    justify-content: center;
    background: var(--chat-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }

/* Mobile Header Styles */
@media (max-width: 940px) {
  .main-navigation {
    display: none;
  }

  .header-button {
    display: none;
  }

  .header-icons {
    display: none;
  }

  .header-history-btn {
    display: none;
  }

  .header-credits {
    display: none;
  }

  .mobile-menu-toggle {
    display: flex;
  }



  .site-logo {
    height: 40px;
  }

  .site-header-wrap {
    padding: 10px 15px;
  }

  .header-left {
    gap: 10px;
    justify-content: flex-start;
  }


  /* Mobile Header Styles */
  @media (max-width: 940px) {
    .history-toggle-mobile {
      display: flex !important;
      visibility: visible !important;
      opacity: 1 !important;
      width: 35px !important;
      height: 35px !important;
      overflow: visible !important;
      position: relative !important;
      left: auto !important;
      pointer-events: auto !important;
    }

    .substack-embed iframe {
      max-width: 100%;
      height: 110px;
      margin: 0 auto;
    }

    .substack-embed {
      margin-bottom: 10px;
    }


    .site-footer {
      padding: 10px 10px 4px;
      min-height: auto;
      /* Keep fixed positioning from main definition */
    }

    .page-wrapper {
/*      min-height: 100vh; */
      display: flex;
      flex-direction: column;
      position: relative;
    }

    .content-wrapper {
      flex: 1;
      min-height: 0;
/*      padding-bottom: 140px; */
      /* Space for footer */
    }

    .chat-history {
      padding-bottom: 200px;
      /* More space for input area + footer */
    }


  }

  .main-content.chat-started .center-content {
    display: none;
  }

  /* کد برای صفحات با ارتفاع کم و زوم بالا */
  @media (max-height: 750px) {
    .center-content {
      top: 35%;
      /* بالاتر می‌رود */
      transform: translate(-50%, -50%) scale(0.85);
      /* کل بلاک 15% کوچک‌تر می‌شود */
    }

    .input-area {
      top: 65%;
      /* کادر ورودی هم کمی پایین‌تر می‌آید تا فاصله حفظ شود */
      transform: translate(-50%, -50%) scale(0.9);
      /* کادر ورودی هم کمی کوچک‌تر می‌شود */
    }
  }

  /* ===== استایل‌های جدید برای کادر تفسیر خطوط ===== */
  .hexagram-line-info {
    margin-top: 10px;
    padding: 15px;
    background: #fdfaf0;
    /* رنگی هماهنگ با پس‌زمینه */
    border: 1px solid #e0e0d1;
    border-radius: 5px;
    text-align: left;
    font-family: 'Karla', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    animation: fadeIn 0.5s ease;
  }

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

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

/* TAGS / CHIPS STYLES */
.tags-wrapper {
  display: flex;
  gap: 8px;
  justify-content: start;
  flex-wrap: wrap;
  margin-bottom: 12px;
  transition: opacity 0.3s ease, height 0.3s ease;
  width: 100%;
}

/* Скрываем теги, когда инпут уезжает вниз */
.input-area.moved .tags-wrapper {
  display: none;
  pointer-events: none;
}

.tag-chip {
  padding: 8px 16px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e0e0e0;
  color: #5f6368;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tag-chip:hover {
  background: #f1f3f4;
  border-color: #dadce0;
  color: #202124;
}

.tag-chip.active {
  background: #e8f0fe;
  /* Светло-голубой как в Google */
  color: #1967d2;
  /* Синий текст */
  border-color: #d2e3fc;
}

.tag-chip .icon {
  /* margin-right: 6px; */
  font-size: 16px;
}

/* Адаптация под мобильные */
@media (max-width: 940px) {
  .tags-wrapper {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 5px;
    /* Скрываем скроллбар но оставляем прокрутку */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
    padding-left: 5px;
    padding-right: 5px;
    flex-wrap: nowrap;
  }

  .tags-wrapper::-webkit-scrollbar {
    display: none;
  }

  .tag-chip {
    white-space: nowrap;
    flex-shrink: 0;
  }
}