:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --soft: #f8fafc;
  --text: #171717;
  --muted: #7b7f87;
  --line: #e5e7eb;
  --blue: #3478f6;
  --blue-dark: #1d4ed8;
  --orange: #f5b94f;
  --green: #23a455;
  --danger: #b42318;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
}

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

.side-panel {
  border-right: 1px solid var(--line);
  background: #eef1f5;
  padding: 18px;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

h2 {
  font-size: 16px;
}

p {
  color: var(--muted);
}

.control-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  margin-bottom: 14px;
  padding: 16px;
}

.control-panel h2 {
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #424854;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

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

textarea {
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

.button-row button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
  padding: 9px 14px;
}

.button-row button,
.primary-button {
  background: var(--blue);
  color: #fff;
}

.button-row button:hover,
.primary-button:hover {
  background: var(--blue-dark);
}

.button-row button.secondary,
.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.compact-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.compact-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.compact-item.selected {
  border-color: var(--blue);
  background: #eef5ff;
}

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

.compact-select-button {
  display: grid;
  gap: 4px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.compact-delete-button,
.compact-run-button,
.inline-run-button {
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.compact-run-button,
.inline-run-button {
  background: var(--blue);
}

.compact-delete-button {
  background: #dc2626;
}

.compact-delete-button,
.compact-run-button {
  padding: 8px 10px;
}

#logOutput {
  min-height: 130px;
  max-height: 300px;
  overflow: auto;
  border-radius: 10px;
  background: #101827;
  color: #dbeafe;
  font-size: 12px;
  padding: 12px;
  white-space: pre-wrap;
}

.stage {
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  padding: 18px 24px 28px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  width: min(100%, 760px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
  margin-bottom: 18px;
  padding: 14px 16px;
}

.status-bar span {
  color: var(--muted);
}

.phone-frame {
  width: 430px;
  min-height: 820px;
  border: 10px solid #111827;
  border-radius: 42px;
  background: #111827;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.phone-screen {
  min-height: 800px;
  background: #f5f5f6;
  overflow: hidden;
  position: relative;
}

.mobile-page {
  min-height: 800px;
  padding: 28px 17px 94px;
  position: relative;
}

.mobile-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-bottom: 22px;
}

.nav-button {
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 0;
}

.nav-action {
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
}

.nav-actions {
  display: flex;
  gap: 14px;
}

.danger-action {
  color: #dc2626;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px 0 34px;
}

.hero-mark {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 22px;
  background: #3fa0d7;
  color: #fff;
  font-size: 34px;
  font-weight: 900;
}

.page-title {
  font-size: 35px;
  letter-spacing: 0;
  line-height: 1.05;
  margin-bottom: 22px;
}

.hero-title {
  font-size: 32px;
  letter-spacing: 0;
  line-height: 1.1;
}

.type-grid {
  display: grid;
  gap: 16px;
}

.type-card,
.mobile-card {
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: none;
}

.type-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  color: var(--text);
  cursor: pointer;
  padding: 22px;
  text-align: left;
}

.type-icon,
.row-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: #eef5ff;
  color: var(--blue);
  font-weight: 900;
}

.type-card strong {
  display: block;
  font-size: 21px;
  margin-bottom: 4px;
}

.type-card small {
  color: var(--muted);
  font-size: 15px;
}

.mobile-card {
  margin-bottom: 16px;
  overflow: hidden;
  padding: 0;
}

.scenario-list-card {
  display: grid;
}

.scenario-filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: -8px 0 18px;
}

.scenario-filter-tabs button {
  border: 1px solid #dce4ef;
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  min-height: 38px;
  padding: 0 10px;
}

.scenario-filter-tabs button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.scenario-row {
  cursor: pointer;
  min-height: 84px;
}

.scenario-row-control {
  display: flex;
  justify-content: flex-end;
}

.inline-run-button {
  min-width: 72px;
  padding: 8px 10px;
}

.empty-state-card {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 28px;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: #eef5ff;
  color: var(--blue);
  font-size: 24px;
  font-weight: 900;
}

.empty-state-card h3 {
  font-size: 22px;
}

.empty-state-card p,
.sheet-empty {
  color: var(--muted);
  font-size: 15px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 18px 12px;
}

.card-header h2 {
  font-size: 28px;
}

.card-subtitle {
  color: var(--muted);
  font-size: 16px;
  margin-top: 2px;
}

.add-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
}

.mobile-row {
  display: grid;
  grid-template-columns: 58px 1fr 22px;
  gap: 12px;
  align-items: center;
  min-height: 88px;
  border-top: 1px solid #ececec;
  background: #fff;
  color: var(--text);
  padding: 12px 18px;
  text-align: left;
}

.mobile-row:first-child {
  border-top: 0;
}

.target-action-row .row-icon {
  background: #f3f7ff;
}

.mobile-row-title {
  display: block;
  font-size: 19px;
  font-weight: 850;
  line-height: 1.2;
}

.mobile-row-subtitle {
  display: block;
  color: var(--muted);
  font-size: 16px;
  margin-top: 3px;
}

.chevron {
  color: #c6c6c8;
  font-size: 34px;
  line-height: 1;
}

.empty-row {
  border-top: 1px solid #ececec;
  color: var(--muted);
  font-size: 16px;
  padding: 18px;
}

.name-card {
  padding: 18px;
}

.name-card input,
.name-card textarea,
.sheet input,
.sheet select {
  border-radius: 12px;
  font-size: 15px;
  min-height: 44px;
}

.name-card textarea {
  min-height: 76px;
}

.save-bar {
  position: absolute;
  left: 17px;
  right: 17px;
  bottom: 18px;
}

.save-button {
  width: 100%;
  min-height: 58px;
  border-radius: 13px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  font-weight: 850;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  background: rgba(17, 24, 39, 0.45);
  z-index: 20;
}

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

.sheet {
  width: min(680px, calc(100vw - 34px));
  max-height: min(760px, calc(100vh - 48px));
  border-radius: 26px 26px 0 0;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet-header {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.sheet-header h2 {
  text-align: center;
}

.icon-button {
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.sheet-body {
  display: grid;
  gap: 12px;
  max-height: 570px;
  overflow: auto;
  padding: 16px;
}

.sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

.choice-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 72px;
  padding: 12px;
  text-align: left;
}

.choice-row.selected {
  border-color: var(--blue);
  background: #eef5ff;
}

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

.choice-row small {
  color: var(--muted);
  font-size: 13px;
}

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

.section-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  margin-top: 4px;
  text-transform: uppercase;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 48px;
  padding: 10px 12px;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.full {
  grid-column: 1 / -1;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  font-weight: 800;
  min-height: 22px;
  padding: 2px 8px;
}

.badge.ok {
  background: #dcfce7;
  color: var(--green);
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}

@media (max-width: 1050px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .phone-frame {
    width: min(430px, calc(100vw - 28px));
  }
}
