/* S-227 Landing pages list + S-228 editor. Kit tokens and classes only (.panel, .m-*, .tag,
   .notice, .switch, .s-app/.s-desk); load after admin-content.css. Prefix lp-.
   Phones (< 1024px): the editor is four panes (ข้อมูล · HTML · ตรวจ · ตัวอย่าง) switched from a
   bottom tab bar, with the save / publish bar fixed above it (and above the prototype strip). */

/* ---- List ---- */
.lp-table td.title {
  min-width: 240px;
}
.lp-slugline,
.lp-link,
.lp-url {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}
.lp-slugline {
  font-size: 0.78rem;
}

/* ---- Editor layout ---- */
.lp-ed {
  display: grid;
  gap: 22px;
  align-items: start;
}
.lp-main,
.lp-side {
  display: grid;
  gap: 22px;
  align-content: start;
  min-width: 0;
}
.lp-ed .panel {
  min-width: 0;
  margin-bottom: 0;
}
.lp-ed .panel-head h2 {
  margin: 0;
}
#lp-check-h:focus,
#lp-hint:focus {
  outline: none;
}
@media (min-width: 1024px) {
  .lp-ed {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}
/* Wide screens: the HTML and its preview side by side, the preview stays in view. */
@media (min-width: 1600px) {
  .lp-ed {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .lp-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "info info"
      "html preview"
      "check preview";
  }
  #lp-pane-info {
    grid-area: info;
  }
  #lp-pane-html {
    grid-area: html;
  }
  #lp-pane-check {
    grid-area: check;
  }
  #lp-pane-preview {
    position: sticky;
    top: 92px;
    grid-area: preview;
  }
}

/* ---- Phones and tablets: one pane at a time ---- */
.lp-tabbar {
  display: none;
}
@media (max-width: 1023px) {
  .lp-ed {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .lp-main,
  .lp-side {
    display: contents;
  }
  .lp-ed [data-pane] {
    display: none;
  }
  .lp-ed[data-tab="info"] [data-pane="info"],
  .lp-ed[data-tab="html"] [data-pane="html"],
  .lp-ed[data-tab="check"] [data-pane="check"],
  .lp-ed[data-tab="preview"] [data-pane="preview"] {
    display: block;
  }
  /* status first on the ข้อมูล pane */
  .lp-pub {
    order: -1;
  }
  .lp-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .lp-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.74rem;
    cursor: pointer;
  }
  .lp-tab-ic {
    display: grid;
    place-items: center;
    width: 56px;
    height: 30px;
    border-radius: 15px;
  }
  .lp-tab[aria-pressed="true"] {
    color: var(--ink);
    font-weight: 600;
  }
  .lp-tab[aria-pressed="true"] .lp-tab-ic {
    background: var(--soft);
    color: var(--green);
  }
  .lp-tab:focus-visible {
    border-radius: 12px;
    outline: 2px solid var(--blue);
    outline-offset: -4px;
  }
  .lp-tab-dot {
    position: absolute;
    top: 2px;
    left: calc(50% + 8px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: var(--paper);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }
  .lp-tab-dot.is-warn {
    background: var(--gold);
    color: var(--navy);
  }
  /* save / publish bar above the tab bar and the prototype strip */
  .lp-actbar {
    position: fixed;
    right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--proto-h, 0px));
    left: 0;
    z-index: 44;
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .lp-actbar .btn {
    flex: 1;
    min-width: 0;
    padding-inline: 10px;
  }
  .lp-actbar .lp-more {
    flex: none;
    width: 48px;
    height: 44px;
  }
  .app.task .page:has(.lp-ed) {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--proto-h, 0px) + 100px);
  }
  body:has(.app.task .lp-ed) .toasts {
    bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--proto-h, 0px) + 80px);
  }
}

/* ---- Buttons that sit in tight rows ---- */
.lp-mini {
  min-height: 40px;
  padding: 7px 12px;
  font-size: 0.84rem;
}
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---- ข้อมูล ---- */
.lp-group {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.lp-group > legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 0.98rem;
  font-weight: 600;
}
.lp-slug {
  display: flex;
  align-items: stretch;
}
.lp-slug-base {
  display: grid;
  flex: none;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--muted);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: var(--bg);
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.field .lp-slug input {
  flex: 1;
  min-width: 0;
  border-radius: 0 8px 8px 0;
}
.lp-url {
  margin: 0;
}
.lp-url .tag {
  margin-left: 4px;
  font-family: inherit;
}
.lp-serp {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.lp-serp p {
  margin: 0;
  overflow-wrap: anywhere;
}
.lp-serp-url {
  color: var(--muted);
  font-size: 0.8rem;
}
.lp-serp-title {
  color: var(--blue);
  font-size: 1.05rem;
  line-height: 1.4;
}
.lp-serp-desc {
  color: var(--muted);
  font-size: 0.86rem;
}
.lp-og {
  max-width: 320px;
}
.lp-switchrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}
.lp-sw-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.lp-utm-grid {
  display: grid;
  gap: 12px;
}
@media (min-width: 600px) {
  .lp-utm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.lp-copyrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.lp-link {
  flex: 1 1 240px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.8rem;
}

/* ---- HTML ---- */
.lp-count {
  font-variant-numeric: tabular-nums;
}
.lp-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.lp-tools .btn {
  padding: 8px 12px;
  font-size: 0.84rem;
}
.lp-empty {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px dashed var(--green);
  border-radius: 10px;
  background: var(--soft);
}
.lp-empty p {
  margin: 0;
}
.lp-sample-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.lp-sample-row select {
  min-height: 44px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}
/* Line numbers + code. The box has a fixed height (resizable) so the gutter never grows it. */
.lp-code {
  display: flex;
  height: clamp(360px, 62vh, 760px);
  overflow: hidden;
  border: 1px solid var(--muted);
  border-radius: 10px;
  background: var(--paper);
  resize: vertical;
}
.lp-code:focus-within {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.lp-gutter,
#lp-src {
  font: 12.5px/20px ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.lp-gutter {
  flex: none;
  min-width: 3.4em;
  margin: 0;
  padding: 12px 8px 12px 10px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  text-align: right;
  user-select: none;
}
#lp-src {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  white-space: pre;
  overflow: auto;
  resize: none;
  tab-size: 2;
}
#lp-src:focus,
#lp-src:focus-visible {
  outline: none;
}
@media (max-width: 760px) {
  .lp-code {
    height: clamp(320px, 58vh, 600px);
  }
  /* 16px keeps iOS from zooming into the field */
  .lp-gutter,
  #lp-src {
    font-size: 16px;
    line-height: 22px;
  }
}

