.page-shell {
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  height: 100vh;
  position: relative;
}

.topbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid #333;
  background: #121212;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 23px;
  min-width: 0;
}

.topbar-logo {
  color: #f0f3f7;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-mode-btn {
  padding: 8px 12px;
  color: #d9e5f6;
  height: 42px;
  border-radius: 0;
}

.topbar-mode-btn:hover,
.topbar-mode-btn:focus-visible,
.topbar-mode-btn.is-active {
  background: #223348;
  color: #eef5ff;
}

.topbar-mode-btn.is-active {
  border-color: #3b5576;
}

.topbar-logo img {
  width: 19px;
  height: 19px;
  display: block;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  border: 1px solid #2f3b4c;
  border-radius: 10px;
  background: #182433;
  overflow: hidden;
}

.mobile-workspace-tabs {
  display: none;
}

.mobile-workspace-tab {
  min-width: 0;
}

.app-panels {
  display: grid;
  grid-template-columns: minmax(280px, var(--panel-source-width, 42fr)) minmax(280px, var(--panel-preview-width, 42fr)) minmax(240px, var(--panel-history-width, 16fr));
  min-height: 0;
}

.app.has-panel-resizers .app-panels,
html.app-booting.ui-panel-resizers #appRoot .app-panels {
  display: grid;
  grid-template-columns:
    minmax(280px, var(--panel-source-width, 42fr))
    var(--panel-resizer-width, 12px)
    minmax(280px, var(--panel-preview-width, 42fr))
    var(--panel-resizer-width, 12px)
    minmax(240px, var(--panel-history-width, 16fr));
}

.app.is-history-collapsed .app-panels {
  grid-template-columns: minmax(280px, var(--panel-source-width, 50fr)) minmax(280px, var(--panel-preview-width, 50fr));
}

.app.has-panel-resizers.is-history-collapsed .app-panels,
html.app-booting.ui-panel-resizers.ui-history-collapsed #appRoot .app-panels {
  grid-template-columns:
    minmax(280px, var(--panel-source-width, 50fr))
    var(--panel-resizer-width, 12px)
    minmax(280px, var(--panel-preview-width, 50fr));
}

.app.is-preview-collapsed .app-panels {
  grid-template-columns: minmax(280px, var(--panel-source-width, 70fr)) minmax(240px, var(--panel-history-width, 30fr));
}

.app.has-panel-resizers.is-preview-collapsed .app-panels,
html.app-booting.ui-panel-resizers.ui-preview-collapsed #appRoot .app-panels {
  grid-template-columns:
    minmax(280px, var(--panel-source-width, 70fr))
    var(--panel-resizer-width, 12px)
    minmax(240px, var(--panel-history-width, 30fr));
}

.app.is-preview-collapsed.is-history-collapsed .app-panels {
  grid-template-columns: minmax(280px, 1fr);
}

html.app-booting.ui-history-collapsed #appRoot .app-panels {
  grid-template-columns: minmax(280px, var(--panel-source-width, 50fr)) minmax(280px, var(--panel-preview-width, 50fr));
}

html.app-booting.ui-history-collapsed #appRoot.has-panel-resizers .app-panels,
html.app-booting.ui-panel-resizers.ui-history-collapsed #appRoot.has-panel-resizers .app-panels {
  grid-template-columns:
    minmax(280px, var(--panel-source-width, 50fr))
    var(--panel-resizer-width, 12px)
    minmax(280px, var(--panel-preview-width, 50fr));
}

html.app-booting.ui-preview-collapsed #appRoot .app-panels {
  grid-template-columns: minmax(280px, var(--panel-source-width, 70fr)) minmax(240px, var(--panel-history-width, 30fr));
}

html.app-booting.ui-preview-collapsed #appRoot.has-panel-resizers .app-panels,
html.app-booting.ui-panel-resizers.ui-preview-collapsed #appRoot.has-panel-resizers .app-panels {
  grid-template-columns:
    minmax(280px, var(--panel-source-width, 70fr))
    var(--panel-resizer-width, 12px)
    minmax(240px, var(--panel-history-width, 30fr));
}

html.app-booting.ui-preview-collapsed.ui-history-collapsed #appRoot .app-panels {
  grid-template-columns: minmax(280px, 1fr);
}

.panel-resizer {
  position: relative;
  z-index: 5;
  display: block;
  min-width: var(--panel-resizer-width, 12px);
  min-height: 0;
  border: 0;
  background: #151515;
  cursor: col-resize;
  touch-action: none;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  top: 49px;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: #333;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 48px;
  border-bottom: 1px solid #333;
  background:
    linear-gradient(to right, transparent 0, transparent 50%, #333 50%, #333 calc(50% + 1px), transparent calc(50% + 1px), transparent 100%),
    #1d1d1d;
}

.panel-resizer:hover,
.panel-resizer:focus-visible,
.app.is-panel-resizing .panel-resizer.is-active {
  background: #151515;
  outline: none;
}

.panel-resizer:hover::before,
.panel-resizer:focus-visible::before,
.app.is-panel-resizing .panel-resizer.is-active::before {
  background: #536273;
}

.app.has-panel-resizers .preview-panel,
.app.has-panel-resizers .history-panel,
html.app-booting.ui-panel-resizers #appRoot .preview-panel,
html.app-booting.ui-panel-resizers #appRoot .history-panel {
  border-left: 0;
}

