/* Dankon Watch v64: aligned order editor and inline controls. */

.editor {
  width: min(820px, 100%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.editor form {
  min-height: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #565a66 #17181e;
}

.editor form::-webkit-scrollbar {
  width: 10px;
}

.editor form::-webkit-scrollbar-track {
  background: #17181e;
}

.editor form::-webkit-scrollbar-thumb {
  border: 2px solid #17181e;
  border-radius: 99px;
  background: #565a66;
}

.editor form > .field:not(.full) {
  grid-column: span 3;
}

.editor form > .full,
.editor form > .editor-footer {
  grid-column: 1 / -1;
}

.editor form > .format-field,
.editor form > .type-field,
.editor form > .status-field {
  grid-column: span 2;
}

.editor form > .customer-editor-field,
.editor form > .timer-manual-field {
  grid-column: 1 / -1;
}

.customer-editor-row,
.field-control {
  position: relative;
  min-width: 0;
}

.customer-editor-row {
  display: block;
}

.customer-editor-row > input {
  min-width: 0;
  padding-right: 94px;
}

.customer-editor-row:not(:has(.customer-editor-remove)) > input,
.customer-editor-row:not(:has(.customer-editor-add)) > input {
  padding-right: 50px;
}

.customer-editor-row:has(.customer-editor-remove):has(.customer-editor-add) > input {
  padding-right: 94px;
}

.field-trailing-actions {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  display: flex;
  overflow: hidden;
  border-radius: 0 8px 8px 0;
}

.field-trailing-button,
.customer-editor-add,
.customer-editor-remove {
  width: 44px;
  min-width: 44px;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  color: #b7bac3;
  background: #1b1d24;
  cursor: pointer;
}

.field-trailing-button:focus-visible,
.field-trailing-button:hover {
  color: #fff;
  border-color: var(--line);
  background: rgba(232, 59, 63, 0.16);
  outline: 0;
}

.customer-editor-remove,
.customer-editor-remove:hover,
.customer-editor-remove:focus-visible {
  color: #e18487;
}

.estimated-time-control > input {
  padding-right: 56px;
}

.field-trailing-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 44px;
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
  color: #7d8089;
  background: #1b1d24;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
}

.field-trailing-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.field-trailing-toggle .watch-time-check {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid #555966;
  border-radius: 6px;
  background: #121319;
}

.field-trailing-toggle.selected {
  color: #fff;
  background: rgba(232, 59, 63, 0.09);
}

.field-trailing-toggle.selected .watch-time-check {
  border-color: #e83b3f;
  background: #e83b3f;
}

.field-trailing-toggle:focus-within,
.field-trailing-toggle:hover {
  color: #fff;
  background: rgba(232, 59, 63, 0.16);
}

.time-picker-control {
  overflow: hidden;
  border-radius: 9px;
}

.time-picker-control input {
  padding-right: 88px;
}

.time-picker-control input:placeholder-shown {
  padding-right: 52px;
}

.time-picker-toggle {
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 44px;
  height: auto;
  border-left: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: #1b1d24;
  transform: none;
}

.time-picker-clear {
  right: 47px;
}

.date-picker-calendar-button {
  background: #1b1d24;
}

.number-stepper-controls {
  background: #1b1d24;
}

.field-error {
  display: block;
  color: #f07d81;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.field:has(> .field-error) > input,
.field:has(> .field-error) > textarea,
.field:has(> .field-error) .field-control > input,
.field:has(> .field-error) .number-stepper > input,
.field:has(> .field-error) .time-picker-control > input,
.field:has(> .field-error) .cover-url-field > input,
.field:has(> .field-error) .source-url-field > input,
.field:has(> .field-error) .date-picker-trigger {
  border-color: rgba(232, 59, 63, 0.72);
}

.editor-footer {
  position: relative;
  z-index: 65;
  margin: 0;
  padding: 14px 26px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(27, 29, 36, 0.97);
  box-shadow: 0 -13px 28px rgba(10, 11, 15, 0.28);
  backdrop-filter: blur(14px);
}

html[data-theme="light"] .field-trailing-button,
html[data-theme="light"] .field-trailing-toggle,
html[data-theme="light"] .time-picker-toggle,
html[data-theme="light"] .date-picker-calendar-button,
html[data-theme="light"] .number-stepper-controls,
html[data-theme="light"] .number-stepper-controls button {
  color: #666c77;
  background: #eef0f4;
}

html[data-theme="light"] .field-trailing-toggle .watch-time-check {
  border-color: #c9cdd5;
  background: #fff;
}

html[data-theme="light"] .field-trailing-toggle.selected .watch-time-check {
  border-color: #e83b3f;
  color: #fff;
  background: #e83b3f;
}

html[data-theme="light"] .editor-footer {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 -13px 28px rgba(28, 31, 39, 0.1);
}

@media (max-width: 760px) {
  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .editor {
    max-height: calc(100dvh - 20px);
    border-radius: 18px;
  }

  .editor form {
    grid-template-columns: minmax(0, 1fr);
    padding: 18px;
    gap: 17px;
  }

  .editor form > .field:not(.full),
  .editor form > .format-field,
  .editor form > .type-field,
  .editor form > .status-field,
  .editor form > .full,
  .editor form > .editor-footer {
    grid-column: 1;
  }

  .editor-footer {
    margin: 0;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  }

  .customer-editor-row > input {
    padding-right: 94px;
  }
}

@media (max-width: 480px) {
  .editor-footer-actions {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  }

  .editor-footer .secondary-button,
  .editor-footer .primary-button {
    min-width: 0;
    padding-right: 11px;
    padding-left: 11px;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .editor-footer {
    backdrop-filter: none;
  }
}
