* {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-height: 100%;
}

body {
  height: 100dvh;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: #f4f6f8;
  color: #20242b;
  font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  width: min(1760px, calc(100% - 16px));
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  margin: 0 auto;
  padding: 8px 0;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  padding: 6px 0 8px;
}

.header-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #14213d;
  color: #fff;
  font-size: 0;
  font-weight: 700;
}

.brand::before {
  content: "M";
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #657080;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #151922;
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.3;
}

h3 {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.4;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid #cdd5df;
  border-radius: 8px;
  background: #fff;
  padding: 8px 14px;
  color: #273142;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.text-button:not(:disabled):hover {
  border-color: #9aa8ba;
}

.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.header-utilities {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.editor-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  gap: 6px;
}

.editor-workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  gap: 10px;
}

.templates-panel {
  min-height: 0;
  overflow: hidden;
}

.templates-panel .templates-list {
  height: 74px;
}

.templates-panel .template-card {
  flex-basis: 112px;
  width: 112px;
  height: 64px;
}

.templates-panel .template-button {
  height: 100%;
  grid-template-rows: 1fr;
}

.templates-panel .template-thumb {
  height: 100%;
  border-radius: 7px;
  aspect-ratio: auto;
}

.templates-panel .template-title {
  display: none;
}

.templates-panel .template-selection-detail {
  display: none;
}

.editor-center {
  display: grid;
  min-height: 0;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(180px, 0.28fr)
    minmax(200px, 0.3fr)
    minmax(250px, 0.38fr);
  gap: 14px;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

.preview-stack {
  display: grid;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-items: center;
}

.preview-panel {
  position: relative;
  display: grid;
  width: min(100%, 740px);
  min-height: 0;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  border: 1px solid #c9d5e4;
  border-radius: 8px;
  background: #101827;
}

.preview-stage {
  position: absolute;
  inset: 0;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  background: #101827;
}

.preview-stage[data-preview-state="error"] {
  background: #1f1012;
}

.preview-layer {
  position: absolute;
  inset: 0;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.preview-placeholder[hidden],
.preview-video-layer[hidden] {
  display: none;
}

.preview-stage .video-js {
  width: 100%;
  height: 100%;
  background: #101827;
}

.preview-stage .video-js,
.preview-stage .video-js .vjs-tech {
  inset: 0;
}

.preview-stage .video-js .vjs-tech {
  object-fit: contain;
}

.preview-stage .video-js .vjs-control-bar,
.preview-stage .video-js .vjs-big-play-button,
.preview-stage .video-js .vjs-loading-spinner,
.preview-stage .video-js .vjs-picture-in-picture-control,
.preview-stage .video-js .vjs-play-control,
.preview-stage .video-js .vjs-volume-panel,
.preview-stage .video-js .vjs-fullscreen-control,
.preview-stage .video-js .vjs-remaining-time,
.preview-stage .video-js .vjs-current-time,
.preview-stage .video-js .vjs-duration,
.preview-stage .video-js .vjs-progress-control {
  display: none !important;
}

.preview-media,
.preview-stage img,
.preview-stage video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-media[data-preview-ratio="4:3"] {
  width: auto;
  aspect-ratio: 4 / 3;
}

.preview-media[data-preview-ratio="16:9"] {
  height: auto;
  aspect-ratio: 16 / 9;
}

.preview-placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  min-height: 0;
  color: #e8edf5;
  text-align: center;
  padding: 22px;
  box-sizing: border-box;
}

.preview-placeholder strong {
  font-size: 18px;
  line-height: 1.35;
}

.preview-placeholder span {
  color: #aab7c8;
  font-size: 13px;
  line-height: 1.5;
}

.preview-loading-indicator {
  display: none;
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 999px;
  animation: preview-spin 0.9s linear infinite;
}

.preview-stage[data-preview-state="starting"] .preview-loading-indicator,
.preview-stage[data-preview-state="generating"] .preview-loading-indicator,
.preview-stage[data-preview-state="ready"] .preview-loading-indicator {
  display: block;
}

.preview-stage[data-preview-state="error"] .preview-placeholder strong {
  color: #ffd6d2;
}

.preview-stage[data-preview-state="error"] .preview-placeholder span {
  color: #ffbbb6;
}

@keyframes preview-spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-playback-status {
  display: grid;
  min-height: 46px;
  align-items: center;
  margin: 0;
  border: 1px solid #dbe4ef;
  border-radius: 7px;
  background: #fff;
  padding: 8px 10px;
  color: #46566d;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.preview-playback-status[data-preview-state="starting"],
.preview-playback-status[data-preview-state="generating"],
.preview-playback-status[data-preview-state="ready"] {
  border-color: #c9d8ea;
  background: #f7fbff;
  color: #2b5c8a;
}

.preview-playback-status[data-preview-state="playing"] {
  border-color: #cde8d2;
  background: #f4fbf5;
  color: #256b36;
}

.preview-playback-status[data-preview-state="completed"] {
  border-color: #d9e0ec;
  background: #f8fafc;
  color: #374151;
}

.preview-playback-status.is-error {
  border-color: #f2b8b5;
  background: #fff6f6;
  color: #b42318;
}

.preview-playback-status.is-warning {
  border-color: #f3d58b;
  background: #fff9e8;
  color: #7a4d00;
}

.preview-controls,
.playback-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preview-control-button,
.export-movie-button {
  display: inline-flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cdd5df;
  border-radius: 7px;
  background: #fff;
  padding: 7px 10px;
  color: #273142;
  font-weight: 700;
  cursor: pointer;
}

.preview-control-button {
  padding-inline: 7px;
  font-size: 16px;
  white-space: normal;
}

.preview-control-button:disabled,
.export-movie-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.preview-operations,
.photo-settings,
.editor-actions {
  display: grid;
  min-width: 0;
  min-height: 0;
  align-content: start;
  gap: 10px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.preview-operations,
.photo-settings {
  background: #f7f9fc;
}

.photo-settings-controls {
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr;
  gap: 12px;
}

.editor-actions {
  justify-self: stretch;
}

.editor-action-group {
  display: grid;
  min-width: 0;
  gap: 7px;
  margin: 0;
  border: 0;
  padding: 0;
}

.editor-action-group legend,
.editor-action-group > span {
  color: #405064;
  font-size: 13px;
  font-weight: 700;
}

.export-format-group label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #273142;
  font-size: 13px;
  font-weight: 600;
}

.export-format-group .format-future {
  color: #657080;
}

.format-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e8edf5;
  padding: 2px 7px;
  color: #5b6677;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.format-status-current {
  background: #e8f5ee;
  color: #0d6b3d;
}

.export-format-note {
  margin: 2px 0 0;
  color: #5b6677;
  font-size: 11px;
  line-height: 1.5;
}

.photo-duration-group select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #cdd5df;
  border-radius: 7px;
  background: #fff;
  padding: 6px 9px;
  color: #151922;
  font: inherit;
  font-weight: 600;
}

