:root {
  --color-brand: #f26419;
  --color-brand-hover: #d94f0c;
  /* Deepened orange for text and links: the brand tone alone is too light on white. */
  --color-brand-ink: #c04405;
  --color-brand-line: #ffd8bd;
  --color-mist: #fff1e6;
  --color-paper: #ffffff;
  --color-canvas: #fffaf5;
  --color-ink: #1d1611;
  --color-muted: #7b6a5e;
  --color-line: #efdfd2;
  /* Crimson rather than red so errors never read as the orange brand tone. */
  --color-danger: #c81e3c;
  --color-ok: #0f7a45;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(196, 92, 24, 0.1);
  --font-display: "Onest", system-ui, sans-serif;
  --font-body: "Golos Text", system-ui, sans-serif;
}

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

/* Layout classes (display: grid/flex) would otherwise defeat the hidden attribute. */
[hidden] {
  display: none !important;
}

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

body {
  font-family: var(--font-body);
  color: var(--color-ink);
  background:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(242, 100, 25, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 45% at 100% 100%, rgba(242, 100, 25, 0.08), transparent 50%),
    linear-gradient(180deg, var(--color-canvas) 0%, var(--color-paper) 55%, var(--color-mist) 100%);
  line-height: 1.45;
}

a {
  color: var(--color-brand-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.auth-panel {
  width: min(100%, 420px);
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0 0 0.75rem;
}

.brand span {
  color: var(--color-brand);
}

.brand-compact {
  font-size: 1.5rem;
  margin: 0;
}

.auth-lead {
  margin: 0 0 1.75rem;
  color: var(--color-muted);
  font-size: 1rem;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-ink);
}

.field input {
  width: 100%;
  border: 1px solid var(--color-line);
  background: var(--color-paper);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  color: var(--color-ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(242, 100, 25, 0.15);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #ff7a2f, #ea570b);
  color: var(--color-paper);
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(226, 87, 11, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #f96c1e, #d94f0c);
}

.btn-ghost {
  background: transparent;
  color: var(--color-brand-ink);
  padding-left: 0;
  padding-right: 0;
  border-radius: 0;
  width: fit-content;
}

.auth-footer {
  margin-top: 1.5rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.alert {
  display: none;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
}

.alert.visible {
  display: block;
}

.alert-error {
  background: #ffe9ed;
  color: var(--color-danger);
  border: 1px solid #f5c3cd;
}

.alert-ok {
  background: #e8f7ef;
  color: var(--color-ok);
  border: 1px solid #b9e2cb;
}

.step {
  display: none;
}

.step.active {
  display: block;
  animation: rise 0.35s ease;
}

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

.password-meter {
  display: grid;
  gap: 0.35rem;
}

.password-meter-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--color-line);
  overflow: hidden;
}

.password-meter-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-brand);
  transition: width 0.2s ease, background 0.2s ease;
}

.password-meter[data-score="1"] .password-meter-bar > span {
  width: 25%;
  background: #d6455e;
}
.password-meter[data-score="2"] .password-meter-bar > span {
  width: 50%;
  background: #ef8a17;
}
.password-meter[data-score="3"] .password-meter-bar > span {
  width: 75%;
  background: #8ba513;
}
.password-meter[data-score="4"] .password-meter-bar > span {
  width: 100%;
  background: #0f7a45;
}

.code-input {
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 600;
}

.app-shell {
  min-height: 100vh;
  padding: 2rem 1.25rem 3rem;
}

.app-top {
  width: min(1120px, 100%);
  margin: 0 auto 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-main {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.app-main h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.app-lead {
  color: var(--color-muted);
  margin: 0 0 1.75rem;
}

.app-main .alert {
  margin-bottom: 1.25rem;
}

.cabinet-block {
  background: var(--color-paper);
  border: 1px solid var(--color-line);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.cabinet-block + .cabinet-block {
  margin-top: 1.25rem;
}

.cabinet-block h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.cabinet-copy {
  color: var(--color-muted);
  margin: 0 0 1.5rem;
  max-width: 58ch;
}

.cabinet-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-line);
  /* Credential fields stay readable instead of stretching the full wide card. */
  max-width: 460px;
}

.cabinet-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-top: 0.5rem;
}

