:root {
  color-scheme: light;
  --bg: #f4f5f1;
  --surface: #ffffff;
  --surface-2: #f9faf7;
  --text: #20231f;
  --muted: #6f756d;
  --subtle: #90978e;
  --line: #dde2d9;
  --line-strong: #c9d0c4;
  --accent: #126b53;
  --accent-2: #0f5f98;
  --accent-soft: #e7f2ec;
  --blue-soft: #e7f0f7;
  --warn: #9b5a12;
  --warn-soft: #fff2dc;
  --danger: #b7352a;
  --danger-soft: #fde8e5;
  --ok: #0f7a45;
  --ok-soft: #e5f4ea;
  --shadow: 0 18px 50px rgba(31, 41, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 220px),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill.is-ok,
.mini-pill.is-ok {
  border-color: rgba(15, 122, 69, 0.25);
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.is-warn,
.mini-pill.is-warn {
  border-color: rgba(155, 90, 18, 0.25);
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill.is-danger,
.mini-pill.is-danger {
  border-color: rgba(183, 53, 42, 0.25);
  background: var(--danger-soft);
  color: var(--danger);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.icon-button:hover {
  border-color: var(--line-strong);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(420px, 1.2fr) minmax(320px, 0.88fr);
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.panel-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.meta {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

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

.platform-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.platform-row.is-selected {
  border-color: rgba(18, 107, 83, 0.65);
  box-shadow: inset 0 0 0 1px rgba(18, 107, 83, 0.18);
}

.platform-logo,
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 750;
}

.platform-logo img,
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

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

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

.platform-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 750;
}

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

.connect-button,
.select-button,
.small-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 700;
}

.connect-button {
  background: var(--blue-soft);
  border-color: rgba(15, 95, 152, 0.22);
  color: var(--accent-2);
}

.connect-button:hover,
.select-button:hover,
.small-button:hover {
  border-color: var(--line-strong);
}

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

.account-option {
  display: grid;
  grid-template-columns: 22px 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-2);
}

.account-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.account-option .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 12px;
}

.account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.account-id {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.account-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segment {
  min-width: 58px;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 750;
}

.segment.is-active {
  color: var(--surface);
  background: var(--text);
}

.publish-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

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

input:focus,
textarea:focus {
  border-color: rgba(18, 107, 83, 0.72);
  box-shadow: 0 0 0 3px rgba(18, 107, 83, 0.12);
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr minmax(210px, 0.62fr);
  gap: 12px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 800;
}

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

.primary-button:hover {
  background: #0e5a46;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-2);
}

.preflight {
  display: grid;
  gap: 8px;
  padding: 14px 18px 0;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.check-row.is-ok {
  border-color: rgba(15, 122, 69, 0.24);
  background: var(--ok-soft);
  color: var(--ok);
}

.check-row.is-warn {
  border-color: rgba(155, 90, 18, 0.24);
  background: var(--warn-soft);
  color: var(--warn);
}

.check-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 900;
}

.flow-box {
  padding: 14px 18px 18px;
}

.empty-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
  background: rgba(255, 255, 255, 0.58);
}

.flow-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  margin-bottom: 12px;
}

.flow-id {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.task-list {
  display: grid;
  gap: 9px;
}

.task-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.task-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.task-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 750;
}

.task-detail {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  word-break: break-word;
}

.task-detail a {
  color: var(--accent-2);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  z-index: 20;
}

.toast {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(31, 41, 29, 0.12);
  padding: 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.toast.is-danger {
  border-left-color: var(--danger);
}

.toast.is-warn {
  border-left-color: var(--warn);
}

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

  .result-panel {
    grid-column: 1 / -1;
    min-height: 420px;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .topbar-status {
    justify-content: flex-start;
  }

  .workspace,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
