/* Each list's email template (src/templates.js; views/template.ejs, partials/part/templates.ejs). Classes tpl-.
 * The shared components (chip, ov-esp, ov-lists, ov-probs, btn, the email frame) come from app.css and plan.css
 * and are never redefined here. */

/* ════ The template page ════ */

.tpl-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; }
.tpl-head h1 { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.tpl-head .chip + .chip { margin-left: 0; }
.tpl-size { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tpl-size b { font-weight: 600; color: var(--ink-2); }
.tpl-size.is-over, .tpl-size.is-over b { color: var(--warn); }
.tpl-viewing { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; }
.tpl-viewing form { margin: 0; }
.tpl-problem { margin-top: 12px; }

/* The editor on the left, the email on the right. */
.tpl-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 600px); gap: 36px; margin-top: 22px; align-items: start; }
.tpl-col { min-width: 0; }
.tpl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 28px; margin-bottom: 8px; }
.tpl-bar h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tpl-bar .btn.quiet { margin-left: auto; }
.tpl-dirty { font-size: 12px; font-weight: 600; color: var(--warn); }
.tpl-status { font-size: 12px; font-weight: 550; color: var(--ink-2); }
.tpl-status:empty { display: none; }
.tpl-status.is-warn { color: var(--warn); }
.tpl-same { font-size: 12px; font-weight: 550; color: var(--ink-3); white-space: nowrap; }

/* The HTML: a plain text box in a fixed-width face. Long lines wrap anywhere: today's templates are one line each. */
.tpl-code {
  display: block; min-height: 440px; padding: 12px 14px; border-radius: 10px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all;
  background: var(--bg-2); color: var(--ink);
}
.tpl-save { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; margin-top: 10px; }
.tpl-save input { min-height: 32px; padding: 6px 10px; font-size: 13px; }

/* The seven places and the service's own pieces, each with how many places it fills. */
.tpl-parts { margin-top: 24px; }
.tpl-parts h2, .tpl-hist h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.tpl-part { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 10px; min-height: 30px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.tpl-part b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tpl-part.is-missing, .tpl-part.is-missing b { color: var(--warn); }
.tpl-part.is-auto b { font-weight: 500; color: var(--ink-3); }
/* A part at 0: its code on a line of its own under it, selected whole by a click, to be typed back in. */
.tpl-hint { display: none; order: 3; flex-basis: 100%; padding: 0 0 7px; font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--warn); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; cursor: text; }
.tpl-part.is-missing .tpl-hint { display: block; }

/* Every version: when, who, the note, View and Restore. Beside the email the column is at most about 480px wide,
 * so a version takes two lines there (when and who, then the note) and the note is never cut to a letter; one
 * line when the page stacks (wider than the column, 641 to 1080px). */
.tpl-hist { margin-top: 24px; }
.tpl-hist li { display: grid; grid-template-columns: 34px auto minmax(0, 1fr) auto; grid-template-areas: "v when who acts" "v note note acts"; align-items: center; column-gap: 12px; padding: 6px 0; min-height: 34px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.tpl-hist li > b { grid-area: v; }
.tpl-hist .tpl-when { grid-area: when; }
.tpl-hist .tpl-who { grid-area: who; }
.tpl-hist .tpl-note { grid-area: note; }
.tpl-hist .tpl-acts { grid-area: acts; }
.tpl-hist .tpl-note:empty { display: none; }
.tpl-hist li b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tpl-hist li.is-shown { margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; background: var(--wash); }
.tpl-hist li.is-shown + li { border-top-color: transparent; }
.tpl-hist li.is-shown b { color: var(--accent); }
.tpl-when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tpl-who, .tpl-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-note { color: var(--ink-3); }
.tpl-acts { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.tpl-acts form { margin: 0; }
.tpl-cur { font-size: 12px; font-weight: 600; color: var(--ok); }

.tpl-prev { position: sticky; top: 76px; min-width: 0; }

/* ════ The Templates part of the site's page ════ */

.tpl-rows { padding: 2px 0 6px; }
.tpl-row { display: grid; grid-template-columns: 92px 88px minmax(0, 1fr) auto; align-items: center; column-gap: 14px; min-height: 40px; border-top: 1px solid var(--line); font-size: 13px; }
.tpl-row:first-child { border-top: 0; }
.tpl-row .ov-esp { justify-self: start; }
.tpl-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tpl-q { font-weight: 500; color: var(--ink-3); }
.tpl-warn { font-weight: 600; color: var(--warn); }
.tpl-old { display: flex; flex-wrap: wrap; gap: 4px 16px; min-width: 0; }

/* A send time's page: its email on an older version of the template, above the email. */
.pln-prev .pln-tpl { margin: 0 0 10px; }
.pln-tpl a:hover { text-decoration: underline; }

/* The Schedule's list head: the template, at the end of the line. */
.one-lh-tpl { margin-left: auto; font-weight: 550; color: var(--ink-2); }
.one-lh-tpl:hover { color: var(--accent); }
.one-lh-tpl.is-need { color: var(--warn); font-weight: 600; }

/* ── Narrower: the editor, its parts, the email, then the history. ── */
@media (max-width: 1080px) {
  .tpl-split { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tpl-col { display: contents; }
  .tpl-edit { order: 1; }
  .tpl-parts { order: 2; }
  .tpl-prev { order: 3; position: static; margin-top: 24px; scroll-margin-top: 76px; }
  .tpl-hist { order: 4; }
}
@media (min-width: 641px) and (max-width: 1080px) {
  .tpl-hist li { grid-template-columns: 40px 118px 84px minmax(0, 1fr) auto; grid-template-areas: "v when who note acts"; padding: 0; }
}
@media (max-width: 640px) {
  .tpl-code { min-height: 320px; font-size: 11.5px; }
  .tpl-save { display: flex; flex-wrap: wrap; justify-content: flex-end; }
  .tpl-save input { flex: 1 1 100%; }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
  .tpl-hist li { grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "v when acts" "v note acts"; row-gap: 0; padding: 6px 0; }
  .tpl-hist .tpl-who { display: none; }
  .tpl-prev .email { height: 640px; }
  .tpl-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .tpl-row .tpl-old { grid-column: 1 / -1; grid-row: 2; padding-bottom: 8px; }
  .tpl-row .tpl-old:empty { display: none; }
}

/* The "Code" field beside Save while a code is needed (partials/code.ejs): the note takes its own line, and Preview,
   the field and Save go under it, to the right (four in one row squeezed the note to nothing). */
.tpl-save:has(.code-field) { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.tpl-save:has(.code-field) > input { flex: 1 1 100%; }
.tpl-save .code-field input { flex: 0 0 auto; }
.tpl-viewing form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* What a template is for: one calm line under the title (views/template.ejs). */
.tpl-what { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.tpl-what .tpl-site { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.tpl-ads { font-variant-numeric: tabular-nums; color: var(--ink); }
.tpl-ads.is-grey { color: var(--ink-3); }
