:root {
  --bg: #fff7fb;
  --surface: #ffffff;
  --surface-soft: #fffafd;
  --ink: #332733;
  --muted: #766a74;
  --line: #ead7e0;
  --rose: #f29db7;
  --rose-strong: #d85f8c;
  --wine: #7c2f50;
  --mint: #bfe8dd;
  --sky: #b9d7ff;
  --amber: #ffdca8;
  --danger: #b64058;
  --shadow: 0 18px 48px rgba(124, 47, 80, 0.12);
  --topbar-height: 57px;
  --composer-space: 168px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, #f8fbff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

main {
  min-height: calc(100vh - 144px);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 250, 253, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.92rem;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
}

.language-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-decoration: none;
}

.language-switcher a:hover,
.language-switcher a.is-active {
  background: var(--wine);
  color: #fff;
}

.conversation-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
}

.conversation-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--wine);
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.narrow {
  width: min(520px, calc(100% - 32px));
}

.home-band {
  padding: 24px 0 18px;
}

.home-hero {
  display: grid;
  gap: 22px;
  align-items: center;
}

.home-hero.with-conversations {
  align-items: start;
}

.home-copy {
  padding: 10px 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--wine);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: 2.45rem;
}

h2 {
  font-size: 1.2rem;
}

.home-copy p:not(.eyebrow),
.muted {
  color: var(--muted);
}

.home-copy p:not(.eyebrow) {
  max-width: 62ch;
  margin: 14px 0 0;
  font-size: 1.04rem;
}

.home-visual {
  padding: 0;
}

.home-visual img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-actions,
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-actions {
  margin-top: 22px;
}

.button,
.link-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 11px 16px;
  background: var(--surface);
  color: var(--wine);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px var(--line);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  background: var(--wine);
  color: #fff;
  box-shadow: none;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.7);
}

.button.compact {
  min-height: 40px;
  padding: 9px 12px;
  font-size: 0.94rem;
}

.button.danger {
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.info-grid {
  display: grid;
  gap: 12px;
  padding: 16px 0 28px;
}

.info-item,
.auth-panel,
.conversation-item,
.side-section,
.notice,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 28px rgba(124, 47, 80, 0.06);
}

.info-item {
  padding: 16px;
}

.info-item p {
  margin: 8px 0 0;
  color: var(--muted);
}

.conversation-list {
  padding: 10px 0 38px;
}

.home-conversations {
  margin-top: 22px;
  padding: 0;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.conversation-items {
  display: grid;
  gap: 10px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  color: var(--ink);
}

.conversation-item:hover {
  border-color: var(--rose);
  text-decoration: none;
}

.conversation-item strong,
.conversation-item small,
.conversation-date {
  display: block;
}

.conversation-item small,
.conversation-date {
  color: var(--muted);
  font-size: 0.86rem;
}

.conversation-date {
  text-align: right;
}

.notice,
.empty-state {
  padding: 14px;
  color: var(--muted);
}

.flash {
  position: relative;
  z-index: 30;
  width: min(760px, calc(100% - 32px));
  margin: 12px auto 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--sky);
  color: #17304d;
  font-weight: 700;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
}

.flash-success {
  background: var(--mint);
  color: #173d35;
}

.flash-error,
.form-error {
  background: #ffe2e8;
  color: #7f2037;
}

.auth-panel {
  margin-top: 28px;
  padding: 18px;
}

.auth-panel h1 {
  font-size: 1.8rem;
}

.auth-panel .muted {
  margin: 10px 0 0;
}

.form-stack {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.inline-form {
  margin-top: 14px;
}

label {
  color: var(--ink);
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(242, 157, 183, 0.5);
  outline-offset: 2px;
}

.form-error {
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
}

.check-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  font-weight: 700;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 4px;
}

.conversation-layout {
  display: grid;
  gap: 14px;
  width: min(1220px, calc(100% - 24px));
  margin: 14px auto 32px;
}

.conversation-main {
  min-width: 0;
}

.conversation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.conversation-title h1 {
  font-size: 1.5rem;
}

.status-pill,
.mini-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--mint);
  color: #173d35;
  font-size: 0.82rem;
  font-weight: 900;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 46vh;
  padding: 12px 0 120px;
}

