@font-face {
  font-family: "IRANYekanX";
  src: url("/static/fonts/IRANYekanX-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IRANYekanX";
  src: url("/static/fonts/IRANYekanX-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --ink: #0f1c1a;
  --ink-soft: #3d524c;
  --paper: #f3f7f5;
  --panel: rgba(255, 255, 255, 0.72);
  --line: rgba(15, 28, 26, 0.12);
  --accent: #0d6e5f;
  --accent-deep: #084c42;
  --user: #143d38;
  --bot: #ffffff;
  --danger: #9b2c2c;
  --shadow: 0 18px 50px rgba(8, 40, 34, 0.12);
  --radius: 18px;
  --font: "IRANYekanX", "IBM Plex Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 10% -10%, #b8e4d8 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, #d7e8ef 0%, transparent 50%),
    linear-gradient(165deg, #eef6f3 0%, #e4ece8 45%, #dfe8e4 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M0 60h120M60 0v120' stroke='%230f1c1a' stroke-opacity='0.04' stroke-width='1'/%3E%3C/svg%3E");
}

.shell {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.brand {
  text-align: center;
  animation: rise 0.7s ease both;
}

.brand-name {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent-deep);
  line-height: 1.1;
}

.brand h1 {
  margin: 0.35rem 0 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.lede {
  margin: 0.75rem auto 0;
  max-width: 34rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.status {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.status.ok {
  color: var(--accent);
}

.status.err {
  color: var(--danger);
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  animation: rise 0.85s ease 0.08s both;
}

.messages {
  flex: 1;
  min-height: 280px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
  padding: 1rem 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.msg {
  max-width: 88%;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  animation: fade-in 0.35s ease both;
}

.msg.user {
  align-self: flex-start;
  background: var(--user);
  color: #f4fffc;
  border-bottom-right-radius: 6px;
}

.msg.bot {
  align-self: flex-end;
  background: var(--bot);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 6px;
}

.msg.error {
  align-self: flex-end;
  background: #fff5f5;
  border: 1px solid rgba(155, 44, 44, 0.25);
  color: var(--danger);
}

.msg.thinking {
  opacity: 0.75;
  font-style: italic;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.suggestions button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.suggestions button:hover {
  background: #fff;
  border-color: rgba(13, 110, 95, 0.35);
  color: var(--accent-deep);
  transform: translateY(-1px);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.composer textarea {
  font: inherit;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.4rem;
  min-height: 3.2rem;
}

.composer textarea::placeholder {
  color: rgba(61, 82, 76, 0.65);
}

.send {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 14px;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.send:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-1px);
}

.send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.msg a.file-link {
  color: var(--accent-deep);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
}

.msg a.file-link:hover {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 1.25rem, 100%);
    padding-top: 1.5rem;
  }

  .msg {
    max-width: 95%;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .send {
    width: 100%;
  }
}