.app.is-preview-collapsed.is-history-collapsed .panel-resizer,
.app.is-history-collapsed .panel-resizer-preview,
.app.is-preview-collapsed .panel-resizer-preview,
html.app-booting.ui-preview-collapsed.ui-history-collapsed #appRoot .panel-resizer,
html.app-booting.ui-history-collapsed #appRoot .panel-resizer-preview,
html.app-booting.ui-preview-collapsed #appRoot .panel-resizer-preview,
html.app-booting.ui-panel-resizers-disabled #appRoot .panel-resizer {
  display: none;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-header {
  height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: #1d1d1d;
  border-bottom: 1px solid #333;
  font-size: 14px;
  font-weight: bold;
}

.panel-title {
  white-space: nowrap;
}

.buttons,
.action-row,
.template-actions,
.chain-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.code-toolbar {
  position: relative;
  align-items: center;
  min-width: 0;
}

.code-settings-toggle {
  display: none;
}

.code-settings-toggle .button-label {
  white-space: nowrap;
}

.code-settings-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.code-settings-menu .toggle-switch {
  flex-shrink: 0;
}

.code-settings-menu .code-font-actions {
  flex-shrink: 0;
}

.template-actions {
  justify-content: flex-start;
}

.template-actions-toolbar {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.template-actions-group-meta {
  margin-left: auto;
  justify-content: flex-end;
}

@media (max-width: 599px) {
  #exportUserTemplatesBtn,
  #importUserTemplatesBtn {
    min-width: 42px;
    padding-right: 10px;
    padding-left: 10px;
  }

  #exportUserTemplatesBtn .button-label span,
  #importUserTemplatesBtn .button-label span {
    display: none;
  }
}

.app.is-code-toolbar-compact .code-settings-toggle,
html.app-booting.ui-code-toolbar-compact #appRoot .code-settings-toggle {
  display: inline-flex;
  flex-shrink: 0;
  min-height: 32px;
}

.app.is-code-toolbar-compact .code-settings-menu,
html.app-booting.ui-code-toolbar-compact #appRoot .code-settings-menu {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 12;
  min-width: 250px;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 10px;
  background: #191919;
  border: 1px solid #333;
  border-radius: 10px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.34);
}

.app.is-code-toolbar-compact .code-toolbar.is-settings-open .code-settings-menu,
html.app-booting.ui-code-toolbar-compact #appRoot .code-toolbar.is-settings-open .code-settings-menu {
  display: grid;
}

.app.is-code-toolbar-compact .code-settings-menu .toggle-switch,
html.app-booting.ui-code-toolbar-compact #appRoot .code-settings-menu .toggle-switch {
  width: 100%;
}

.app.is-code-toolbar-compact .code-settings-menu .code-font-actions,
html.app-booting.ui-code-toolbar-compact #appRoot .code-settings-menu .code-font-actions {
  justify-content: flex-start;
}

.app.is-code-toolbar-compact .code-settings-menu #formatHtmlBtn,
html.app-booting.ui-code-toolbar-compact #appRoot .code-settings-menu #formatHtmlBtn {
  width: 100%;
  justify-content: flex-start;
}

.preview-panel {
  border-left: 1px solid #333;
}

.preview-panel:fullscreen,
.preview-panel:-webkit-full-screen,
.preview-panel.is-preview-fullscreen {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  background: #151515;
}

.preview-panel.is-preview-fullscreen {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 120;
}

.preview-panel:fullscreen #previewFrame,
.preview-panel:-webkit-full-screen #previewFrame,
.preview-panel.is-preview-fullscreen #previewFrame {
  flex: 1 1 auto;
  min-height: 0;
}

.app.is-preview-collapsed .preview-panel {
  display: none;
}

html.app-booting.ui-preview-collapsed #appRoot .preview-panel {
  display: none;
}

html.app-booting.ui-profile-no-preview #appRoot .preview-panel,
html.app-booting.ui-profile-no-preview #togglePreviewPanelBtn {
  display: none !important;
}

html.app-booting.ui-profile-no-delete-blocks #appRoot #deleteBlockBtn,
html.ui-profile-no-delete-blocks #appRoot #deleteBlockBtn {
  display: none !important;
}

.history-panel {
  border-left: 1px solid #333;
}

