:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #6d756f;
  --line: #dfe3dd;
  --paper: #ffffff;
  --canvas: #f6f7f3;
  --accent: #185c45;
  --accent-hover: #104a37;
  --accent-soft: #e7f1ec;
  --signal: #de5b44;
  --shadow: 0 16px 40px rgba(23, 32, 27, 0.08);
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(400px, 1fr) 390px;
  min-height: 100vh;
}

.sidebar,
.draft-panel {
  background: var(--paper);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
}

.brand,
.connection-row,
.topbar,
.operator,
.panel-header,
.approval-copy {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  padding: 0 8px 24px;
}

.brand-mark,
.welcome-mark {
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  font-weight: 700;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.new-campaign-button {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 7px;
  color: white;
  background: var(--accent);
  font-weight: 600;
}

.new-campaign-button:hover,
.send-button:hover,
.publish-button:hover {
  background: var(--accent-hover);
}

.nav-label {
  margin: 28px 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.campaign-list {
  display: grid;
  gap: 4px;
}

.campaign-item {
  width: 100%;
  padding: 10px 11px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-item:hover,
.campaign-item.active {
  color: var(--ink);
  background: #eff1ed;
}

.connection-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.connection-row {
  gap: 9px;
}

.connection-row div {
  min-width: 0;
}

.connection-row strong,
.connection-row span {
  display: block;
}

.connection-row strong {
  font-size: 13px;
}

.connection-row span,
.channel-name {
  color: var(--muted);
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a0a6a1;
}

.status-dot.connected {
  background: #3a9a6e;
  box-shadow: 0 0 0 3px #e3f1e9;
}

.channel-name {
  display: block;
  margin: 10px 0 0 17px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  justify-content: space-between;
  min-height: 86px;
  padding: 18px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 243, 0.94);
}

.topbar p,
.panel-header p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  max-width: 580px;
  overflow: hidden;
  font-size: 18px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operator {
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #cbd1cb;
  border-radius: 50%;
  color: var(--accent);
  background: white;
  font-weight: 700;
}

.mobile-menu {
  display: none;
  border: 0;
  background: transparent;
  font-size: 20px;
}

.conversation {
  overflow-y: auto;
  padding: 42px clamp(24px, 5vw, 70px);
}

.welcome {
  display: flex;
  max-width: 590px;
  min-height: 100%;
  margin: auto;
  flex-direction: column;
  justify-content: center;
}

.welcome-mark {
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 9px;
}

.welcome h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.welcome > p {
  margin: 12px 0 26px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.prompt-examples {
  display: grid;
  gap: 8px;
}

.prompt-examples button {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #3e4842;
  background: rgba(255, 255, 255, 0.66);
  text-align: left;
}

.prompt-examples button:hover {
  border-color: #aeb8b0;
  background: white;
}

.messages {
  display: grid;
  max-width: 650px;
  margin: 0 auto;
  gap: 22px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

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

.message-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: white;
  background: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.message.user .message-avatar {
  order: 2;
  border-radius: 50%;
  background: var(--accent);
}

.bubble {
  max-width: min(82%, 520px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .bubble {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 9px;
  margin: 0 clamp(24px, 5vw, 70px) 26px;
  padding: 8px;
  border: 1px solid #cad0ca;
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 28px rgba(23, 32, 27, 0.06);
}

.composer textarea {
  max-height: 140px;
  padding: 9px 10px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.5;
}

.send-button {
  width: 42px;
  height: 42px;
  align-self: end;
  border: 0;
  border-radius: 7px;
  color: white;
  background: var(--accent);
  font-size: 20px;
  font-weight: 600;
}

.draft-panel {
  display: flex;
  min-width: 0;
  padding: 24px;
  flex-direction: column;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.panel-header {
  justify-content: space-between;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
}

.draft-state {
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--muted);
  background: #eff1ed;
  font-size: 11px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-panel {
  display: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: white;
  font-size: 20px;
  line-height: 1;
}

.draft-form {
  padding-top: 18px;
}

fieldset {
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 0;
  gap: 9px;
  border: 0;
}

.draft-form label {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
}

.draft-form textarea,
.draft-form input {
  width: 100%;
  padding: 10px 11px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  color: var(--ink);
  background: #fbfcfa;
  font-size: 13px;
  line-height: 1.5;
}

.draft-form textarea:focus,
.draft-form input:focus {
  border-color: #7d9b8c;
  box-shadow: 0 0 0 3px #e5eee9;
}

.image-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 64px;
  gap: 6px;
}

.image-strip:empty {
  display: none;
}

.image-strip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 5px;
  background: #e8ebe7;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.media-check-row {
  display: flex;
  min-height: 25px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.link-button:hover {
  text-decoration: underline;
}

.media-check-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-check-row span.success {
  color: #23734f;
}

.media-check-row span.error {
  color: #9a3a2b;
}

.secondary-button,
.approve-button,
.publish-button {
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  font-weight: 600;
}

.secondary-button {
  margin-top: 15px;
  border: 1px solid #bdc6bf;
  color: var(--ink);
  background: white;
}

.secondary-button:hover {
  background: #f1f3f0;
}

.approval-section {
  margin-top: auto;
  padding-top: 22px;
}

.publish-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.publish-steps li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  color: #8b928d;
  font-size: 9px;
  text-align: center;
}

.publish-steps li::before {
  position: absolute;
  top: 10px;
  right: 50%;
  left: -50%;
  height: 1px;
  background: var(--line);
  content: "";
}

.publish-steps li:first-child::before {
  display: none;
}

.publish-steps span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid #cfd5cf;
  border-radius: 50%;
  background: white;
  font-size: 9px;
  font-weight: 700;
}

.publish-steps li.complete,
.publish-steps li.current {
  color: var(--accent);
}

.publish-steps li.complete::before {
  background: var(--accent);
}

.publish-steps li.complete span {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.publish-steps li.current span {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.approval-copy {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.approval-copy strong,
.approval-copy span {
  display: block;
}

.approval-copy strong {
  font-size: 13px;
}

.approval-copy span {
  max-width: 180px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.approve-button {
  border: 1px solid var(--accent);
  color: var(--accent);
  background: white;
}

.publish-button {
  margin-top: 8px;
  border: 0;
  color: white;
  background: var(--accent);
}

.publish-note {
  margin: 10px 4px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 15px;
  transform: translateY(20px);
  border: 1px solid #cad0ca;
  border-radius: 7px;
  opacity: 0;
  background: white;
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: #e4a99f;
  color: #8b2f20;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(360px, 1fr) 340px;
  }

  .draft-panel {
    padding: 20px;
  }
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .draft-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 12;
    width: min(390px, 92vw);
    transform: translateX(100%);
    box-shadow: var(--shadow);
    transition: transform 180ms ease;
  }

  .draft-panel.open {
    transform: translateX(0);
  }

  .close-panel {
    display: block;
  }
}

@media (max-width: 680px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    width: 250px;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
    transition: transform 180ms ease;
  }

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

  .workspace {
    min-height: 100dvh;
  }

  .mobile-menu {
    display: block;
  }

  .topbar {
    min-height: 72px;
    padding: 14px 16px;
  }

  .topbar h1 {
    max-width: 190px;
    font-size: 15px;
  }

  .operator span {
    display: none;
  }

  .conversation {
    padding: 30px 18px;
  }

  .welcome h2 {
    font-size: 26px;
  }

  .composer {
    margin: 0 14px 14px;
  }
}
