:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-soft: #fbfcfd;
  --border: #dfe5ea;
  --text: #17212b;
  --muted: #667085;
  --teal: #007f7a;
  --teal-soft: #e6f5f3;
  --warn: #a14d0b;
  --warn-bg: #fff7e6;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app {
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 16px;
}

.login-app {
  align-items: center;
  display: flex;
  justify-content: center;
  padding: 24px;
}

.login-shell {
  align-items: stretch;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  width: min(100%, 980px);
}

.login-intro {
  align-content: center;
  background: var(--text);
  border-radius: 8px;
  color: #fff;
  display: grid;
  gap: 18px;
  min-height: 440px;
  padding: 32px;
}

.login-intro .brand-mark {
  background: #fff;
  color: var(--teal);
}

.login-intro h1 {
  font-size: 38px;
  line-height: 1;
  margin: 0;
}

.login-intro p {
  color: rgba(255, 255, 255, 0.78);
  font-size: 16px;
  line-height: 1.55;
  margin: 10px 0 0;
  max-width: 420px;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  padding: 18px;
  width: 100%;
}

.login-key-field {
  display: block;
  position: relative;
}

.login-key-field input {
  padding-right: 52px;
}

.login-key-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.login-key-toggle:active {
  transform: translateY(calc(-50% + 1px));
}

.login-brand {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  padding-bottom: 14px;
}

.login-brand h1 {
  font-size: 22px;
  line-height: 1.05;
  margin: 0;
}

.login-summary {
  border-left: 3px solid var(--teal);
  color: var(--text);
  display: grid;
  gap: 4px;
  padding: 2px 0 2px 10px;
}

.login-summary strong {
  font-size: 14px;
}

.login-summary span {
  color: #3b4a58;
  font-size: 13px;
  line-height: 1.4;
}