.app.is-history-collapsed .history-panel {
  display: none;
}

html.app-booting.ui-history-collapsed #appRoot .history-panel {
  display: none;
}

.cleanup-tools {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  background: #191919;
  border-top: 1px solid #2f2f2f;
}

html.app-booting.ui-profile-no-tools #appRoot .utility-strip,
html.app-booting.ui-profile-no-tools #appRoot .cleanup-tools {
  display: none !important;
}

.utility-strip {
  padding: 10px 14px;
  border-top: 1px solid #333;
  background: #151515;
}

.utility-strip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.utility-strip-btn {
  min-height: 34px;
}

.utility-strip-btn .button-label {
  align-items: normal;
}

.utility-strip-btn .ph-plus {
  font-size: 22px;
}

.quick-template-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  align-items: center;
}

button.soft.quick-template-btn {
  min-height: 34px;
  padding: 0 10px;
  border-color: #343434;
  background: #252525;
  color: #d7deea;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

button.soft.quick-template-btn:hover,
button.soft.quick-template-btn:focus-visible {
  background: #313131;
  color: #eef4ff;
}

.tool-card {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: #191919;
  max-width: 960px;
}

.tool-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #eee;
  font-size: 14px;
  font-weight: bold;
}

.tool-subtitle,
.chain-step-details,
.hint-text {
  color: #999;
  font-size: 12px;
  line-height: 1.45;
}

.template-actions-group-meta .tool-subtitle {
  white-space: nowrap;
}

#templateSourceInfo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#templateSourceInfo .template-source-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#templateSourceInfo .template-source-icon .ui-icon {
  font-size: 21px;
}

.input-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  align-items: center;
}

.input-row.compact {
  grid-template-columns: 130px minmax(0, 1fr) 76px auto;
}

.mode-panel,
.expert-grid {
  display: grid;
  gap: 10px;
}

.is-hidden {
  display: none !important;
}

.status {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 34px;
  padding: 9px 16px;
  border-top: 1px solid rgb(51, 51, 51);
  background: #151515;
  color: #f0f3f7;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  pointer-events: auto;
}

.status-text-value {
  min-width: 0;
  flex: 1 1 auto;
}

.mobile-status-label,
.mobile-status-actions,
.mobile-quick-template-bar {
  display: none;
}

.status-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.status-links button:hover {
  background: transparent;
}

.status-links a {
  color: #a4b1c4;
  text-decoration: none;
  white-space: nowrap;
}

.status-link-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a4b1c4;
  font: inherit;
  line-height: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.status-link-icon-button .ui-icon {
  font-size: 15px;
}