/* ---- ตรวจ ---- */
.lp-sum {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.lp-cnt {
  display: grid;
  justify-items: center;
  min-height: 64px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.lp-cnt b {
  font-size: 1.4rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.lp-cnt span {
  color: var(--muted);
  font-size: 0.8rem;
}
.lp-cnt[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--soft);
}
.lp-cnt-block b {
  color: var(--danger);
}
.lp-cnt-warn {
  border-top: 3px solid var(--gold);
}
.lp-cnt-info b {
  color: var(--green);
}
.lp-verdict {
  margin: 0 0 14px;
}
.lp-verdict > span {
  flex: 1;
  min-width: 0;
}
.lp-v-block {
  border-color: var(--danger);
}
.lp-v-block svg {
  color: var(--danger);
}
.lp-v-warn {
  border-color: var(--gold);
}
.lp-findings {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lp-f {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.lp-f-block {
  border-left-color: var(--danger);
}
.lp-f-warn {
  border-left-color: var(--gold);
}
.lp-f-info {
  border-left-color: var(--green);
}
.lp-f > .tag {
  margin-top: 2px;
}
.lp-f-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.lp-f-main p {
  margin: 0;
}
.lp-f-msg {
  font-weight: 500;
}
.lp-f-act {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 4px;
}
.lp-f-act .link-btn {
  min-height: 32px;
}
.lp-rules {
  margin-top: 16px;
}
.lp-rules summary,
.lp-prompt-view summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.88rem;
}
.lp-rules ul {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
  padding-left: 1.2em;
}
@media (max-width: 420px) {
  .lp-sum {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lp-f {
    grid-template-columns: minmax(0, 1fr);
  }
  .lp-f > .tag {
    justify-self: start;
  }
}

/* ---- ตัวอย่าง ---- */
.lp-prev-head {
  flex-wrap: wrap;
}
.lp-devices {
  flex: 1 1 300px;
  max-width: 420px;
  margin: 0;
}
.lp-devices button {
  font-size: 0.84rem;
}
.lp-stage {
  display: grid;
  justify-items: center;
  overflow: hidden;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
}
.lp-device {
  width: calc(var(--lp-w, 375px) * var(--lp-s, 1));
  height: calc(var(--lp-h, 740px) * var(--lp-s, 1));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
/* The frame is someone else's page: a plain white canvas, whatever the admin theme. */
.lp-device iframe {
  display: block;
  width: var(--lp-w, 375px);
  height: var(--lp-h, 740px);
  border: 0;
  background: white;
  transform: scale(var(--lp-s, 1));
  transform-origin: 0 0;
}
.lp-stage-empty {
  margin: 0;
  padding: 48px 12px;
  color: var(--muted);
  text-align: center;
}
.lp-prev-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.lp-prev-tools .check {
  font-size: 0.88rem;
}
.lp-formtest {
  padding: 12px 14px;
  border: 1px dashed var(--muted);
  border-radius: 10px;
}
.lp-formtest p {
  margin: 0;
}
.lp-ft-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px !important;
  color: var(--green);
  font-weight: 600;
}
.lp-ft-bad {
  color: var(--danger);
}
.lp-ft-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px 16px;
  margin: 0 0 8px;
}
.lp-ft-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.lp-ft-list dt {
  color: var(--muted);
}
.lp-ft-list dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
  overflow-wrap: anywhere;
}
.lp-sandbox-note {
  margin: 0;
}
.lp-sandbox-note svg {
  vertical-align: -2px;
}

/* ---- Side boxes ---- */
.lp-acts {
  display: grid;
  gap: 8px;
  margin: 14px -24px -24px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.lp-acts .btn {
  width: 100%;
}
.lp-why {
  margin: 0;
}
.lp-pub .pub-rows .tag {
  margin-right: 4px;
}
.lp-pub #lp-hint,
.lp-pub #lp-dirty {
  margin: 0 0 8px;
}
.lp-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.lp-stats > div {
  display: grid;
  justify-items: center;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.lp-stats b {
  font-size: 1.5rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.lp-stats span {
  color: var(--muted);
  font-size: 0.8rem;
}
.lp-box p {
  margin: 0;
}
.lp-mcp {
  background: var(--soft);
}
.lp-mcp-h {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
}
.lp-mcp-h svg {
  margin-top: 2px;
  color: var(--green);
}
.lp-mcp .code-inline,
.notice .code-inline {
  overflow-wrap: anywhere;
}
.lp-prompt-view textarea {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 0.78rem/1.6 ui-monospace, "SFMono-Regular", Consolas, monospace;
  resize: vertical;
}
.lp-prompt select,
.lp-prompt textarea#lp-brief {
  width: 100%;
}
@media (max-width: 760px) {
  .lp-acts {
    margin: 14px -18px -18px;
    padding: 14px 18px;
  }
}