.photo-aspect-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.photo-aspect-button {
  min-height: 34px;
  border: 1px solid #c9d5e4;
  border-radius: 7px;
  background: #fff;
  padding: 7px 10px;
  color: #273142;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.photo-aspect-button:hover,
.photo-aspect-button.is-selected {
  border-color: #3159c6;
  background: #eef4ff;
  color: #2548a8;
}

.photo-aspect-button.is-selected {
  box-shadow: 0 0 0 2px rgba(49, 89, 198, 0.16);
}

.photo-aspect-button:focus-visible {
  outline: 2px solid rgba(55, 102, 214, 0.45);
  outline-offset: 2px;
}

.photo-aspect-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.export-movie-button {
  width: 100%;
}

.export-movie-button {
  border-color: #254db8;
  background: #3766d6;
  color: #fff;
}

.editor-actions p {
  margin: 0;
  color: #5b6677;
  font-size: 13px;
  line-height: 1.5;
}

.status-bar,
.editor-meta-bar,
.summary-grid,
.panel {
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fff;
}

.status-bar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  padding: 5px 9px;
  color: #405064;
  font-size: 12px;
}

.status-bar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
}

.status-dot.is-ready {
  background: #16a34a;
}

.status-dot.is-error {
  background: #dc2626;
}

.error-message {
  margin: 0;
  color: #b42318;
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.editor-meta-bar {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  border: 0;
  background: transparent;
  padding: 0;
}

.editor-meta-item {
  display: inline-flex;
  min-width: 0;
  align-items: baseline;
  gap: 6px;
  color: #405064;
}

.editor-meta-item .summary-label {
  margin: 0;
  font-size: 11px;
}

.editor-meta-item strong {
  display: block;
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  color: #151922;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-meta-storage {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
}

.summary-item {
  min-width: 0;
  padding: 8px 12px;
}

.summary-item + .summary-item {
  border-left: 1px solid #e5ebf1;
}

.summary-label {
  display: block;
  margin-bottom: 2px;
  color: #657080;
  font-size: 12px;
  font-weight: 600;
}

.summary-item strong {
  display: block;
  overflow: hidden;
  color: #151922;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.template-panel-header {
  align-items: center;
}

.template-panel-header > div {
  min-width: 0;
}

.template-title-row {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 12px;
}

.selected-template-summary {
  margin: 0;
  overflow: hidden;
  color: #405064;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  min-width: 0;
  padding: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.meta-text {
  color: #657080;
  font-size: 12px;
  white-space: nowrap;
}

.slide-board {
  min-height: 0;
  overflow: hidden;
}

.slide-grid {
  display: flex;
  gap: 10px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 4px;
  scroll-snap-type: x proximity;
}

.slide-card {
  flex: 0 0 170px;
  min-width: 0;
  width: 170px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 6px;
  scroll-snap-align: start;
}

.slide-card.has-photo {
  border-color: #86b7a0;
  background: #f7fcf9;
}

.slide-card.is-drag-over {
  border-color: #3766d6;
  background: #f2f6ff;
}

.slide-card.is-busy {
  opacity: 0.82;
}

.slide-card-header,
.slide-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slide-card-header {
  margin-bottom: 4px;
}

.slide-number {
  display: inline-flex;
  min-width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #20242b;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.slide-delete-button,
.slide-choose-button,
.slide-edit-button,
.slide-comment-button {
  min-height: 32px;
  border: 1px solid #cdd5df;
  border-radius: 6px;
  background: #fff;
  padding: 6px 10px;
  color: #273142;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-delete-button:disabled,
.slide-choose-button:disabled,
.slide-edit-button:disabled,
.slide-comment-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.slide-preview {
  position: relative;
  height: 96px;
  margin-bottom: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: #eef3f7;
  border: 1px dashed #c6d0dc;
  cursor: pointer;
}

.slide-preview:focus {
  outline: 2px solid rgba(55, 102, 214, 0.45);
  outline-offset: 2px;
}

.slide-card.is-drag-over .slide-preview {
  border-color: #3766d6;
  background: #eaf1ff;
}

.slide-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.slide-comment-mark {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 1px 3px rgba(21, 25, 34, 0.22);
}

.slide-comment-mark.is-active,
.slide-comment-mark[data-has-comment="1"] {
  background: #16a34a;
}

.slide-actions {
  align-items: stretch;
  gap: 8px;
  justify-content: space-between;
}

.slide-file-input {
  display: none;
}

.slide-choose-button,
.slide-edit-button,
.slide-comment-button {
  flex: 1 1 0;
  min-width: 0;
}

.slide-status,
.slide-error {
  margin: 6px 0 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-status {
  display: none;
}

.slide-status {
  color: #5b6677;
}

.slide-card.has-photo .slide-status {
  color: #16784f;
  font-weight: 700;
}

.slide-error {
  color: #b42318;
  font-weight: 700;
}

.templates-list {
  display: flex;
  gap: 10px;
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 8px;
  scroll-snap-type: x proximity;
}

.variants-list {
  display: grid;
  gap: 10px;
}

.template-card {
  display: grid;
  flex: 0 0 150px;
  grid-template-rows: minmax(0, 1fr);
  width: 150px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  padding: 0;
  scroll-snap-align: start;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.template-card:hover,
.template-card.is-selected {
  border-color: #3159c6;
  background: #f6f9ff;
}

.template-card:hover {
  box-shadow: 0 8px 18px rgba(21, 25, 34, 0.12);
  transform: translateY(-1px);
}

.template-card.is-selected {
  box-shadow: 0 0 0 2px rgba(49, 89, 198, 0.28);
}

.template-button {
  display: grid;
  grid-template-rows: auto auto;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  color: #20242b;
  text-align: left;
  cursor: pointer;
}

.template-button:disabled {
  cursor: default;
  opacity: 0.7;
}

.template-thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px 7px 0 0;
  aspect-ratio: 16 / 9;
  background: #e8edf5;
  color: #657080;
  font-size: 12px;
  font-weight: 700;
}

.template-thumb-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.18s ease;
}

.template-thumb.has-image .template-thumb-placeholder {
  opacity: 0;
}

.template-card:hover .template-thumb-image {
  transform: scale(1.03);
}

.template-selected-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  border-radius: 999px;
  background: #3159c6;
  padding: 3px 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

.template-card.is-selected .template-selected-badge {
  opacity: 1;
}

.template-card-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-title {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 6px 8px 7px;
}

.template-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.template-key {
  color: #657080;
  font-size: 12px;
  white-space: nowrap;
}

.template-duration {
  flex: 0 0 auto;
  color: #405064;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.template-description,
.path-text,
.empty-text,
.field-value {
  color: #5b6677;
  font-size: 13px;
  line-height: 1.6;
}

.template-description {
  display: -webkit-box;
  overflow: hidden;
  min-height: 38px;
  margin: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.path-text {
  margin: 0;
  overflow-wrap: anywhere;
}

.template-detail {
  margin: 0;
}

.template-selection-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 12px;
  margin-top: 12px;
  border-top: 1px solid #edf1f5;
  padding-top: 12px;
}

.detail-list,
.variant-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1f5;
}

.field-name {
  color: #657080;
  font-size: 13px;
  font-weight: 600;
}

.field-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.variant-item {
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.variant-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.variant-heading strong {
  overflow-wrap: anywhere;
}

.selected-template-detail-card {
  display: grid;
  gap: 8px;
}

.selected-template-detail-name {
  color: #20242b;
  font-size: 14px;
  line-height: 1.5;
}

.selected-template-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.summary-chip {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  background: #fff;
  padding: 4px 9px;
  color: #273142;
  font-size: 12px;
  line-height: 1.4;
}

.summary-chip-label {
  color: #657080;
  font-weight: 700;
}

.variant-summary-text {
  margin: 0;
  color: #5b6677;
  font-size: 12px;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e8edf5;
  padding: 3px 8px;
  color: #405064;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.empty-text {
  margin: 0;
}

.has-modal-open {
  overflow: hidden;
}

.template-detail-modal[hidden],
.comment-modal[hidden],
.photo-edit-modal[hidden],
.render-export-modal[hidden] {
  display: none;
}

.template-detail-modal,
.comment-modal,
.photo-edit-modal,
.render-export-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.template-detail-backdrop,
.comment-modal-backdrop,
.photo-edit-backdrop,
.render-export-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 25, 34, 0.46);
}

.template-detail-dialog,
.comment-dialog,
.photo-edit-dialog,
.render-export-dialog {
  position: relative;
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(21, 25, 34, 0.28);
}

.template-detail-dialog-header,
.template-detail-dialog-actions,
.comment-dialog-header,
.comment-dialog-actions,
.photo-edit-dialog-header,
.photo-edit-dialog-actions,
.render-export-dialog-header,
.render-export-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

.template-detail-dialog-header,
.comment-dialog-header,
.photo-edit-dialog-header,
.render-export-dialog-header {
  border-bottom: 1px solid #edf1f5;
}

.template-detail-dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid #edf1f5;
}

.template-detail-dialog-actions .primary-button {
  min-width: 220px;
  min-height: 44px;
  font-size: 15px;
}

.template-detail-dialog {
  width: min(900px, 100%);
}

.render-export-dialog {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.template-detail-label {
  margin: 0 0 4px;
  color: #657080;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.render-export-label {
  margin: 0 0 4px;
  color: #657080;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.render-export-dialog-body {
  display: grid;
  gap: 16px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.render-export-status {
  display: grid;
  gap: 10px;
}

.render-export-stage-message {
  margin: 0;
  color: #273142;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.render-progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.render-progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e9f2;
}

.render-progress-bar {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #3766d6;
  transition: width 0.2s ease;
}

.render-progress-percent {
  min-width: 44px;
  color: #273142;
  font-size: 13px;
  text-align: right;
}

.render-sample-block,
.render-payment-block {
  display: grid;
  gap: 10px;
}

.render-sample-block[hidden],
.render-payment-block[hidden],
.render-purchase-summary[hidden],
.render-mock-payment-button[hidden],
.render-checkout-button[hidden],
.render-payment-unavailable-button[hidden],
.render-payment-status[hidden],
.render-download-link[hidden],
.render-retry-button[hidden],
.render-export-error[hidden] {
  display: none;
}

.render-export-error {
  margin: 0;
}

.render-sample-video {
  display: block;
  width: 100%;
  max-height: min(42vh, 320px);
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  background: #101827;
  object-fit: contain;
}

.render-sample-block.has-purchase-summary .render-sample-video {
  max-height: min(30vh, 190px);
}

.render-sample-block .secondary-button {
  justify-self: start;
}

.render-payment-block {
  border-top: 1px solid #edf1f5;
  padding-top: 14px;
}

.render-purchase-summary {
  display: grid;
  gap: 10px;
  border: 1px solid #cbd8f2;
  border-radius: 8px;
  background: #f7f9fe;
  padding: 14px;
}

.render-purchase-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.render-payment-block .render-purchase-kicker {
  margin: 0 0 2px;
  color: #657080;
  font-size: 11px;
  font-weight: 700;
}

.render-purchase-heading h3 {
  margin: 0;
  color: #151922;
  font-size: 17px;
  line-height: 1.4;
}

.render-payment-block .render-purchase-price {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  margin: 0;
  color: #273142;
  line-height: 1.35;
}

.render-purchase-price strong {
  color: #173f9f;
  font-size: 18px;
}

.render-purchase-price span {
  color: #5b6677;
  font-size: 11px;
  font-weight: 700;
}

.render-purchase-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
}

.render-purchase-details > div {
  min-width: 0;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
}

.render-purchase-details dt {
  color: #657080;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.render-purchase-details dd {
  margin: 2px 0 0;
  color: #273142;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.render-payment-block .render-purchase-flow {
  color: #273142;
  font-weight: 600;
}

.render-payment-block .render-purchase-policy {
  border-left: 3px solid #d6a72b;
  background: #fffbeb;
  padding: 7px 9px;
  color: #694b00;
  font-size: 12px;
}

.render-payment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.render-payment-block .primary-button,
.render-payment-block .secondary-button {
  min-width: 0;
  min-height: 44px;
  max-width: 100%;
  justify-self: start;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: center;
}

.render-download-link {
  text-decoration: none;
}

.render-payment-block p {
  margin: 0;
  color: #5b6677;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.render-payment-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.render-payment-legal-links a {
  color: #2548a8;
  font-weight: 700;
}

.render-payment-legal-links a:hover {
  text-decoration: underline;
}

.render-payment-status.is-error {
  color: #b42318;
}

.render-payment-status.is-success {
  color: #0d6b3d;
  font-weight: 600;
}

.template-detail-dialog-body {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.template-detail-overview,
.template-detail-content {
  min-width: 0;
}

.template-detail-thumb-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  aspect-ratio: 16 / 9;
  background: #e8edf5;
  color: #657080;
  font-size: 13px;
  font-weight: 700;
}

.template-detail-thumb-wrap .template-detail-thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-detail-meta {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.template-detail-meta div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.template-detail-meta dt {
  color: #657080;
  font-size: 12px;
  font-weight: 700;
}

.template-detail-meta dd {
  min-width: 0;
  margin: 0;
  color: #20242b;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.template-detail-description-text,
.template-detail-loading,
.template-detail-lyrics {
  color: #405064;
  font-size: 13px;
  line-height: 1.7;
}

.template-detail-description-block {
  display: grid;
  gap: 7px;
}

.template-detail-description-block h3 {
  margin: 0;
  font-size: 13px;
}

.template-detail-description-text {
  margin: 0;
}

.template-detail-content {
  display: grid;
  align-content: start;
  gap: 16px;
}

.template-detail-content h3 {
  margin: 0 0 8px;
  color: #20242b;
  font-size: 15px;
}

.template-detail-loading {
  margin: 0;
}

.template-detail-error {
  margin: 0;
}

.template-detail-section {
  display: grid;
  gap: 8px;
}

.template-detail-ratios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-detail-ratio-button {
  border: 1px solid #c9d5e4;
  border-radius: 8px;
  background: #fff;
  min-width: 76px;
  padding: 8px 13px;
  color: #273142;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.template-detail-ratio-button:hover,
.template-detail-ratio-button.is-selected {
  border-color: #3159c6;
  background: #eef4ff;
  color: #2548a8;
}

.template-detail-ratio-button.is-selected {
  box-shadow: 0 0 0 2px rgba(49, 89, 198, 0.16);
}

.template-detail-variants {
  display: grid;
  gap: 10px;
}

.template-detail-variant {
  display: grid;
  gap: 9px;
  width: 100%;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: #20242b;
  text-align: left;
  cursor: pointer;
}

.template-detail-variant:hover,
.template-detail-variant.is-selected {
  border-color: #3159c6;
  background: #f6f9ff;
}

.template-detail-variant.is-selected {
  box-shadow: 0 0 0 2px rgba(49, 89, 198, 0.18);
}

.template-detail-variant-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-detail-variant-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.template-detail-variant-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #5b6677;
  font-size: 12px;
  line-height: 1.5;
}

.template-detail-lyrics-block {
  border-top: 1px solid #edf1f5;
  padding-top: 14px;
}

.template-detail-lyrics {
  min-height: 76px;
  max-height: 220px;
  margin: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.comment-dialog-body {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.15fr);
  gap: 18px;
  padding: 18px;
}

.comment-editor-panel,
.comment-field {
  display: grid;
  gap: 8px;
}

.comment-field,
.comment-control {
  color: #405064;
  font-size: 13px;
  font-weight: 700;
}

.comment-editor-panel {
  align-content: start;
  gap: 14px;
}

.comment-field textarea {
  min-height: 190px;
  resize: vertical;
  border: 1px solid #cdd5df;
  border-radius: 8px;
  padding: 12px;
  color: #151922;
  font: inherit;
  line-height: 1.7;
}

.comment-field textarea:focus {
  outline: 2px solid rgba(55, 102, 214, 0.35);
  outline-offset: 1px;
}

.comment-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.comment-control {
  display: grid;
  gap: 6px;
}

.comment-control select,
.comment-control input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cdd5df;
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px;
  color: #151922;
  font: inherit;
  font-weight: 600;
}

.comment-custom-font-field {
  grid-column: 1 / -1;
}

.comment-custom-font-field[hidden] {
  display: none;
}

.comment-custom-font-field small {
  color: #657080;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
}

.comment-control select:focus,
.comment-control input:focus {
  outline: 2px solid rgba(55, 102, 214, 0.35);
  outline-offset: 1px;
}

.comment-position-controls {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.comment-preview-wrap {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #eef3f7;
  padding: 12px;
}

.comment-preview-frame {
  position: relative;
  display: grid;
  width: 100%;
  max-width: 720px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cdd5df;
  border-radius: 8px;
  background: #e1e7ef;
  aspect-ratio: 4 / 3;
}

.comment-preview-frame[data-ratio="16:9"] {
  aspect-ratio: 16 / 9;
}

.comment-preview-frame canvas {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  background:
    linear-gradient(45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(-45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f8fafc 75%),
    linear-gradient(-45deg, transparent 75%, #f8fafc 75%);
  background-color: #fff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  cursor: grab;
  touch-action: none;
}

.comment-preview-frame[data-ratio="16:9"] canvas {
  width: 75%;
  max-width: none;
  height: 100%;
}

.comment-preview-frame canvas.is-dragging {
  cursor: grabbing;
}

.photo-edit-dialog-body {
  display: grid;
  grid-template-columns: minmax(320px, 1.35fr) minmax(220px, 0.65fr);
  gap: 18px;
  padding: 18px;
}

.photo-edit-preview-wrap {
  display: grid;
  align-items: center;
  min-height: 320px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: #eef3f7;
  box-shadow: none;
  padding: 12px;
}

.photo-edit-preview-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  cursor: grab;
  touch-action: none;
}

.photo-edit-preview-wrap canvas.is-dragging {
  cursor: grabbing;
}

.photo-edit-controls,
.photo-edit-control {
  display: grid;
  gap: 12px;
}

.photo-edit-control {
  color: #405064;
  font-size: 13px;
  font-weight: 700;
}

.photo-edit-control input {
  width: 100%;
}

.photo-edit-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-detail-error,
.comment-modal-error,
.photo-edit-error,
.render-export-error {
  margin: 0 18px;
  border: 1px solid #f1b9b2;
  border-radius: 8px;
  background: #fff5f4;
  padding: 10px 12px;
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.render-export-error {
  margin: 0;
}

.comment-dialog-actions,
.photo-edit-dialog-actions,
.render-export-dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid #edf1f5;
}

.render-export-dialog-actions {
  flex-wrap: wrap;
}

.render-export-dialog-actions .primary-button,
.render-export-dialog-actions .secondary-button,
.render-export-dialog-actions .danger-button {
  min-height: 44px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  border: 1px solid #cdd5df;
  background: #fff;
  color: #273142;
  font-size: 20px;
  line-height: 1;
}

.primary-button {
  border: 1px solid #254db8;
  background: #3766d6;
  color: #fff;
}

.secondary-button {
  border: 1px solid #cdd5df;
  background: #fff;
  color: #273142;
}

.danger-button {
  border: 1px solid #f1b9b2;
  background: #fff5f4;
  color: #b42318;
}

.comment-delete-button {
  margin-right: auto;
}

.icon-button:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (max-height: 960px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .editor-workspace {
    grid-template-rows: auto auto auto;
  }

  .editor-center {
    min-height: auto;
    overflow: visible;
  }
}

@media (max-height: 680px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 680px;
  }

  .editor-center {
    min-height: auto;
    overflow: visible;
  }

  .preview-panel {
    min-height: 150px;
  }

  .render-export-dialog-header,
  .render-export-dialog-actions {
    padding-block: 10px;
  }

  .render-export-dialog-body {
    gap: 10px;
    padding-block: 12px;
  }

  .render-sample-video {
    max-height: min(22vh, 132px);
  }

  .render-payment-block {
    padding-top: 10px;
  }

  .render-purchase-summary {
    gap: 8px;
    padding: 10px;
  }
}

@media (min-width: 821px) and (max-width: 1279px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .editor-workspace {
    grid-template-rows: auto auto auto;
  }

  .editor-center {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .preview-stack {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    width: min(100% - 24px, 1760px);
    height: auto;
    min-height: 100dvh;
    padding-top: 10px;
  }

  .editor-header {
    align-items: flex-start;
  }

  .work-grid {
    grid-template-columns: 1fr;
  }

  .editor-center {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .preview-stack {
    justify-items: center;
  }

  .preview-controls,
  .playback-controls {
    grid-template-columns: 1fr;
  }

  .template-selection-detail {
    grid-template-columns: 1fr;
  }

  .summary-item + .summary-item {
    border-left: 1px solid #e5ebf1;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .template-detail-dialog-body,
  .comment-dialog-body,
  .photo-edit-dialog-body,
  .render-export-dialog-body {
    grid-template-columns: 1fr;
  }

  .templates-list {
    margin-right: -14px;
  }
}

@media (max-width: 560px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .editor-header {
    flex-direction: column;
  }

  .header-utilities {
    width: 100%;
    flex-wrap: wrap;
  }

  .status-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .template-detail-modal,
  .comment-modal,
  .photo-edit-modal,
  .render-export-modal {
    padding: 12px;
  }

  .template-detail-dialog,
  .comment-dialog,
  .photo-edit-dialog,
  .render-export-dialog {
    max-height: calc(100vh - 24px);
  }

  .template-detail-dialog-header,
  .template-detail-dialog-body,
  .template-detail-dialog-actions,
  .comment-dialog-header,
  .comment-dialog-body,
  .comment-dialog-actions,
  .photo-edit-dialog-header,
  .photo-edit-dialog-body,
  .photo-edit-dialog-actions,
  .render-export-dialog-header,
  .render-export-dialog-body,
  .render-export-dialog-actions {
    padding: 14px;
  }

  .render-purchase-heading {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .render-payment-block .render-purchase-price {
    align-items: flex-start;
  }

  .comment-dialog-actions,
  .template-detail-dialog-actions,
  .photo-edit-dialog-actions,
  .render-export-dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .comment-delete-button {
    margin-right: 0;
  }
}