.status-link-button {
  border: 1px solid #314256;
  border-radius: 999px;
  padding: 3px 8px;
  background: #1d2938;
  color: #a4b1c4;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.status-link-button:hover,
.status-link-button:focus-visible {
  background: #26364a;
  color: #d1d9e4;
}


.status-link-icon-button:hover,
.status-link-icon-button:focus-visible,
.status-links a:hover,
.status-links a:focus-visible,
.about-panel-inner a
 {
  color: #cad4e1;
  text-decoration: underline;
}

.history-body {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  background: #151515;
}

.about-panel {
  padding: 56px 22px 80px;
  background:
    linear-gradient(180deg, #111 0%, #151922 100%);
  border-top: 1px solid rgb(51, 51, 51);
}

.about-panel.is-hidden {
  display: none;
}

.about-disclosure {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  border: 1px solid #2b3440;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(23, 28, 37, 0.98) 0%, rgba(18, 22, 30, 0.98) 100%);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.about-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  background:
    radial-gradient(circle at top left, rgba(139, 170, 221, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(29, 35, 46, 0.96) 0%, rgba(21, 26, 35, 0.96) 100%);
  color: #f1f5fb;
  cursor: pointer;
  list-style: none;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.about-summary:hover,
.about-summary:focus-visible {
  background:
    radial-gradient(circle at top left, rgba(139, 170, 221, 0.15), transparent 34%),
    linear-gradient(180deg, rgba(32, 38, 50, 0.98) 0%, rgba(24, 29, 39, 0.98) 100%);
}

.about-summary::-webkit-details-marker {
  display: none;
}

.about-summary-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.about-summary-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(114, 137, 173, 0.34);
  border-radius: 999px;
  background: rgba(89, 110, 142, 0.12);
  color: #d6deea;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.about-summary-side {
  display: grid;
  justify-items: end;
  gap: 10px;
  flex: 0 0 auto;
}

.about-summary-hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(115, 130, 153, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
  color: #d8e2ef;
  font-size: 12px;
  font-weight: bold;
  line-height: 1.2;
  text-transform: uppercase;  
}

.about-summary-hint::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 1.5px solid #aebcd0;
  border-bottom: 1.5px solid #aebcd0;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}

.about-disclosure[open] .about-summary {
  border-bottom: 1px solid rgba(83, 96, 116, 0.38);
}

.about-disclosure[open] .about-summary-hint::after {
  transform: rotate(-135deg) translateY(-1px);
}

.about-panel-inner {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 26px;
  padding: 28px 22px 22px;
  background:
    linear-gradient(180deg, rgba(19, 24, 32, 0.96) 0%, rgba(16, 20, 27, 0.96) 100%);
}

.about-hero {
  display: grid;
  gap: 18px;
  padding: 2px 2px 10px;
}

.about-hero-copy {
  display: grid;
  gap: 16px;
}

.about-lead {
  color: #dee7f2;
  font-size: 17px;
  line-height: 1.72;
}

.about-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.about-meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(104, 120, 145, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #d4deea;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.about-panel-inner h1,
.about-panel-inner h2 {
  margin: 0;
  color: #f1f5fb;
}

.about-panel-inner h1 {
  max-width: 920px;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.about-panel-inner h2 {
  font-size: 20px;
  line-height: 1.3;
}

.about-panel-inner p {
  margin: 0;
  color: #c7d1de;
  font-size: 15px;
  line-height: 1.7;
  max-width: 980px;
}

.about-section-block {
  display: grid;
  gap: 14px;
  padding: 20px 2px 0;
  border-top: 1px solid rgba(77, 89, 107, 0.34);
}

.about-section-block-muted {
  border-top-color: rgba(90, 104, 90, 0.34);
}

.about-list {
  margin: 0;
  padding-left: 20px;
  color: #d1d9e4;
  font-size: 15px;
  line-height: 1.7;
}

.about-list li + li {
  margin-top: 8px;
}

.static-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #111 0%, #151922 100%);
}

.static-page-shell {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 56px 18px 72px;
}

.static-page-card {
  display: grid;
  gap: 18px;
  padding: 26px 28px;
  border: 1px solid #2f3742;
  border-radius: 20px;
  background: rgba(24, 29, 38, 0.94);
}

.static-page-card h1 {
  margin: 0;
  color: #f1f5fb;
  font-size: 30px;
  line-height: 1.2;
}

.static-page-card p {
  margin: 0;
  color: #c4cedb;
  font-size: 15px;
  line-height: 1.7;
}

.static-page-back a {
  color: #9dc2ff;
  text-decoration: none;
  font-size: 13px;
}

.static-page-back a:hover,
.static-page-back a:focus-visible {
  color: #c3dcff;
  text-decoration: underline;
}

@supports not (gap: 8px) {
  .panel-header > * + *,
  .tool-title > * + * {
    margin-left: 10px;
  }

  .buttons,
  .action-row,
  .template-actions,
  .chain-actions,
  .modal-actions {
    margin-top: -8px;
    margin-left: -8px;
  }

  .buttons > *,
  .action-row > *,
  .template-actions > *,
  .chain-actions > *,
  .modal-actions > * {
    margin-top: 8px;
    margin-left: 8px;
  }
}

html[dir="rtl"] .topbar {
  flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-brand {
  flex-direction: row-reverse;
}

html[dir="rtl"] .topbar-actions {
  direction: rtl;
}

html[dir="rtl"] .app-panels {
  direction: rtl;
}

html[dir="rtl"] .preview-panel,
html[dir="rtl"] .history-panel {
  border-left: 0;
  border-right: 1px solid #333;
}

html[dir="rtl"] .app.has-panel-resizers .preview-panel,
html[dir="rtl"] .app.has-panel-resizers .history-panel,
html[dir="rtl"].app-booting.ui-panel-resizers #appRoot .preview-panel,
html[dir="rtl"].app-booting.ui-panel-resizers #appRoot .history-panel {
  border-right: 0;
}

html[dir="rtl"] .panel-header,
html[dir="rtl"] .tool-card,
html[dir="rtl"] .history-body,
html[dir="rtl"] .status,
html[dir="rtl"] .about-panel-inner,
html[dir="rtl"] .static-page-card {
  text-align: right;
}

html[dir="rtl"] .panel-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .history-panel .panel-header .buttons {
  flex: 0 0 auto;
}

html[dir="rtl"] .buttons,
html[dir="rtl"] .action-row,
html[dir="rtl"] .chain-actions,
html[dir="rtl"] .modal-actions,
html[dir="rtl"] .status-links {
  justify-content: flex-start;
}

html[dir="rtl"] .code-settings-menu {
  right: auto;
  left: 0;
}

html[dir="rtl"] .template-actions-toolbar {
  direction: rtl;
}

html[dir="rtl"] .template-actions-group-meta {
  margin-left: 0;
}

html[dir="rtl"] .about-summary-side {
  justify-items: start;
}

html[dir="rtl"] .about-list {
  padding-left: 0;
  padding-right: 20px;
}
