:root {
  --bg: #f6f1e8;
  --paper: #fffdf8;
  --card: #ffffff;
  --ink: #17231d;
  --muted: #69766f;
  --green: #143d34;
  --green-2: #1f5a4c;
  --green-soft: #e7f0eb;
  --gold: #c9964b;
  --gold-soft: #f5ead8;
  --line: #e4dccf;
  --danger: #b13f37;
  --danger-soft: #f8e4e1;
  --shadow: 0 20px 48px rgba(32, 45, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

.shell {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 14px;
  font-size: 22px;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.hidden {
  display: none !important;
}

.login-card {
  width: min(520px, 100%);
  margin: 8vh auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-note,
.header-help,
.help,
.status,
.muted,
#sectionSubtitle {
  color: var(--muted);
  line-height: 1.65;
}

label {
  display: block;
  margin-top: 14px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  outline-color: var(--green);
}

textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.6;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.primary {
  background: var(--green);
  color: #fff;
}

.primary:hover {
  background: var(--green-2);
}

.secondary {
  border: 2px solid var(--line);
  background: #fff;
  color: var(--green);
}

.danger {
  background: var(--danger);
  color: #fff;
}

.big-login {
  width: 100%;
  margin-top: 24px;
}

.app {
  display: grid;
  gap: 18px;
}

.app-header,
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.header-actions,
.save-actions,
.row-actions,
.button-row,
.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.save-bar {
  position: sticky;
  top: 12px;
  z-index: 20;
}

#sectionTitle {
  display: block;
  margin-bottom: 4px;
  font-size: 20px;
}

#sectionSubtitle {
  margin: 0;
  font-size: 14px;
}

.dirty-badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #8b5c1e;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.status {
  min-height: 30px;
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.75);
  padding: 6px 12px;
}

.main-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 320px;
  gap: 18px;
}

.side-nav,
.work-area,
.preview-area {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.side-nav {
  position: sticky;
  top: 132px;
  align-self: start;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.nav-button {
  justify-content: flex-start;
  width: 100%;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.nav-button.active {
  background: var(--green);
  color: #fff;
}

.nav-button.quiet {
  margin-top: 10px;
  color: var(--muted);
}

.work-area {
  min-height: 680px;
  padding: 20px;
}

.preview-area {
  position: sticky;
  top: 132px;
  align-self: start;
  padding: 18px;
}

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

.big-action-card {
  display: block;
  min-height: 140px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 18px;
  text-align: left;
}

.big-action-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 20px;
}

.big-action-card span {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.6;
}

.big-action-card:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.easy-form {
  display: grid;
  gap: 18px;
}

.easy-section,
.danger-zone,
.phone-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 18px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.health-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf8f2;
  padding: 14px;
}

.health-card strong {
  display: block;
  color: var(--green);
  font-size: 26px;
  line-height: 1;
}

.health-card span {
  display: block;
  margin-top: 8px;
  font-weight: 800;
}

.health-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

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

.map-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf8f2;
  padding: 12px 14px;
}

.map-row strong {
  color: var(--green);
}

.map-row span {
  color: var(--muted);
  line-height: 1.5;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

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

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

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

.item-grid,
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.pick-card,
.asset-card {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.pick-card {
  min-height: 0;
  padding: 0;
  text-align: left;
}

.pick-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.pick-card img,
.asset-card img,
.image-preview {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f2eee6;
}

.pick-body,
.asset-body {
  padding: 12px;
}

.pick-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.small-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.repeat-list {
  display: grid;
  gap: 12px;
}

.repeat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf8f2;
  padding: 12px;
}

.repeat-row.single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.repeat-row.three {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
}

.repeat-row.image {
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
}

.row-actions button,
.small-btn {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
}

.image-tool {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf8f2;
  padding: 14px;
}

.image-tool .image-preview {
  border-radius: 12px;
}

.danger-zone {
  border-color: #e7b8b4;
  background: var(--danger-soft);
}

.target-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid #d9c293;
  border-radius: 10px;
  background: var(--gold-soft);
  color: #6d4513;
  padding: 12px 14px;
}

.target-banner strong {
  color: var(--green);
}

details.advanced-box {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 14px 18px;
}

details.advanced-box summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.json-editor {
  min-height: 520px;
  font-family: Consolas, Monaco, monospace;
  font-size: 15px;
}

.phone-preview {
  padding: 14px;
}

.phone-frame {
  overflow: hidden;
  border: 10px solid #1d1d1d;
  border-radius: 34px;
  background: #f7f4ee;
  min-height: 560px;
}

.phone-top {
  padding: 18px 18px 12px;
  background: #fffdf8;
  text-align: center;
  font-size: 16px;
  font-weight: 900;
}

.phone-body {
  padding: 16px;
}

.phone-hero,
.phone-card-img {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  background: #e9e2d8;
}

.phone-hero {
  height: 150px;
}

.phone-card-img {
  height: 112px;
}

.phone-title {
  margin: 12px 0 4px;
  font-size: 20px;
  font-weight: 900;
}

.phone-subtitle {
  color: var(--muted);
  font-size: 14px;
}

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

.phone-card {
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(32, 45, 38, 0.1);
}

.phone-card-info {
  padding: 10px;
  font-size: 14px;
  font-weight: 900;
}

.phone-spec {
  margin-top: 8px;
  border-radius: 10px;
  background: #f1f4f0;
  padding: 10px;
  font-size: 13px;
}

.empty {
  border: 2px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

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

  .preview-area {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    font-size: 15px;
  }

  .shell {
    padding: 12px;
  }

  .app-header,
  .save-bar,
  .main-grid,
  .hero-actions,
  .form-grid,
  .filter-bar,
  .map-row,
  .repeat-row,
  .repeat-row.single,
  .repeat-row.three,
  .repeat-row.image,
  .image-tool {
    grid-template-columns: 1fr;
  }

  .app-header,
  .save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .side-nav {
    position: static;
  }
}
