/* Phone-first task dialog. All task UI stays inside the modal top layer. */
.task-dialog,
.task-dialog * {
  box-sizing: border-box;
}

.task-dialog {
  position: fixed;
  inset: 0;
  width: min(480px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  height: calc(100vh - 16px);
  height: calc(100dvh - 16px);
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  margin: 8px auto;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  isolation: isolate;
  border: 2px solid #b6c4b4;
  border-radius: 20px;
  background: #f8f5ed;
  color: #243c35;
  box-shadow: 0 20px 70px #172e3540;
  font-size: 15px;
  line-height: 1.65;
}

.task-dialog[open] {
  display: flex;
  flex-direction: column;
}

.task-dialog::backdrop {
  background: #1d302b80;
  backdrop-filter: blur(4px);
}

.task-dialog button,
.task-dialog a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.task-dialog :is(button, a, input, textarea):focus-visible {
  outline: 3px solid #27664c;
  outline-offset: 3px;
}

/* The header remains in place while only the body scrolls. */
.task-dialog-top {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  flex: 0 0 auto;
  align-items: start;
  gap: 8px;
  padding: 14px 12px;
  border-bottom: 2px solid #b6c4b4;
  background: #fffdf7;
}

.task-dialog-top h2 {
  min-width: 0;
  margin: 0;
  color: #243c35;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.task-dialog-top small {
  display: block;
  margin-top: 6px;
  color: #52665a;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
}

.task-dialog .close-dialog {
  display: grid;
  place-items: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 1.5px solid #b6c4b4;
  border-radius: 14px;
  background: #edf2e7;
  color: #27664c;
  font-size: 28px;
  line-height: 1;
}

.task-body {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 14px 12px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.task-summary {
  margin: 0 0 14px;
  padding: 16px 14px;
  border: 1.5px solid #b6c4b4;
  border-radius: 16px;
  background: #edf2e6;
}

.task-summary h3 {
  margin: 0 0 8px;
  color: #243c35;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.45;
}

.task-summary p {
  margin: 0;
  color: #52665a;
  font-size: 15px;
  line-height: 1.65;
}

.task-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 16px 0 0;
  color: #27664c;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.task-progress span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  padding: 8px 4px;
  border: 1px solid #b6c4b4;
  border-radius: 10px;
  background: #fffefa;
  font-weight: 650;
}

.task-progress b {
  display: none;
}

.task-source {
  margin: 0 2px 16px;
  color: #52665a;
  font-size: 14px;
  line-height: 1.65;
}

.task-step {
  min-width: 0;
  margin: 16px 0 0;
  padding: 16px 12px;
  border: 1.5px solid #b6c4b4;
  border-radius: 16px;
  background: #fffefa;
}

.task-step-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
}

.task-step-heading > span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #b6c4b4;
  border-radius: 8px;
  background: #e8f0e4;
  color: #27664c;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.task-step h3 {
  margin: 0;
  color: #243c35;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.5;
}

.task-description {
  margin: 12px 0 16px;
  color: #52665a;
  font-size: 15px;
  line-height: 1.65;
}

.platforms {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 14px;
}

.platform {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 104px;
  padding: 12px 4px;
  border: 1.5px solid #b6c4b4;
  border-radius: 12px;
  background: #f7f8f0;
  color: #243c35;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
}

.platform img {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.task-copy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.task-copy-box {
  min-width: 0;
  padding: 12px;
  border: 1.5px solid #b6c4b4;
  border-radius: 12px;
  background: #f7f8f0;
}

.task-copy-box label {
  display: block;
  margin-bottom: 8px;
  color: #52665a;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.6;
}

.task-copy-box textarea {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 122px;
  padding: 12px;
  border: 1.5px solid #b6c4b4;
  border-radius: 10px;
  background: #fffefa;
  color: #243c35;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.65;
  resize: vertical;
  overflow-wrap: anywhere;
}

.task-copy-box textarea.keyword-field {
  min-height: 54px;
  height: 54px;
  line-height: 1.5;
  resize: none;
}

.copy-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.copy-actions button {
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid #27664c;
  border-radius: 10px;
  background: #27664c;
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.copy-actions button:only-child {
  grid-column: 1 / -1;
}

.copy-actions .minor {
  min-width: 68px;
  border-color: #b6c4b4;
  background: #fffefa;
  color: #243c35;
}

.comment-pending,
.task-heading-note {
  margin: 10px 0 0;
  color: #52665a;
  font-size: 14px;
  line-height: 1.65;
}

.task-tip {
  margin: 14px 0 0;
  padding: 12px;
  border: 1.5px solid #b6c4b4;
  border-radius: 12px;
  background: #f0f4e9;
  color: #52665a;
  font-size: 14px;
  line-height: 1.65;
}

.screenshot-example {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid #b6c4b4;
  border-radius: 12px;
  background: #f3f6ec;
}

.example-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 40px;
  border: 1.5px solid #b6c4b4;
  border-radius: 7px;
  background: #fffefa;
  color: #27664c;
  font-size: 24px;
  line-height: 1;
}

.screenshot-example p {
  min-width: 0;
  margin: 0;
  color: #52665a;
  font-size: 15px;
  line-height: 1.65;
}

.upload-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 164px;
  padding: 20px 12px;
  border: 2px dashed #27664c;
  border-radius: 14px;
  background: #f0f6e9;
  color: #27664c;
  cursor: pointer;
  text-align: center;
}

