:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --ink: #111827;
  --muted: #68717d;
  --line: #e3ddd4;
  --surface: #ffffff;
  --soft: #f1ece5;
  --teal: #0f766e;
  --teal-soft: #e1f4f1;
  --coral: #df684a;
  --rose: #9f3f5f;
  --shadow: 0 22px 70px rgba(17, 24, 39, 0.18);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #111827;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(37, 48, 58, 0.92)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 86px);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.landing-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-nav {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.landing-brand {
  min-width: 0;
}

.landing-nav-link,
.landing-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 900;
  text-decoration: none;
}

.landing-nav-link {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 12px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 13px;
}

.landing-main {
  flex: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
  padding: clamp(32px, 7vw, 86px) clamp(16px, 4vw, 48px);
}

.landing-hero {
  max-width: 680px;
}

.landing-eyebrow {
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.landing-hero h2 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.98;
  font-weight: 950;
  letter-spacing: 0;
}

.landing-hero > p {
  margin: 18px 0 0;
  max-width: 620px;
  color: #55606b;
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.55;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}

.landing-cta {
  min-height: 50px;
  padding: 0 18px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 16px 34px rgba(17, 24, 39, 0.16);
}

.landing-actions span {
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.landing-preview {
  display: flex;
  justify-content: center;
}

.preview-phone {
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.14);
}

.preview-message {
  border-radius: 16px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.45;
}

.preview-message.user {
  margin-left: 48px;
  background: var(--ink);
  color: #fff;
}

.preview-message.assistant {
  margin-top: 12px;
  margin-right: 30px;
  background: var(--teal-soft);
  color: #315c57;
}

.preview-message.assistant strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.preview-message.assistant span {
  display: block;
}