.login-brand p,
.muted,
.login-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field label {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.login-key-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-key-actions .secondary-button {
  justify-content: center;
  min-width: 0;
  width: 100%;
}

.login-panel .primary-button {
  width: 100%;
}

.login-status {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.shell {
  display: grid;
  grid-template-columns: 290px minmax(420px, 1fr) 330px;
  gap: 14px;
  max-width: 1680px;
  margin: 0 auto;
  width: 100%;
}

.shell > * {
  min-width: 0;
}

.header {
  grid-column: 1 / -1;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  max-width: 100%;
  min-width: 0;
  min-height: 76px;
  overflow: hidden;
  padding: 14px 18px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark,
.platform-mark,
.panel-icon,
.insight-icon,
.step-number {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

.brand-mark {
  background: var(--teal);
  border-radius: 8px;
  color: #fff;
  flex: 0 0 auto;
  height: 42px;
  width: 42px;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.05;
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button,
.danger-button {
  align-items: center;
  border-radius: 7px;
  display: inline-flex;
  font-weight: 750;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  white-space: nowrap;
}

.primary-button {
  background: var(--teal);
  border: 1px solid var(--teal);
  color: #fff;
}

.primary-button.dark {
  background: var(--text);
  border-color: var(--text);
}

.secondary-button,
.icon-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: #2f3f55;
}

.secondary-button.danger-inline {
  background: #fff7f7;
  border-color: #f0c8c8;
  color: #a61b1b;
}

.secondary-button.compact-button {
  font-size: 12px;
  min-height: 34px;
  padding: 0 10px;
}

.danger-button {
  background: #fff7f7;
  border: 1px solid #f0c8c8;
  color: #a61b1b;
}

.primary-button:active,
.secondary-button:active,
.icon-button:active,
.danger-button:active {
  transform: translateY(1px);
}

.icon-button {
  height: 34px;
  min-height: 34px;
  padding: 0;
  width: 34px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 14px;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.panel-title {
  align-items: center;
  display: flex;
  gap: 9px;
}

.panel-title h2 {
  font-size: 17px;
  margin: 0;
}

.panel-icon {
  background: var(--teal-soft);
  border-radius: 7px;
  color: var(--teal);
  height: 30px;
  width: 30px;
}

.account-list,
.right-stack,
.workspace,
.material-list,
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 100%;
  min-width: 0;
}

.account-card,
.empty-state,
.preview-card,
.metric-card,
.recent-row,
.scheduled-row,
.plan-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  max-width: 100%;
  min-width: 0;
}

.account-card {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.account-card.selected {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.account-main {
  align-items: center;
  display: flex;
  gap: 10px;
}

.account-main strong,
.recent-row strong,
.scheduled-row strong {
  display: block;
  font-size: 14px;
}

.account-main span,
.recent-row span,
.scheduled-row span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.account-card p,
.empty-state p,
.insight-row p,
.plan-card p,
.recent-row p,
.scheduled-row p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.recent-row em {
  color: var(--warn);
  display: block;
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.platform-mark {
  border-radius: 7px;
  color: #fff;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  height: 34px;
  width: 34px;
}

.platform-linkedin {
  background: #0a66c2;
}

.platform-x {
  background: #111;
}

.platform-instagram {
  background: #e1306c;
}

.platform-threads {
  background: #4b5563;
}

.badge {
  background: #eef2f6;
  border-radius: 999px;
  color: #344054;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  width: max-content;
}

.badge.live {
  background: var(--teal-soft);
  color: var(--teal);
}

.empty-state {
  padding: 14px;
}

.empty-state strong {
  display: block;
  font-size: 15px;
  margin-bottom: 8px;
}

.workspace {
  min-height: 720px;
}

.destinations {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.readiness-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.readiness-row {
  align-items: flex-start;
  background: var(--warn-bg);
  border: 1px solid rgba(161, 77, 11, 0.18);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr;
  padding: 8px 10px;
}

.readiness-row.ready {
  background: var(--teal-soft);
  border-color: rgba(0, 127, 122, 0.18);
}

.readiness-row p {
  color: #325d5a;
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
}

.setup-action-button {
  justify-content: center;
  width: 100%;
}

.live-setup-panel .panel-header {
  margin-bottom: 10px;
}

.setup-list {
  display: grid;
  gap: 8px;
}

.setup-row {
  align-items: flex-start;
  background: var(--warn-bg);
  border: 1px solid rgba(161, 77, 11, 0.18);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 8px;
}

.setup-row.ready {
  background: var(--teal-soft);
  border-color: rgba(0, 127, 122, 0.18);
}

.setup-row p {
  color: #325d5a;
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
}

.setup-row .compact-button {
  grid-column: 1 / -1;
  width: 100%;
}

.destination-chip,
.tone-chip,
.keyword-chip {
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  min-height: 38px;
  max-width: 100%;
  padding: 0 12px;
}

.destination-chip.selected,
.tone-chip.selected {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 800;
}

.warning {
  align-items: flex-start;
  background: var(--warn-bg);
  border-radius: 8px;
  color: var(--warn);
  display: flex;
  gap: 10px;
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 11px 12px;
}

.warning::before {
  background: var(--warn);
  border-radius: 999px;
  content: "";
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.live-box {
  background: var(--teal-soft);
  border: 1px solid rgba(0, 127, 122, 0.22);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.live-box strong {
  color: var(--teal);
}

.live-box p {
  color: #325d5a;
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

.live-box .credential-source {
  color: var(--teal);
  font-size: 12px;
  font-weight: 750;
}

.oauth-fallback-link {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(0, 127, 122, 0.28);
  border-radius: 7px;
  color: var(--teal);
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
}

.live-box label {
  color: var(--text);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
}

.form-section {
  display: grid;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}

.form-section label,
.field-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

textarea,
input,
select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  min-width: 0;
  outline: none;
  padding: 12px;
  width: 100%;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 127, 122, 0.12);
}

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

.tone-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}

.composer-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.publish-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.plan-card {
  background: var(--teal-soft);
  padding: 12px;
}

.source-list {
  display: grid;
  gap: 6px;
}

.source-row {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr;
  min-width: 0;
  padding: 8px;
}

.source-row p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
}

.plan-card strong {
  display: block;
  margin-bottom: 8px;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.keyword-chip {
  border-radius: 999px;
  color: var(--teal);
  font-size: 12px;
  min-height: 28px;
}

.preview-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.preview-head {
  align-items: center;
  display: flex;
  gap: 10px;
}

.preview-text {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.creative-preview {
  background: var(--teal-soft);
  border: 1px solid rgba(0, 127, 122, 0.25);
  border-radius: 8px;
  color: var(--teal);
  min-height: 96px;
  padding: 12px;
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  padding: 12px;
}

.metric-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric-card strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}

.metric-card em {
  color: var(--teal);
  display: block;
  font-size: 12px;
  font-style: normal;
  margin-top: 4px;
}

.insight-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 30px 1fr;
}

.insight-icon,
.step-number {
  background: var(--teal-soft);
  border-radius: 7px;
  color: var(--teal);
  height: 30px;
  width: 30px;
}

.readiness {
  background: #eef2f6;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.readiness span {
  background: var(--teal);
  display: block;
  height: 100%;
}

.step-row,
.recent-row,
.scheduled-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 28px 1fr;
}

.material-asset {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.material-asset img {
  aspect-ratio: 1;
  background: var(--bg);
  display: block;
  object-fit: cover;
  width: 100%;
}

.asset-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.asset-actions a {
  text-decoration: none;
}

.material-history {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 10px;
}

.material-history strong,
.material-history p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-history p {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
}

.material-history a {
  min-width: 42px;
  padding: 0 10px;
  text-decoration: none;
}

.recent-row,
.scheduled-row {
  grid-template-columns: 34px 1fr;
  padding: 10px;
}

.recent-row,
.scheduled-row {
  align-items: center;
  grid-template-columns: 34px minmax(0, 1fr) 36px;
}

.step-number {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  height: 24px;
  width: 24px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.38);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: fixed;
  z-index: 20;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.25);
  max-height: min(760px, 92vh);
  max-width: 640px;
  overflow: auto;
  padding: 18px;
  width: 100%;
}

.modal-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
}

.modal-grid {
  display: grid;
  gap: 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.provider-grid,
.schedule-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-button,
.schedule-button {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  min-height: 38px;
  padding: 0 12px;
}

.provider-button.selected,
.schedule-button.selected {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .right-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app {
    padding: 10px;
  }

  .login-shell {
    display: flex;
    width: min(100%, 420px);
  }

  .login-intro {
    display: none;
  }

  .shell {
    display: flex;
    flex-direction: column;
    margin: 0;
    max-width: 350px;
    width: 100%;
  }

  .header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .header-actions {
    flex-direction: column;
    width: 100%;
  }

  .header .primary-button,
  .header .secondary-button {
    width: 100%;
  }

  .brand h1 {
    font-size: 20px;
  }

  .brand p {
    line-height: 1.3;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .brand > div {
    min-width: 0;
  }

  .panel,
  .empty-state,
  .warning,
  .form-section,
  .preview-card,
  textarea,
  input {
    max-width: 100%;
  }

  .right-stack {
    display: flex;
  }

  .composer-actions,
  .publish-actions,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .publish-actions .secondary-button,
  .publish-actions .primary-button {
    width: 100%;
  }

  .tone-chip,
  .secondary-button {
    white-space: normal;
    text-align: center;
  }

  .tone-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .empty-state p,
  .warning,
  textarea {
    max-width: 300px;
  }
}
