:root {
  --bg-top: #eef8ff;
  --bg-bottom: #d7ebff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(78, 145, 200, 0.16);
  --line-strong: rgba(78, 145, 200, 0.3);
  --text: #133552;
  --muted: #5d7d98;
  --accent: #3a99de;
  --accent-strong: #1f7bc1;
  --danger: #cb5961;
  --shadow: 0 22px 48px rgba(65, 122, 168, 0.14);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "SF Pro Display", "PingFang SC", "Helvetica Neue", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(1200px 580px at 8% 0%, rgba(113, 192, 238, 0.34), transparent 60%),
    radial-gradient(880px 520px at 92% 18%, rgba(77, 157, 219, 0.16), transparent 60%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.manage-page {
  padding:
    calc(22px + env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
}

.manage-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
}

.manage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(241, 249, 255, 0.82));
  box-shadow: var(--shadow);
}

.header-copy {
  max-width: 44rem;
}

.header-kicker,
.panel-kicker,
.phone-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.manage-header h1,
.panel-head h2,
.login-card h2 {
  margin: 8px 0 0;
  line-height: 1.05;
}

.manage-header h1 {
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: -0.04em;
}

.manage-header p,
.login-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.header-actions,
.panel-tools,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-card,
.editor-panel,
.preview-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 460px);
  margin-left: auto;
  margin-right: auto;
  padding: 24px;
}

.login-form {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

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

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 0;
}

.panel-head h2 {
  font-size: 28px;
}

.editor-list {
  padding: 18px 22px 22px;
  display: grid;
  gap: 14px;
}

.editor-card {
  padding: 18px;
  border: 1px solid rgba(58, 153, 222, 0.12);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: 0 14px 28px rgba(65, 122, 168, 0.08);
}

.editor-card.is-collapsed {
  padding-bottom: 14px;
}

.editor-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-card-body {
  margin-top: 16px;
}

.card-summary {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.item-index {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-strong);
}

.item-title-text {
  min-width: 0;
  flex: 1 1 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.item-type-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.item-type-badge[data-type="wechat"],
.type-badge[data-type="wechat"] {
  color: #1d6fb3;
  background: rgba(84, 169, 235, 0.18);
}

.item-type-badge[data-type="form"],
.type-badge[data-type="form"] {
  color: #8f6b1e;
  background: rgba(236, 221, 184, 0.9);
}

.insert-position {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(58, 153, 222, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.insert-position input {
  width: 68px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(58, 153, 222, 0.18);
  border-radius: 12px;
  background: rgba(248, 252, 255, 0.98);
  color: var(--text);
  text-align: center;
  font-size: 14px;
  outline: none;
}

.insert-position input:focus {
  border-color: rgba(31, 123, 193, 0.42);
  box-shadow: 0 0 0 4px rgba(58, 153, 222, 0.12);
}

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

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(58, 153, 222, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(248, 252, 255, 0.98);
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input {
  min-height: 48px;
  padding: 0 14px;
  font-size: 15px;
}

.field select {
  min-height: 48px;
  padding: 0 14px;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
}

.field textarea {
  resize: vertical;
  min-height: 90px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(31, 123, 193, 0.42);
  box-shadow: 0 0 0 4px rgba(58, 153, 222, 0.12);
}

.type-panel {
  display: grid;
  gap: 0;
}

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

.title-display-value {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(58, 153, 222, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(248, 252, 255, 0.98);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.parse-preview {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px dashed rgba(58, 153, 222, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(243, 250, 255, 0.88);
}

.parse-preview-kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.parse-preview-line {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-all;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(58, 153, 222, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(248, 252, 255, 0.98);
  font-size: 15px;
  color: var(--text);
}

.switch input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.ghost-btn,
.primary-btn,
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.ghost-btn,
.primary-btn {
  min-height: 46px;
  padding: 0 16px;
  font-size: 14px;
}

.mini-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.ghost-btn,
.mini-btn {
  color: var(--text);
  background: rgba(58, 153, 222, 0.08);
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6dc5f4);
  box-shadow: 0 14px 26px rgba(58, 153, 222, 0.22);
}

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

.full-width {
  width: 100%;
}

.save-state {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(58, 153, 222, 0.08);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  color: #bf4a50;
  font-size: 13px;
}

.preview-panel {
  padding-bottom: 22px;
}

.site-footer {
  display: flex;
  justify-content: center;
  margin-top: 22px;
  padding: 8px 0 4px;
}

.site-footer-link {
  color: rgba(19, 53, 82, 0.6);
  font-size: 12px;
  line-height: 1.6;
  text-decoration: none;
}

.phone-frame {
  width: min(100% - 44px, 380px);
  margin: 18px auto 0;
  padding: 18px;
  border: 1px solid rgba(58, 153, 222, 0.14);
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(244, 251, 255, 0.98), rgba(231, 245, 255, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.phone-hero {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 28px rgba(65, 122, 168, 0.08);
}

.phone-title {
  margin-top: 8px;
  font-size: 30px;
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 700;
}

.phone-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.phone-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.phone-card {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(65, 122, 168, 0.08);
}

.phone-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.phone-card-title {
  font-size: 18px;
  font-weight: 700;
}

.phone-card-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.phone-empty {
  margin-top: 16px;
  padding: 18px;
  border: 1px dashed rgba(58, 153, 222, 0.24);
  border-radius: 20px;
  text-align: center;
  color: var(--muted);
}

.manage-modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(11, 35, 57, 0.28);
  backdrop-filter: blur(10px);
}

.manage-modal-card {
  width: min(100%, 420px);
  padding: 22px;
  border: 1px solid rgba(84, 169, 235, 0.22);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 56px rgba(29, 86, 129, 0.2);
}

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

.modal-kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.modal-head h2 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.modal-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: rgba(84, 169, 235, 0.08);
  color: var(--text);
  font-size: 26px;
  cursor: pointer;
}

.modal-form {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

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

@media (min-width: 920px) {
  .workspace {
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
    align-items: start;
  }

  .preview-panel {
    position: sticky;
    top: 20px;
  }

  .field-grid {
    grid-template-columns: minmax(0, 1fr) 180px;
    align-items: end;
  }
}

@media (max-width: 700px) {
  .manage-header,
  .panel-head,
  .editor-card-head {
    flex-direction: column;
  }

  .panel-head {
    align-items: stretch;
  }

  .panel-tools {
    justify-content: space-between;
  }

  .card-summary,
  .card-actions {
    width: 100%;
  }

  .phone-frame {
    width: calc(100% - 32px);
  }
}