.preview-replies {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.preview-replies span {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #fffaf5;
  color: #5e554d;
  font-size: 12px;
  font-weight: 900;
}

.landing-features {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.landing-features article {
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}

.landing-features strong {
  display: block;
  font-size: 15px;
  font-weight: 950;
}

.landing-features p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.phone {
  width: min(100%, 430px);
  height: min(860px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.topbar {
  flex: 0 0 auto;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand,
.tabs,
.chat-toolbar,
.dimension-top,
.reply > div,
.composer-actions,
.composer-main,
.composer-foot,
.history-head,
.history-item {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
}

.mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.tabs {
  gap: 5px;
  margin-top: 8px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--soft);
}

.tab {
  flex: 1;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #6d655d;
  font-size: 13px;
  font-weight: 850;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.08);
}

.auth-status {
  margin-top: 7px;
  border-radius: 999px;
  padding: 5px 8px;
  background: #fffaf5;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.auth-status.connected {
  background: var(--teal-soft);
  color: var(--teal);
  border-color: rgba(15, 118, 110, 0.22);
}

.auth-status.error {
  background: #fff0e9;
  color: #a4452d;
  border-color: rgba(164, 69, 45, 0.2);
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.screen::-webkit-scrollbar,
.message-list::-webkit-scrollbar {
  width: 0;
}

.chat-screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-toolbar {
  flex: 0 0 auto;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
}

.chat-toolbar .eyebrow {
  display: none;
}

.eyebrow {
  display: block;
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chat-toolbar h2,
.history-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.12;
  font-weight: 900;
  letter-spacing: 0;
}

.message-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 2px 0 12px;
}

.welcome-card,
.message-bubble,
.composer,
.history-item,
.empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.welcome-card {
  padding: 16px;
}

.welcome-card h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.welcome-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.summary-grid span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #fffaf5;
  color: #5e554d;
  font-size: 12px;
  font-weight: 850;
}

.message {
  display: flex;
  scroll-margin-top: 8px;
}

.user-message {
  justify-content: flex-end;
}

.assistant-message {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 94%;
  padding: 11px;
}

.user-message .message-bubble {
  background: var(--ink);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
}

.assistant-message .message-bubble {
  width: 100%;
  background: #fff;
}

.message-label {
  display: block;
  margin-bottom: 6px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.user-message .message-label,
.user-message small {
  color: rgba(255, 255, 255, 0.72);
}

.message-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.48;
}

.message-text {
  white-space: normal;
  word-break: break-word;
}

.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.message-files span {
  max-width: 100%;
  overflow: hidden;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-bubble small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.analysis-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: #fffdf9;
}

.analysis-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.analysis-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.analysis-summary strong {
  font-size: 18px;
}

.analysis-summary meter {
  width: 100%;
  height: 9px;
  margin-top: 9px;
}

.analysis-summary p {
  margin-top: 9px;
  color: #4f5a64;
  font-size: 13px;
}

.dimension-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.dimension {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fffdf9;
}

.dimension-top {
  justify-content: space-between;
  gap: 10px;
}

.dimension-top span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.dimension-top strong {
  font-size: 15px;
}

.dimension-top b {
  color: var(--teal);
  font-size: 18px;
}

.bar {
  height: 7px;
  overflow: hidden;
  margin-top: 9px;
  border-radius: 999px;
  background: var(--soft);
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.dimension p {
  margin-top: 8px;
  color: #525d68;
  font-size: 13px;
}

.dimension small {
  color: var(--muted);
}

.support-card {
  margin-top: 10px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--teal-soft);
}

.support-card strong,
.reply-list > strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.support-card p {
  color: #3f5f5a;
  font-size: 13px;
}

.reply-list {
  margin-top: 10px;
}

.reply {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fffdf9;
}

.reply > div {
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  background: #f8f2eb;
}

.reply strong {
  font-size: 13px;
}

.reply p {
  padding: 9px;
  color: #525d68;
  font-size: 13px;
}

.composer {
  flex: 0 0 auto;
  padding: 8px;
  box-shadow: 0 -10px 24px rgba(17, 24, 39, 0.06);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.composer-main {
  min-height: 46px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  background: #fffdf9;
}

.composer-main.dragging,
.composer-main:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.attach-button,
.send-button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  font-weight: 900;
}

.attach-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.send-button {
  min-width: 52px;
  height: 36px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
}

.attachments {
  display: grid;
  gap: 7px;
  margin-bottom: 7px;
}

.attachment {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px;
  background: #fffdf9;
}

.attachment img,
.file-badge {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 7px;
}

.attachment img {
  object-fit: cover;
}

.file-badge {
  display: grid;
  place-items: center;
  background: var(--soft);
  color: #5f544b;
  font-size: 10px;
  font-weight: 900;
}

.attachment-info {
  min-width: 0;
  flex: 1;
}

.attachment-info strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-info span,
.attachment-info small,
.privacy-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.attachment-info small {
  display: block;
  margin-top: 2px;
  color: var(--teal);
  font-weight: 800;
}

.remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: #fff0e9;
  color: #a4452d;
  font-weight: 900;
}

.chat-box {
  min-width: 0;
  width: 100%;
  min-height: 36px;
  max-height: 118px;
  flex: 1;
  resize: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 8px 2px;
  outline: none;
  overflow-y: auto;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-box::-webkit-scrollbar {
  width: 0;
}

.composer-main .chat-box:focus {
  box-shadow: none;
}

.context-input:focus {
  border-color: rgba(15, 118, 110, 0.58);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.context-block {
  margin-bottom: 7px;
}

.context-input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  outline: none;
  background: #fffdf9;
  color: var(--ink);
  font-size: 12px;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
}

.context-chip {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  background: #fffdf9;
  text-align: center;
}

.context-chip.selected {
  border-color: rgba(15, 118, 110, 0.5);
  background: var(--teal-soft);
}

.context-chip strong {
  display: block;
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
}

.context-chip span {
  display: none;
}

.composer-actions {
  gap: 8px;
  margin-top: 7px;
}

.composer-foot {
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.composer-foot span {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.main-button,
.mini-button {
  border: 0;
  border-radius: var(--radius);
  font-weight: 900;
}

.main-button {
  flex: 1;
  min-height: 40px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 20px rgba(17, 24, 39, 0.14);
}

.mini-button {
  min-height: 34px;
  padding: 0 10px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
}

.mini-button.danger {
  background: #fff0e9;
  color: #a4452d;
}

.mini-button.ghost {
  background: var(--soft);
  color: #5f544b;
}

.privacy-note {
  margin: 6px 0 0;
}

.history-screen {
  overflow: auto;
}

.history-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  align-items: stretch;
  gap: 8px;
  padding: 10px;
}

.history-item.editing {
  display: block;
}

.history-main {
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.history-main strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-main span,
.history-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.history-main p {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: #525d68;
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.rename-panel {
  display: grid;
  gap: 8px;
}

.rename-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  outline: none;
  background: #fffdf9;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.rename-input:focus {
  border-color: rgba(15, 118, 110, 0.58);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.rename-actions {
  display: flex;
  gap: 8px;
}

.empty {
  margin-top: 10px;
  padding: 24px 16px;
  text-align: center;
}

.empty h3 {
  margin: 0;
  font-size: 18px;
}

.empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  width: min(360px, calc(100% - 32px));
  transform: translateX(-50%);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.22);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 520px) {
  .app-shell {
    padding: 0;
  }

  .landing-nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }

  .landing-nav-link {
    width: 100%;
  }

  .landing-main {
    grid-template-columns: 1fr;
    padding: 28px 16px;
  }

  .landing-hero h2 {
    font-size: 42px;
  }

  .landing-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .landing-cta {
    width: 100%;
  }

  .landing-actions span {
    max-width: none;
  }

  .landing-features {
    grid-template-columns: 1fr;
  }

  .phone {
    width: 100%;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .screen {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  .context-grid,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .composer-actions {
    flex-direction: column;
  }

  .main-button,
  .composer-actions .mini-button {
    width: 100%;
  }
}