.message {
  width: min(86%, 620px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(124, 47, 80, 0.07);
}

.message.mine {
  align-self: flex-end;
  background: #ffeaf2;
  border-color: #f4bdd0;
}

.message.theirs {
  align-self: flex-start;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.message-meta strong {
  color: var(--wine);
}

.message-text {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.image-button {
  display: block;
  width: min(100%, 330px);
  margin-top: 10px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.image-button img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  background: #fff;
}

.composer {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 8;
  display: grid;
  gap: 8px;
  width: calc(100% - 24px);
  max-width: 760px;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 253, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.composer textarea {
  min-height: 48px;
  max-height: 130px;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-media {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--wine);
  font-weight: 900;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-preview {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-preview[hidden] {
  display: none;
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-height: 0;
  border: 1px solid #f4bcc8;
  border-radius: 999px;
  padding: 0;
  background: #fff;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.composer-status {
  min-height: 18px;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 700;
}

.conversation-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.drawer-head {
  display: none;
}

.drawer-close {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--wine);
  font-weight: 900;
}

.drawer-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  z-index: 74;
  background: rgba(51, 39, 51, 0.35);
}

.drawer-backdrop[hidden] {
  display: none;
}

.side-section {
  padding: 14px;
}

.participant-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.participant-main {
  min-width: 0;
}

.participant-row strong,
.participant-row small {
  display: block;
}

.participant-row small {
  color: var(--muted);
  font-size: 0.82rem;
}

.participant-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.participant-actions form {
  margin: 0;
}

.mini-danger {
  min-height: 28px;
  border: 1px solid #f4bcc8;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 900;
}

.danger-zone {
  border-color: #f4bcc8;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 64px 16px 16px;
  background: rgba(35, 24, 33, 0.86);
}

.image-modal[hidden] {
  display: none;
}

.image-modal img {
  max-width: 100%;
  max-height: calc(100dvh - 80px);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-out;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--wine);
  font-weight: 900;
}

.footer {
  padding: 24px 16px 32px;
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
}

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

@media (max-width: 759px) {
  body.conversation-page {
    height: 100dvh;
    overflow: hidden;
  }

  .conversation-page .topbar {
    position: fixed;
    inset: 0 0 auto;
    height: var(--topbar-height);
    z-index: 80;
  }

  .conversation-page .topnav {
    gap: 6px;
  }

  .conversation-page .topnav a {
    display: none;
  }

  .conversation-page .language-switcher a {
    display: inline-flex;
  }

  .conversation-page .conversation-menu-toggle {
    display: inline-flex;
  }

  .conversation-page main {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding-top: var(--topbar-height);
  }

  .conversation-page .flash {
    position: fixed;
    top: calc(var(--topbar-height) + 8px);
    right: 12px;
    left: 12px;
    z-index: 90;
    width: auto;
    margin: 0;
  }

  .conversation-page .conversation-layout {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
  }

  .conversation-page:has(.flash) .conversation-layout {
    padding-top: 68px;
  }

  .conversation-page .conversation-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  .conversation-page .conversation-title {
    display: none;
  }

  .conversation-page .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 12px calc(var(--composer-space) + 16px);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  .conversation-page .message {
    width: min(88%, 620px);
  }

  .conversation-page .composer {
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: 100%;
    max-width: none;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .conversation-page .composer textarea {
    min-height: 46px;
    max-height: 96px;
  }

  .conversation-page .conversation-side {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    z-index: 75;
    display: grid;
    align-content: start;
    width: min(88vw, 380px);
    padding: 14px;
    overflow-y: auto;
    background: var(--bg);
    box-shadow: -18px 0 44px rgba(51, 39, 51, 0.16);
    transform: translateX(105%);
    transition: transform 0.22s ease;
  }

  .conversation-page.drawer-open .conversation-side {
    transform: translateX(0);
  }

  .conversation-page .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .conversation-page.drawer-open .drawer-backdrop:not([hidden]) {
    display: block;
  }

  .conversation-page .footer {
    display: none;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
    padding-inline: 12px;
  }

  .brand {
    gap: 6px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .language-switcher a {
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    font-size: 0.68rem;
  }
}

@media (min-width: 760px) {
  :root {
    --topbar-height: 61px;
    --composer-space: 176px;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding: 14px 28px;
  }

  .flash {
    position: sticky;
    top: 76px;
  }

  body.conversation-page {
    height: 100dvh;
    overflow: hidden;
  }

  .conversation-page main {
    height: calc(100dvh - var(--topbar-height));
    min-height: 0;
    overflow: hidden;
  }

  .conversation-page .flash {
    position: fixed;
    top: calc(var(--topbar-height) + 12px);
    right: 24px;
    left: 24px;
    z-index: 90;
    width: min(760px, calc(100% - 48px));
    margin: 0 auto;
  }

  .home-band {
    padding-top: 46px;
  }

  .home-hero {
    grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.85fr);
  }

  .home-hero.with-conversations {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 3.6rem;
  }

  .info-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .auth-panel {
    margin-top: 56px;
    padding: 24px;
  }

  .conversation-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    margin-top: 22px;
  }

  .conversation-page .conversation-layout {
    height: 100%;
    margin-top: 0;
    padding-top: 18px;
    padding-bottom: 0;
  }

  .conversation-page:has(.flash) .conversation-layout {
    padding-top: 82px;
  }

  .conversation-page .conversation-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  .conversation-page .messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 0 calc(var(--composer-space) + 16px);
    scroll-behavior: smooth;
  }

  .conversation-page .conversation-side {
    max-height: calc(100dvh - var(--topbar-height) - 36px);
    overflow-y: auto;
  }

  .conversation-title h1 {
    font-size: 1.9rem;
  }

  .composer {
    left: max(24px, calc((100vw - 1220px) / 2));
    right: auto;
    width: min(calc(100vw - 392px), 820px);
  }
}
