/* Styles used only by template-editor.html. Shared tokens and header primitives come from styles.css. */
.template-editor-page { background: #f8f7fb; }
.template-editor-shell { width: min(100% - 36px, 1480px); margin: 0 auto; padding: 32px 0 64px; }
.template-editor-heading { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.template-editor-heading h1 { margin: 0; font-size: clamp(28px, 3.3vw, 40px); line-height: 1.15; letter-spacing: -.035em; }
.template-editor-heading p { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.template-editor-heading code, .template-preview-heading code { color: var(--primary-dark); font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.template-kind-switch { width: fit-content; margin-bottom: 14px; padding: 3px; display: flex; gap: 2px; background: #eeebf4; border-radius: 9px; }
.template-kind-switch button { min-height: 30px; padding: 0 13px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 750; }
.template-kind-switch button:hover { color: var(--primary); }
.template-kind-switch button[aria-pressed="true"] { color: var(--primary-dark); background: #fff; box-shadow: 0 2px 8px rgba(51,43,120,.1); }
.template-state-line { margin-top: 10px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.template-state-line i { width: 3px; height: 3px; background: #a49eaa; border-radius: 50%; }
.template-state-line .is-dirty { color: #a25c16; }
.template-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.template-button { min-height: 38px; padding: 0 14px; color: #4c4651; background: #fff; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 700; transition: color .16s ease, border-color .16s ease, background-color .16s ease, transform .08s ease; }
.template-button:hover { color: var(--primary); border-color: #a59cda; background: #faf9ff; }
.template-button:active { transform: scale(.98); }
.template-button.is-primary { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 7px 18px rgba(79,70,165,.18); }
.template-button.is-primary:hover { background: var(--primary-dark); }
.template-editor-workspace { min-height: 730px; display: grid; grid-template-columns: 264px minmax(0, 1fr); align-items: stretch; overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: 15px; box-shadow: 0 14px 42px rgba(51,43,120,.06); }
.template-section-nav { min-width: 0; padding: 18px 14px; background: #fbfafd; border-right: 1px solid var(--border); }
.template-search input { min-height: 40px; padding-left: 13px; background: #fff; }
.template-nav-group { padding: 16px 0 12px; }
.template-nav-group + .template-nav-group { border-top: 1px solid #ebe7ef; }
.template-nav-group h2 { margin: 0 8px 7px; color: #3b3640; font-size: 12px; letter-spacing: .03em; }
.template-nav-item { width: 100%; min-height: 36px; padding: 7px 10px; display: block; color: var(--muted); background: transparent; border: 0; border-radius: 7px; cursor: pointer; font-size: 12px; line-height: 1.45; text-align: left; overflow-wrap: anywhere; }
.template-nav-item:hover { color: var(--primary); background: #f2f0fb; }
.template-nav-item.is-active { color: var(--primary); background: var(--primary-soft); font-weight: 750; box-shadow: inset 3px 0 var(--primary); }
.template-editing-surface { min-width: 0; padding: 24px; }
.template-section-heading { margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.template-section-heading h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.template-section-heading p { max-width: 760px; margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.template-section-heading > span { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.template-code-label { display: block; margin-bottom: 7px; color: #3e3943; font-size: 12px; font-weight: 750; }
.template-code-editor { min-height: 330px; padding: 17px 18px; color: #29252e; background: #fdfdfe; border-radius: 9px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.65; tab-size: 2; white-space: pre; }
.template-code-editor.is-variable-located { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.template-variable-row { padding: 15px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px 14px; }
.template-variable-row > strong { padding-top: 7px; font-size: 12px; }
.template-variable-row > small { grid-column: 2; margin-top: -3px; color: var(--muted); font-size: 10px; }
.template-variable-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.template-variable-button { min-height: 33px; padding: 5px 9px; display: inline-flex; align-items: center; gap: 7px; color: #4d4751; background: #fff; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; }
.template-variable-button:hover { color: var(--primary); border-color: #a59cda; }
.template-variable-button code { color: var(--primary); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }
.template-variable-button span { color: var(--muted); font-size: 10px; }
.template-validation { min-height: 58px; padding: 10px 12px; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; color: var(--success); background: #f3fbf7; border: 1px solid #cce9dc; border-radius: 9px; }
.template-validation.is-error { color: var(--error); background: var(--error-soft); border-color: #efc1ba; }
.template-validation-icon { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 13px; font-weight: 800; }
.template-validation strong { display: block; font-size: 12px; }
.template-validation p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.template-validation .template-button { min-height: 34px; }
.template-preview { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--border); }
.template-preview-heading { margin-bottom: 9px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.template-preview-heading h2 { margin: 0; font-size: 14px; }
.template-preview-heading p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.template-preview pre { max-height: 310px; margin: 0; padding: 16px 18px; overflow: auto; color: #3e3943; background: #f8f7fa; border: 1px solid var(--border); border-radius: 9px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 11px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.template-toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(420px, calc(100vw - 44px)); margin: 0; padding: 11px 15px; color: #fff; background: #2f7259; border-radius: 9px; box-shadow: 0 10px 30px rgba(28,34,31,.2); font-size: 12px; }
.template-toast.is-error { background: #9f3e36; }

@media (max-width: 900px) {
  .template-editor-heading { align-items: flex-start; flex-direction: column; }
  .template-toolbar { justify-content: flex-start; }
  .template-editor-workspace { grid-template-columns: 1fr; }
  .template-section-nav { border-right: 0; border-bottom: 1px solid var(--border); }
  .template-section-nav nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
}

@media (max-width: 600px) {
  .template-editor-shell { width: min(100% - 20px, 1480px); padding-top: 22px; }
  .template-toolbar { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-button { padding: 0 10px; }
  .template-section-nav { padding-bottom: 12px; }
  .template-section-nav nav { height: 224px; margin-top: 8px; display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-inline: contain; scroll-snap-type: x proximity; }
  .template-nav-group { min-width: 210px; height: 216px; padding: 10px 0 8px; flex: 0 0 210px; overflow-y: auto; border-top: 0 !important; scroll-snap-align: start; }
  .template-nav-group h2 { position: sticky; left: 0; }
  .template-editing-surface { padding: 18px 14px; }
  .template-section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .template-code-editor { min-height: 290px; font-size: 12px; }
  .template-variable-row { grid-template-columns: 1fr; }
  .template-variable-row > small { grid-column: 1; }
  .template-validation { grid-template-columns: 28px minmax(0, 1fr); }
  .template-validation .template-button { grid-column: 1 / -1; }
}
