:root {
  --ink: #20232a;
  --muted: #6f7580;
  --subtle: #9aa0aa;
  --line: #e3e6ea;
  --surface: #ffffff;
  --canvas: #f3f5f6;
  --accent: #d94356;
  --accent-strong: #bd3043;
  --accent-soft: #fff0f2;
  --green: #16885b;
  --green-soft: #edf9f3;
  --yellow: #a56a05;
  --yellow-soft: #fff7df;
  --focus: rgba(217, 67, 86, 0.22);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(32, 35, 42, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(32, 35, 42, 0.035) 1px, transparent 1px),
    var(--canvas);
  background-size: 28px 28px;
}

.login-panel {
  width: min(100%, 390px);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(23, 28, 38, 0.10);
}

.login-logo {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--line);
}

.login-heading { margin: 22px 0 28px; }
.login-heading h1 { margin: 4px 0 0; font-size: 24px; font-weight: 700; }
.product-mark, .eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto minmax(280px, 1fr);
  align-items: center;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line); }
.brand span { font-weight: 800; }
.brand strong { padding-left: 10px; border-left: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; }

.topnav { align-self: stretch; display: flex; gap: 4px; }
.nav-button {
  min-width: 84px;
  padding: 0 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.nav-button:hover { color: var(--ink); }
.nav-button.active { color: var(--accent); border-bottom-color: var(--accent); }

.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.save-state { color: var(--green); font-size: 12px; min-width: 70px; text-align: right; }

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button.secondary { background: #fff; border-color: #cfd3d8; }
.button.secondary:hover { border-color: var(--ink); }
.button.ghost { color: var(--muted); border-color: var(--line); }
.button.full { width: 100%; }

.workspace {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 278px minmax(500px, 1fr) 430px;
  max-width: 1680px;
  margin: 0 auto;
}

.notice-sidebar {
  min-width: 0;
  padding: 24px 18px;
  background: #eef0f2;
  border-right: 1px solid var(--line);
}

.sidebar-heading, .editor-heading, .preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.sidebar-heading { margin-bottom: 18px; }
.sidebar-heading h2 { margin: 3px 0 0; font-size: 18px; }

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #cfd3d8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}
.icon-button:hover { color: var(--accent); border-color: var(--accent); }

.notice-list { display: grid; gap: 8px; }
.notice-list-empty { color: var(--muted); padding: 28px 4px; line-height: 1.7; }
.notice-item {
  width: 100%;
  display: block;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  text-align: left;
}
.notice-item:hover { background: #fff; border-color: #d8dce1; }
.notice-item.active { background: #fff; border-color: var(--accent); box-shadow: 0 5px 18px rgba(32, 35, 42, 0.06); }
.notice-item strong, .notice-item span { display: block; }
.notice-item strong { font-size: 14px; }
.notice-item span { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.notice-item small { display: block; margin-top: 8px; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.editor-pane {
  min-width: 0;
  padding: 26px clamp(24px, 3vw, 48px) 64px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.editor-heading { min-height: 50px; margin-bottom: 18px; }
.editor-heading h1 { margin: 3px 0 0; font-size: 22px; }
.editor-actions { display: flex; align-items: center; gap: 9px; }

.share-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid #b9e1cf;
  border-radius: 6px;
  background: var(--green-soft);
}
.share-result span { display: block; margin-bottom: 3px; color: var(--green); font-size: 11px; font-weight: 700; }
.share-result a { display: block; max-width: min(46vw, 520px); color: #0f6644; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.form-section { padding: 26px 0 28px; border-top: 1px solid var(--line); }
.section-heading { display: grid; grid-template-columns: 34px 1fr; gap: 10px; margin-bottom: 20px; }
.section-index { color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; font-weight: 800; }
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field > span, .field legend, .field-label { color: #4c515b; font-size: 12px; font-weight: 700; }
.field-label { display: block; margin: 0 0 7px; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.text-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cfd3d8;
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
textarea.text-input { resize: vertical; line-height: 1.55; }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.text-input[aria-invalid="true"] { border-color: var(--accent); }

.vehicle-field { margin: 0; padding: 0; border: 0; }
.vehicle-field legend { margin-bottom: 8px; }
.segmented-control { display: grid; grid-template-columns: repeat(2, 1fr); padding: 3px; border: 1px solid #cfd3d8; border-radius: 7px; background: #f3f4f5; }
.segmented-control.three-options { grid-template-columns: repeat(3, 1fr); }
.segmented-control label { cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; padding: 9px 12px; border-radius: 5px; color: var(--muted); text-align: center; font-weight: 700; }
.segmented-control input:checked + span { background: #fff; color: var(--accent); box-shadow: 0 1px 5px rgba(32, 35, 42, 0.12); }
.segmented-control input:focus-visible + span { outline: 3px solid var(--focus); }
.coach-tier-field { margin-top: 17px; }

.coach-fields { display: grid; grid-template-columns: 104px 1fr; gap: 18px; align-items: start; }
.avatar-field { cursor: pointer; text-align: center; color: var(--accent); font-size: 12px; font-weight: 700; }
.avatar-field img { width: 92px; height: 92px; display: block; margin-bottom: 8px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.avatar-field input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.coach-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.coach-inputs .field:last-child { grid-column: 1 / -1; }

.form-error { min-height: 20px; margin: 10px 0; color: var(--accent-strong); font-size: 12px; }

.preview-pane { min-width: 0; padding: 24px; background: #e9ecef; }
.preview-heading { margin-bottom: 14px; color: #4c515b; font-size: 12px; font-weight: 800; }
.preview-heading strong { padding: 3px 7px; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 10px; }
.phone-frame {
  width: min(100%, 390px);
  height: calc(100vh - 126px);
  min-height: 620px;
  margin: 0 auto;
  overflow: hidden;
  border: 8px solid #282c34;
  border-top-width: 24px;
  border-bottom-width: 24px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 22px 50px rgba(32, 35, 42, 0.20);
}
.phone-frame iframe { width: 100%; height: 100%; border: 0; background: #f7f8fc; }

.settings-view { min-height: calc(100vh - 64px); padding: 58px 24px; }
.settings-panel { width: min(100%, 680px); margin: 0 auto; padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.settings-panel h1 { margin: 4px 0 30px; font-size: 26px; }
.domain-example { margin: 5px 0 24px; padding: 14px; border-left: 3px solid var(--yellow); background: var(--yellow-soft); }
.domain-example span { display: block; margin-bottom: 6px; color: var(--yellow); font-size: 11px; font-weight: 800; }
.domain-example code { overflow-wrap: anywhere; color: #6f4a0c; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 30px rgba(32, 35, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1220px) {
  .workspace { grid-template-columns: 250px minmax(480px, 1fr); }
  .preview-pane { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .phone-frame { height: 760px; }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; height: auto; min-height: 60px; padding: 10px 14px; }
  .brand strong, .save-state { display: none; }
  .topnav { grid-column: 1 / -1; grid-row: 2; height: 42px; justify-content: center; order: 3; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .workspace { display: block; }
  .notice-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .notice-list { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .notice-item { min-width: 220px; }
  .editor-pane { padding: 22px 18px 52px; border-right: 0; }
  .editor-heading { align-items: flex-start; }
  .editor-actions { flex-direction: column-reverse; align-items: stretch; }
  .share-result { align-items: flex-start; }
  .share-result a { max-width: 55vw; }
  .preview-pane { padding: 20px 12px; }
}

@media (max-width: 560px) {
  .brand span { font-size: 13px; }
  .field-grid.two-columns, .coach-inputs { grid-template-columns: 1fr; }
  .coach-inputs .field:last-child { grid-column: auto; }
  .coach-fields { grid-template-columns: 78px 1fr; gap: 12px; }
  .avatar-field img { width: 72px; height: 72px; }
  .editor-heading { display: block; }
  .editor-actions { margin-top: 14px; }
  .editor-actions .button { width: 100%; }
  .share-result { display: block; }
  .share-result a { max-width: 100%; margin-bottom: 10px; }
  .segmented-control { grid-template-columns: 1fr; }
  .settings-view { padding: 24px 14px; }
  .settings-panel { padding: 22px 18px; }
}
