/* Account configuration focuses on its selected templates; discovery lives in a dialog. */
html.is-template-configuring { --rail-offset: 0px; }
html.is-template-configuring #rail-reserve { display: none; }
.account-template-config { display: grid; gap: 22px; width: 100%; max-width: none; min-width: 0; }
.account-template-config .publishing-template-panel-header { display: flex; align-items: center; gap: 12px; margin: 0; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.account-template-config .publishing-template-panel-header > .publishing-platform-logo { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; object-fit: cover; }
.account-template-config .publishing-template-identity h2 { margin: 0 0 2px; font-size: 17px; line-height: 1.25; }
.account-template-config .publishing-template-identity small { font-size: 11.5px; color: var(--muted); }
.account-template-header-save { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: 0 0 auto; }
.account-template-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); gap: 22px; align-items: start; min-width: 0; }
.account-template-main-card,
.account-template-side-card { display: grid; gap: 16px; min-width: 0; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-subtle); }
.account-template-side-card { position: sticky; top: 18px; gap: 18px; }
.account-template-side-card > .account-copy-profile-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.account-template-side-card .account-copy-profile-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.account-template-side-card .account-copy-length-custom { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.account-template-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.account-template-heading > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.account-template-header-actions { display: flex; align-items: center; gap: 8px; }
.account-template-header-actions .page-action { min-height: 30px; padding: 4px 11px; font-size: 11.5px; }
.account-template-heading h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.account-template-count { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.account-template-selected-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 204px)); gap: 14px; align-items: stretch; }
.account-template-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); min-width: 0; }
.account-template-cover { display: block; position: relative; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; border-bottom: 1px solid var(--line); background: var(--surface-alt); color: var(--muted); cursor: pointer; }
.account-template-cover img, .account-template-cover video,
.account-template-library-cover img, .account-template-library-cover video,
.account-template-source-preview-media img, .account-template-source-preview-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.account-template-kind { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: var(--pill); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(4px); color: var(--muted); font-size: 10.5px; font-weight: 600; border: 1px solid var(--line-strong); }
.account-template-kind.is-cover { background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--theme-ink); border-color: var(--theme-strong-line); font-weight: 700; }
.publishing-template-thumbnail { position: relative; }
.publishing-template-thumbnail-count { position: absolute; right: 2px; bottom: 2px; padding: 1px 4px; border-radius: 6px; background: rgba(18, 18, 27, 0.78); color: #fff; font-size: 9px; line-height: 1.3; pointer-events: none; }
.account-template-library-cover { position: relative; aspect-ratio: 3 / 4; min-width: 0; overflow: hidden; background: var(--surface-alt); }
.account-template-source-order { position: absolute; right: 8px; top: 8px; padding: 2px 7px; border-radius: var(--pill); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(4px); border: 1px solid var(--theme-strong-line); color: var(--theme-ink); font-size: 10.5px; font-weight: 700; }
.account-template-selected-summary { display: block; color: var(--accent-strong); font-size: 11px; font-weight: 600; }
.account-template-selected-strip { display: flex; flex-wrap: wrap; gap: 6px; max-height: 112px; overflow-y: auto; }
.account-template-card-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; min-width: 0; }
.account-template-card-slot { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 600; color: var(--ink); }
.account-template-card-bar-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.account-template-card-bar-actions .page-action { min-height: 26px; padding: 2px 8px; font-size: 11px; }
.account-template-sample { width: 38px; height: 48px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-alt); cursor: pointer; }
.account-template-sample img, .account-template-sample video { display: block; width: 100%; height: 100%; object-fit: contain; }
.account-template-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 220px; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--accent-strong); font: inherit; font-size: 13.5px; font-weight: 600; text-align: center; cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease; }
.account-template-add.is-empty-single { grid-column: 1 / -1; min-height: 224px; }
.account-template-add small { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.4; }
.account-template-add:hover { border-color: var(--accent); background: var(--accent-wash); }
.account-template-save-status { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; white-space: nowrap; }
.account-template-save-status:empty { display: none; }
.account-template-save-status.is-error { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.account-template-save-status.is-error, .account-template-picker-error { color: var(--danger); }
.account-template-picker-dialog { width: min(1040px, calc(100vw - 48px)); max-width: none; max-height: calc(100dvh - 48px); box-sizing: border-box; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px #0003; }
.account-template-picker-dialog[open] { display: flex; flex-direction: column; }
.account-template-picker-dialog::backdrop, .account-template-media-dialog::backdrop { background: #12121b80; backdrop-filter: blur(4px); }
.account-template-picker-dialog > header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px 10px; }
.account-template-picker-dialog h2 { margin: 0; font-size: 17px; }
.account-template-picker-tabs { display: flex; flex: 0 0 auto; gap: 8px; padding: 0 22px 14px; border-bottom: 1px solid var(--line); }
.account-template-picker-tabs [aria-selected=true], .account-template-category-tabs [aria-pressed=true], .account-template-source-actions [aria-pressed=true] { border-color: var(--accent); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent); }
.account-template-picker-content { flex: 1 1 auto; min-height: 0; padding: 18px 22px; overflow-y: auto; overscroll-behavior: contain; }
.account-template-picker-content > .ui-input { width: 100%; box-sizing: border-box; margin-bottom: 14px; }
.account-template-category-tabs, .account-template-source-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.account-template-category-tabs .page-action, .account-template-source-actions .page-action { padding: 5px 11px; font-size: 12px; }
.account-template-source-actions .page-action:last-of-type { margin-left: auto; }
.account-template-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 14px; padding: 2px; }
.account-template-library-card { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: pointer; }
.account-template-library-card:has(input:checked), .account-template-source-card[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.account-template-library-card > input { position: absolute; right: 10px; top: 10px; z-index: 1; width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.account-template-library-card:has(input:disabled:not(:checked)) { opacity: .55; cursor: default; }
.account-template-library-card > strong { padding: 0 12px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-template-library-card > small { padding: 0 12px; font-size: 10.5px; color: var(--muted); }
.account-template-picker-dialog > footer { display: flex; flex: 0 0 auto; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line); }
.account-template-picker-dialog > footer > span { color: var(--muted); font-size: 12px; }
.account-template-source-layout { display: flex; gap: 18px; align-items: flex-start; }
.account-template-source-grid { display: grid; flex: 1; min-width: 0; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; padding: 2px; }
.account-template-source-card { display: flex; flex-direction: column; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); color: var(--ink); cursor: pointer; }
.account-template-source-card > .account-template-library-cover { width: 100%; }
.account-template-source-card > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; height: 34px; margin: 8px 10px; font-size: 11px; line-height: 17px; text-align: left; }
.account-template-source-preview { position: sticky; top: 0; display: grid; gap: 12px; width: 230px; flex: 0 0 230px; }
.account-template-source-preview-media { width: 100%; aspect-ratio: 3 / 4; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-alt); padding: 0; cursor: zoom-in; }
.account-template-source-preview summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.account-template-source-preview .ui-input { width: 100%; min-width: 0; box-sizing: border-box; margin-top: 8px; }
.account-template-empty { grid-column: 1 / -1; padding: 32px 8px; text-align: center; font-size: 12.5px; color: var(--muted); }
.account-template-media-dialog { padding: 18px; box-sizing: border-box; width: min(800px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); }
.account-template-media-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; font-size: 14px; }
.account-template-media { display: grid; place-items: center; min-height: 180px; }
.account-template-media img, .account-template-media video { display: block; max-width: 100%; max-height: calc(100dvh - 150px); object-fit: contain; }
.account-template-config button:focus-visible, .account-template-picker-dialog button:focus-visible, .account-template-library-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 960px) {
  .account-template-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .account-template-side-card { position: static; }
  .account-template-side-card .account-copy-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .account-template-main-card,
  .account-template-side-card { padding: 16px; border-radius: 14px; }
  .account-template-side-card .account-copy-profile-grid { grid-template-columns: minmax(0, 1fr); }
  .account-template-header-save { width: 100%; justify-content: flex-end; margin-left: 0; }
  .account-template-selected-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .account-template-add { min-height: 180px; padding: 14px; font-size: 13px; }
  .account-template-config .publishing-template-panel-header { gap: 10px; }
  .account-template-picker-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 16px; }
  .account-template-picker-dialog > header, .account-template-picker-content { padding: 16px; }
  .account-template-picker-tabs { padding: 0 16px 14px; }
  .account-template-picker-dialog > footer { padding: 14px 16px; }
  .account-template-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .account-template-source-layout { flex-direction: column-reverse; }
  .account-template-source-grid { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-template-source-preview { position: static; width: 100%; flex-basis: auto; grid-template-columns: 90px minmax(0, 1fr); align-items: start; gap: 12px; }
  .account-template-source-preview-media { grid-row: span 2; }
  .account-template-source-preview > .page-action { grid-column: 2; }
}
@media (max-width: 380px) { .account-template-selected-grid { grid-template-columns: minmax(0, 1fr); } }