.cabinet-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.cabinet-block-head h2 {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cabinet-hint {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 0;
}

.api-state {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--color-line);
  background: var(--color-canvas);
  color: var(--color-muted);
  white-space: nowrap;
}

.api-state[data-state="on"] {
  color: var(--color-ok);
  background: rgba(15, 122, 69, 0.1);
  border-color: rgba(15, 122, 69, 0.28);
}

/* Store badge: mirrors the shop plaque of the Ozon seller cabinet. */
.store-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--color-paper);
  border: 1px solid var(--color-line);
  border-radius: 20px;
  padding: 1.1rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.store-card-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  flex: 1 1 auto;
  min-width: 0;
}

.store-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.store-card-name {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.store-premium {
  display: inline-flex;
  color: #c98207;
}

.store-facts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.store-fact {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.store-fact-star {
  color: #f5a623;
}

.store-logo {
  position: relative;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
}

.store-logo-img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  object-fit: cover;
  background: var(--color-mist);
  box-shadow:
    inset 0 0 0 1px rgba(64, 35, 14, 0.08),
    0 6px 16px rgba(64, 35, 14, 0.14);
}

/* Stands in for the shop logo until the seller uploads one: Ozon does not
   expose the picture through the API. */
.avatar {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  user-select: none;
  box-shadow:
    inset 0 -1px 0 rgba(0, 0, 0, 0.14),
    0 6px 16px rgba(64, 35, 14, 0.14);
}

.store-logo-edit {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--color-paper);
  border: 1px solid var(--color-line);
  color: var(--color-muted);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(64, 35, 14, 0.16);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.store-logo-edit:hover,
.store-logo-input:focus-visible + .store-logo-edit {
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.store-logo-hint {
  flex: 1 0 100%;
  margin: 0;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.btn-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--color-brand-ink);
  text-decoration: underline;
  cursor: pointer;
}

.btn-link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.avatar-v0 {
  background: linear-gradient(140deg, #ff9a4d, #e2560a);
}

.avatar-v1 {
  background: linear-gradient(140deg, #7b5cff, #3a1fb0);
}

.avatar-v2 {
  background: linear-gradient(140deg, #12a5a5, #056b6b);
}

.avatar-v3 {
  background: linear-gradient(140deg, #f2596b, #a81232);
}

.avatar-v4 {
  background: linear-gradient(140deg, #14a05a, #0a6a3a);
}

.avatar-v5 {
  background: linear-gradient(140deg, #e0489a, #9d1259);
}

.avatar-v6 {
  background: linear-gradient(140deg, #4b6b90, #22384f);
}

.avatar-v7 {
  background: linear-gradient(140deg, #d4a017, #926a06);
}

.access-block {
  margin: 0.85rem 0 0;
}

.access-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--color-mist);
  border: 1px solid var(--color-line);
  color: var(--color-ink);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
}

.chip-ok {
  background: rgba(15, 122, 69, 0.1);
  border-color: rgba(15, 122, 69, 0.28);
  color: var(--color-ok);
}

.access-expiry {
  margin-top: 0.5rem;
}

.access-expiry-warn {
  color: var(--color-danger);
}

.sync-status {
  margin-top: 1.1rem;
}

@media (max-width: 640px) {
  .cabinet-block {
    padding: 1.35rem;
  }

  /* Below this width the name and the facts stop fitting on one line. */
  .store-card {
    align-items: flex-start;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
  }

  .store-card-body {
    gap: 0.45rem;
  }

  .store-card-title,
  .store-facts,
  .store-logo-hint {
    flex: 1 0 100%;
  }
}

.home-hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  text-align: center;
}

.home-hero .brand {
  font-size: clamp(2.8rem, 8vw, 4.4rem);
  margin-bottom: 0.85rem;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.75rem;
}

.home-actions .btn {
  min-width: 9.5rem;
}

.btn-secondary {
  background: var(--color-paper);
  color: var(--color-brand-ink);
  border: 1px solid var(--color-brand-line);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-mist);
  border-color: var(--color-brand);
}

.btn-danger {
  background: var(--color-paper);
  color: var(--color-danger);
  border: 1px solid #f5c3cd;
}

.btn-danger:hover:not(:disabled) {
  background: #fff5f7;
  border-color: var(--color-danger);
}

@media (max-width: 520px) {
  .auth-shell,
  .home-hero,
  .app-shell {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .app-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Luna workspace */
.luna-workspace {
  --sidebar-width: 286px;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  background: #fffaf5;
}

.chat-sidebar {
  position: relative;
  z-index: 20;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem 0.9rem;
  border-right: 1px solid rgba(239, 223, 210, 0.8);
  background: rgba(255, 246, 238, 0.92);
  backdrop-filter: blur(18px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 0.55rem;
  margin-bottom: 1.1rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--color-ink);
  background: var(--color-mist);
}

.icon-btn:focus-visible,
.new-chat-btn:focus-visible,
.thread-item:focus-visible,
.profile-button:focus-visible,
.prompt-grid button:focus-visible,
.send-button:focus-visible {
  outline: 3px solid rgba(242, 100, 25, 0.24);
  outline-offset: 2px;
}

.icon-btn svg,
.new-chat-btn svg,
.profile-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-close,
.mobile-menu {
  display: none;
}

.new-chat-btn {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: 1px solid rgba(242, 100, 25, 0.22);
  border-radius: 14px;
  color: var(--color-brand-ink);
  background: rgba(255, 255, 255, 0.82);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(242, 100, 25, 0.07);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 100, 25, 0.42);
  box-shadow: 0 10px 28px rgba(242, 100, 25, 0.12);
}

.thread-label {
  padding: 1.45rem 0.65rem 0.55rem;
  color: #a1897a;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.thread-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
}

.thread-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.55rem 0.65rem 0.75rem;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

.thread-item:hover,
.thread-item.active {
  color: var(--color-ink);
  background: rgba(255, 255, 255, 0.9);
}

.thread-item.active {
  box-shadow: inset 3px 0 var(--color-brand);
}

.thread-item-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-item-delete {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  opacity: 0;
  color: #a4907f;
  font-size: 1.15rem;
  line-height: 1;
}

.thread-item:hover .thread-item-delete,
.thread-item:focus-visible .thread-item-delete {
  opacity: 1;
}

.thread-item-delete:hover {
  color: var(--color-danger);
  background: #fff1f4;
}

.thread-empty {
  padding: 0.85rem 0.7rem;
  color: #a89383;
  font-size: 0.8rem;
  line-height: 1.5;
}

.sidebar-footer {
  padding-top: 0.75rem;
  border-top: 1px solid rgba(239, 223, 210, 0.75);
}

.profile-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
}

.profile-button:hover {
  background: rgba(255, 255, 255, 0.9);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: linear-gradient(145deg, #ff9640, #e0510a);
  font-family: var(--font-display);
  font-weight: 700;
}

.profile-copy {
  min-width: 0;
  flex: 1;
  display: grid;
}

.profile-copy strong {
  font-family: var(--font-display);
  font-size: 0.82rem;
}

.profile-copy small {
  overflow: hidden;
  color: var(--color-muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-button > svg {
  width: 16px;
  color: #a4907f;
}

.chat-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 136, 51, 0.1), transparent 28rem),
    #fff;
}

.chat-topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid rgba(239, 223, 210, 0.62);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
}

.luna-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.luna-orb {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 7%, transparent 9%),
    linear-gradient(145deg, #ffc069, #f26419 55%, #d63b1e);
  box-shadow: 0 5px 16px rgba(226, 92, 20, 0.32);
}

.luna-badge {
  padding: 0.15rem 0.38rem;
  border: 1px solid #ffdcc2;
  border-radius: 6px;
  color: #b8571a;
  background: #fff4ea;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.top-settings {
  position: absolute;
  right: 1.2rem;
}

.chat-scroll {
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-empty-state {
  width: min(760px, calc(100% - 2rem));
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(3rem, 8vh, 7rem) 0 3rem;
  text-align: center;
}

.hero-orb {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  margin: 0 auto 1.6rem;
  border-radius: 28px;
  background: linear-gradient(150deg, rgba(255, 165, 89, 0.24), rgba(226, 92, 20, 0.14));
  box-shadow: 0 18px 60px rgba(211, 96, 30, 0.18);
  transform: rotate(-8deg);
}

.hero-orb span {
  width: 44px;
  height: 44px;
  display: block;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, white 0 5%, transparent 8%),
    linear-gradient(145deg, #ffc069, #f26419 55%, #d63b1e);
  box-shadow: 0 10px 25px rgba(211, 76, 20, 0.38);
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--color-brand-ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chat-empty-state h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.25rem);
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.chat-empty-state > p:not(.eyebrow) {
  max-width: 600px;
  margin: 1rem auto 0;
  color: var(--color-muted);
  font-size: 1rem;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-top: 2.4rem;
  text-align: left;
}

.prompt-grid button {
  min-height: 116px;
  padding: 1rem;
  border: 1px solid #f2e2d6;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--color-muted);
  font: inherit;
  font-size: 0.83rem;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(120, 63, 24, 0.05);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.prompt-grid button:hover {
  transform: translateY(-2px);
  border-color: var(--color-brand-line);
  box-shadow: 0 14px 35px rgba(120, 63, 24, 0.1);
}

.prompt-grid button span {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
}

.message-list {
  width: min(820px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.2rem 0 4rem;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.7rem;
}

.message-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #fbeee4;
  color: #8a7264;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
}

.message-assistant .message-avatar {
  color: #fff;
  background: linear-gradient(145deg, #ffa451, #f05f12 58%, #d13d1c);
  box-shadow: 0 7px 18px rgba(205, 90, 25, 0.24);
}

.message-body {
  min-width: 0;
  padding-top: 0.15rem;
}

.message-name {
  margin-bottom: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
}

.message-text {
  color: #2c2118;
  font-size: 0.96rem;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

/* Luna's answer is rendered Markdown; only typed user text keeps its raw breaks. */
.message-user .message-text {
  white-space: pre-wrap;
}

.message-text > *:first-child {
  margin-top: 0;
}

.message-text > *:last-child {
  margin-bottom: 0;
}

.message-text p {
  margin: 0 0 0.85rem;
}

.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  margin: 1.5rem 0 0.6rem;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.message-text h3 {
  font-size: 1.22rem;
}

.message-text h4 {
  font-size: 1.09rem;
}

.message-text h5,
.message-text h6 {
  font-size: 1rem;
}

.message-text ul,
.message-text ol {
  margin: 0 0 0.85rem;
  padding-left: 1.4rem;
}

.message-text li {
  margin-bottom: 0.3rem;
}

.message-text li > ul,
.message-text li > ol {
  margin: 0.3rem 0 0;
}

.message-text strong {
  font-weight: 600;
}

.message-text code {
  padding: 0.1rem 0.34rem;
  border: 1px solid #f3e0d1;
  border-radius: 6px;
  background: #fff6ee;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.message-text pre {
  overflow-x: auto;
  margin: 0 0 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid #f3e0d1;
  border-radius: 12px;
  background: #fff8f2;
}

.message-text pre code {
  padding: 0;
  border: 0;
  background: none;
}

.message-text blockquote {
  margin: 0 0 0.9rem;
  padding: 0.1rem 0 0.1rem 0.9rem;
  border-left: 3px solid var(--color-brand-line);
  color: var(--color-muted);
}

.message-text hr {
  margin: 1.3rem 0;
  border: 0;
  border-top: 1px solid var(--color-line);
}

.message-text a {
  text-decoration: underline;
}

.message-user .message-body {
  width: fit-content;
  max-width: min(100%, 680px);
  padding: 0.75rem 1rem;
  border: 1px solid #f3e4d8;
  border-radius: 6px 16px 16px 16px;
  background: #fff8f2;
}

.message-user .message-name {
  display: none;
}

.typing {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #c2764a;
  animation: lunaTyping 1s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 0.14s;
}

.typing i:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes lunaTyping {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.message-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.message-sources > span {
  color: #a08b7b;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.message-sources a {
  max-width: 260px;
  overflow: hidden;
  padding: 0.3rem 0.55rem;
  border: 1px solid #f5e0cd;
  border-radius: 8px;
  background: #fff6ee;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.5rem 48px;
  padding: 0.7rem 0.85rem;
  border: 1px solid #f4c9d1;
  border-radius: 11px;
  color: #9e2540;
  background: #fff6f8;
  font-size: 0.82rem;
}

.chat-error button {
  border: 0;
  background: transparent;
  color: var(--color-brand-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.composer-wrap {
  position: relative;
  z-index: 5;
  padding: 0.8rem 1.25rem 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 26%);
}

.chat-composer {
  width: min(820px, 100%);
  min-height: 58px;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0 auto;
  padding: 0.68rem 0.72rem 0.68rem 1rem;
  border: 1px solid #eeddd0;
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 14px 42px rgba(102, 55, 24, 0.12);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-composer:focus-within {
  border-color: var(--color-brand-line);
  box-shadow: 0 14px 45px rgba(165, 82, 24, 0.16), 0 0 0 3px rgba(242, 100, 25, 0.12);
}

.chat-composer textarea {
  min-width: 0;
  flex: 1;
  max-height: 180px;
  resize: none;
  overflow-y: auto;
  padding: 0.55rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-ink);
  font: inherit;
  font-size: 0.94rem;
  line-height: 1.4;
}

.chat-composer textarea::placeholder {
  color: #a89383;
}

.send-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #ff7a2f, #ea570b);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(226, 87, 11, 0.26);
  transition: background 0.15s ease, transform 0.15s ease;
}

.send-button:hover {
  background: linear-gradient(135deg, #f96c1e, #d94f0c);
  transform: translateY(-1px);
}

.stop-button span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: currentColor;
}

.composer-note {
  margin: 0.55rem auto 0;
  color: #a89383;
  font-size: 0.7rem;
  text-align: center;
}

.settings-drawer {
  position: fixed;
  z-index: 80;
  inset: 0;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(46, 24, 10, 0.3);
  opacity: 0;
  cursor: default;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(3px);
}

.settings-sheet {
  position: absolute;
  top: 0;
  right: 0;
  width: min(720px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--color-canvas);
  box-shadow: -20px 0 70px rgba(69, 36, 14, 0.18);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.settings-drawer.open .settings-backdrop {
  opacity: 1;
}

.settings-drawer.open .settings-sheet {
  transform: translateX(0);
}

.settings-close {
  position: sticky;
  z-index: 4;
  top: 1rem;
  float: right;
  margin: 1rem 1rem -4rem 0;
  border: 1px solid var(--color-line);
  background: #fff;
  box-shadow: 0 5px 16px rgba(70, 37, 15, 0.1);
}

.settings-sheet .app-shell {
  min-height: 100%;
  padding: 2rem 1.5rem 3rem;
}

.settings-sheet .app-top,
.settings-sheet .app-main {
  width: min(620px, 100%);
}

.settings-sheet .app-top {
  padding-right: 3.5rem;
  margin-bottom: 2rem;
}

.mobile-backdrop {
  position: fixed;
  z-index: 15;
  inset: 0;
  background: rgba(46, 24, 10, 0.34);
  backdrop-filter: blur(2px);
}

@media (max-width: 900px) {
  .luna-workspace {
    display: block;
  }

  .chat-panel {
    height: 100vh;
  }

  .chat-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    box-shadow: 18px 0 55px rgba(62, 33, 14, 0.18);
    transition: transform 0.2s ease;
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close,
  .mobile-menu {
    display: inline-grid;
  }

  .mobile-menu {
    position: absolute;
    left: 1rem;
  }
}

@media (max-width: 680px) {
  .chat-topbar {
    min-height: 60px;
  }

  .top-settings {
    right: 0.65rem;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
    margin-top: 1.75rem;
  }

  .prompt-grid button {
    min-height: auto;
  }

  .chat-empty-state {
    padding-top: 2.5rem;
  }

  .hero-orb {
    width: 66px;
    height: 66px;
    margin-bottom: 1.2rem;
  }

  .message-list {
    width: min(100% - 1.25rem, 820px);
    padding-top: 1.4rem;
  }

  .message {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 0.65rem;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .message-text {
    font-size: 0.91rem;
  }

  .composer-wrap {
    padding: 0.65rem 0.65rem 0.75rem;
  }

  .chat-composer {
    min-height: 54px;
    border-radius: 16px;
  }

  .composer-note {
    display: none;
  }

  .settings-sheet .app-shell {
    padding: 1.25rem 1rem 2rem;
  }

  .settings-sheet .app-top {
    align-items: flex-start;
    padding-right: 3rem;
  }

  .settings-sheet .store-card {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