.upload-box > span {
  display: block;
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1;
}

.upload-box strong {
  font-size: 16px;
  font-weight: 750;
  line-height: 1.5;
}

.upload-box small {
  display: block;
  margin-top: 8px;
  color: #52665a;
  font-size: 14px;
  line-height: 1.6;
}

.upload-box:focus-within {
  outline: 3px solid #27664c;
  outline-offset: 3px;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  clip-path: inset(50%);
}

.upload-full {
  border-style: solid;
  background: #edf2e6;
  cursor: default;
}

.shot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 12px 0 0;
  color: #243c35;
  font-size: 14px;
  line-height: 1.5;
}

#shotCount {
  font-weight: 700;
}

.local-badge {
  color: #52665a;
  font-size: 14px;
}

.shot-previews {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.shot-previews:empty {
  display: none;
}

.shot-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1.5px solid #b6c4b4;
  border-radius: 12px;
  background: #f7f8f0;
}

.shot-item > img {
  width: 56px;
  height: 72px;
  border: 1px solid #b6c4b4;
  border-radius: 6px;
  background: #fffefa;
  object-fit: contain;
}

.shot-item > span {
  min-width: 0;
  margin: 0;
  color: #243c35;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}

.remove-shot {
  position: static;
  display: grid;
  place-items: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border: 1.5px solid #b6c4b4;
  border-radius: 12px;
  background: #fffefa;
  color: #243c35;
  font-size: 28px;
  line-height: 1;
}

.shot-error {
  margin: 12px 0;
  padding: 12px;
  border: 1.5px solid #a66a57;
  border-radius: 12px;
  background: #fff2ec;
  color: #813d2b;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.shot-check-status {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #8eae83;
  border-radius: 12px;
  background: #edf5e6;
  color: #315c36;
  font-size: 14px;
  line-height: 1.7;
}

.task-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  margin-top: 0;
  padding: 13px 12px;
  border: 1.5px solid #27664c;
  border-radius: 12px;
  background: #27664c;
  color: #fff;
  box-shadow: 0 3px 8px #27664c18;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.45;
  white-space: normal;
  transform: none;
}

.task-dialog .task-submit:disabled {
  border-color: #b6c4b4;
  background: #e4eadf;
  color: #52665a;
  box-shadow: none;
  opacity: 1;
  cursor: not-allowed;
}

.task-limit {
  margin: 12px 2px 0;
  color: #52665a;
  font-size: 14px;
  line-height: 1.65;
}

.task-close-line {
  margin: 18px 2px 2px;
  color: #52665a;
  font-size: 14px;
  line-height: 1.65;
  text-align: left;
}

/* This toast is a dialog child, so it is visible above the modal body. */
#taskToast {
  position: absolute;
  z-index: 10;
  right: 12px;
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 12px;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid #52665a;
  border-radius: 12px;
  background: #203b2f;
  color: #fff;
  box-shadow: 0 6px 24px #172e3540;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
  transform: none;
}

/* The receipt badge also belongs to the task flow. */
.completed-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-bottom: 16px;
  padding: 7px 12px;
  border: 1px solid #b6c4b4;
  border-radius: 10px;
  background: #e8f0e4;
  color: #27664c;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
}

.completed-badge::before {
  content: '✓';
}

@media (hover: hover) {
  .task-dialog .close-dialog:hover,
  .platform:hover,
  .copy-actions .minor:hover,
  .remove-shot:hover {
    border-color: #27664c;
    background: #e8f0e4;
  }

  .copy-actions button:not(.minor):hover,
  .task-dialog .task-submit:not(:disabled):hover {
    border-color: #1e513c;
    background: #1e513c;
  }
}

.task-dialog .close-dialog:active,
.platform:active,
.copy-actions .minor:active,
.remove-shot:active {
  border-color: #27664c;
  background: #e0eadb;
}

.copy-actions button:not(.minor):active,
.task-dialog .task-submit:not(:disabled):active {
  background: #1e513c;
}

@media (min-width: 640px) {
  .task-dialog {
    height: min(900px, calc(100vh - 48px));
    height: min(900px, calc(100dvh - 48px));
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    margin: 24px auto;
    border-radius: 22px;
  }

  .task-dialog-top {
    padding: 16px 18px;
  }

  .task-body {
    padding: 18px 16px 28px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .task-step {
    padding: 18px 16px;
  }
}
