.cr-edit-workbench {
  --cr-edit-accent: var(--prediction);
  width: min(570px, calc(100vw - 32px));
  max-width: none;
  height: min(820px, calc(100svh - 32px));
  max-height: none;
  margin: auto 16px auto auto;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--cr-edit-accent) 52%, transparent);
  border-radius: 0;
  background: #071019;
  color: var(--text);
  box-shadow: -28px 0 90px rgba(0, 0, 0, .62);
  overflow: hidden;
}

.cr-edit-workbench.is-official {
  --cr-edit-accent: var(--actual);
}

.cr-edit-workbench::backdrop {
  background: rgba(1, 5, 9, .68);
  backdrop-filter: blur(5px);
}

.cr-edit-workbench[open] {
  display: block;
}

.cr-edit-form {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--cr-edit-accent) 7%, transparent), transparent 38%),
    #071019;
}

.cr-edit-head {
  position: static;
  z-index: auto;
  inset: auto;
  width: auto;
  height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: start;
  justify-content: initial;
  flex-direction: initial;
  gap: 20px;
  padding: 26px 28px 22px;
  border-bottom: 1px solid color-mix(in srgb, var(--cr-edit-accent) 25%, transparent);
  background: transparent;
  backdrop-filter: none;
}

.cr-edit-kind {
  margin: 0 0 8px;
  color: var(--cr-edit-accent);
  font: 700 12px/1 var(--mono);
  letter-spacing: .16em;
}

.cr-edit-head h2 {
  margin: 0;
  color: var(--text);
  font: 700 30px/1.2 var(--jp);
  letter-spacing: .025em;
}

.cr-edit-intro {
  margin: 10px 0 0;
  color: color-mix(in srgb, var(--muted) 58%, var(--text));
  font: 500 14px/1.65 var(--jp);
}

.cr-edit-close {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(225, 236, 244, .34);
  background: rgba(2, 7, 12, .72);
  color: var(--text);
  font: 300 26px/1 var(--display);
  cursor: pointer;
}

.cr-edit-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 28px 34px;
  scrollbar-color: color-mix(in srgb, var(--cr-edit-accent) 40%, transparent) transparent;
}

.cr-edit-field {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
}

.cr-edit-label,
.cr-edit-date legend {
  color: color-mix(in srgb, var(--cr-edit-accent) 52%, var(--text));
  font: 700 14px/1.4 var(--jp);
  letter-spacing: .035em;
}

.cr-edit-field input,
.cr-edit-field textarea,
.cr-edit-field select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid rgba(225, 236, 244, .36);
  border-radius: 0;
  background: rgba(1, 6, 11, .94);
  color: var(--text);
  padding: 11px 13px;
  font: 500 16px/1.5 var(--jp);
  text-align: left;
  outline: none;
}

.cr-edit-field textarea {
  min-height: 124px;
  resize: vertical;
}

.cr-edit-field input:focus,
.cr-edit-field textarea:focus,
.cr-edit-field select:focus,
.cr-edit-close:focus-visible,
.cr-edit-actions button:focus-visible,
.cr-edit-discard button:focus-visible,
.cr-edit-toast button:focus-visible {
  border-color: var(--cr-edit-accent);
  outline: 2px solid color-mix(in srgb, var(--cr-edit-accent) 48%, transparent);
  outline-offset: 2px;
}

.cr-edit-field input.is-preserved {
  color: color-mix(in srgb, var(--text) 80%, var(--muted));
  background: color-mix(in srgb, var(--cr-edit-accent) 4%, rgba(1, 6, 11, .78));
}

.cr-edit-field.has-error input,
.cr-edit-field.has-error textarea,
.cr-edit-field.has-error select {
  border-color: #ff8d80;
}

.cr-edit-error,
.cr-edit-help {
  min-height: 0;
  color: color-mix(in srgb, var(--muted) 58%, var(--text));
  font: 500 13px/1.5 var(--jp);
}

.cr-edit-error:empty,
.cr-edit-help:empty {
  display: none;
}

.cr-edit-error {
  color: #ff9b90;
}

.cr-edit-date {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  margin: 4px 0 6px;
  padding: 20px;
  border: 1px solid rgba(225, 236, 244, .2);
}

.cr-edit-date legend {
  padding: 0 8px;
}

.cr-edit-date .cr-edit-field {
  margin: 0;
}

.cr-edit-details {
  margin-top: 22px;
  border-top: 1px solid color-mix(in srgb, var(--cr-edit-accent) 20%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--cr-edit-accent) 20%, transparent);
}

.cr-edit-details summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  color: var(--text);
  font: 700 15px/1.4 var(--jp);
  cursor: pointer;
}

.cr-edit-details-grid {
  padding: 4px 0 8px;
}

.cr-edit-workbench:not(.is-official) .cr-edit-official-only,
.cr-edit-workbench.is-official .cr-edit-prediction-only {
  display: none;
}

.cr-edit-feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 58px;
  margin: 0 0 20px;
  padding: 12px 13px;
  border: 1px solid color-mix(in srgb, var(--prediction) 25%, transparent);
  cursor: pointer;
}

.cr-edit-feature input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--prediction);
}

.cr-edit-feature span {
  display: grid;
  gap: 4px;
}

.cr-edit-feature strong {
  font: 700 15px/1.4 var(--jp);
}

.cr-edit-feature small {
  color: color-mix(in srgb, var(--muted) 78%, var(--text));
  font: 500 13px/1.5 var(--jp);
}

.cr-edit-actions {
  position: static;
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid color-mix(in srgb, var(--cr-edit-accent) 25%, transparent);
  background: rgba(3, 9, 15, .96);
}

.cr-edit-actions button {
  min-height: 48px;
  border: 1px solid rgba(225, 236, 244, .3);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 17px;
  font: 700 14px/1.2 var(--jp);
  cursor: pointer;
}

.cr-edit-action-spacer {
  flex: 1;
}

.cr-edit-actions .cr-edit-save {
  min-width: 150px;
  border-color: var(--cr-edit-accent);
  background: var(--cr-edit-accent);
  color: #06111b;
}

.cr-edit-actions .cr-edit-delete {
  color: #ff9b90;
  border-color: rgba(255, 120, 108, .34);
}

.cr-edit-actions .cr-edit-delete:disabled {
  color: rgba(225, 236, 244, .34);
  border-color: rgba(225, 236, 244, .12);
  cursor: default;
}

/* Desktop input is one readable composition: essentials left, optional detail right. */
@media (min-width: 900px) and (min-height: 640px) {
  .cr-edit-workbench {
    width: min(880px, calc(100vw - 32px));
    height: auto;
    max-height: calc(100svh - 32px);
    margin: auto;
  }

  .cr-edit-form {
    height: auto;
  }

  .cr-edit-scroll {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
    align-content: start;
    column-gap: 26px;
    padding: 20px 28px 22px;
  }

  .cr-edit-error-summary {
    grid-column: 1 / -1;
  }

  .cr-edit-scroll > [data-field="title"] {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 18px;
  }

  .cr-edit-date {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: 1fr;
    align-self: start;
    margin: 0;
    padding: 17px;
  }

  .cr-edit-details {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin-top: 0;
    padding: 0 17px;
    border: 1px solid rgba(225, 236, 244, .2);
  }

  .cr-edit-details summary {
    min-height: 48px;
  }

  .cr-edit-details-grid {
    padding-bottom: 0;
  }

  .cr-edit-details-grid .cr-edit-field,
  .cr-edit-feature {
    margin-bottom: 14px;
  }

  .cr-edit-field textarea {
    min-height: 104px;
  }
}

.cr-edit-error-summary {
  margin-bottom: 22px;
  padding: 15px 17px;
  border: 1px solid #ff8d80;
  background: rgba(255, 92, 76, .08);
}

.cr-edit-error-summary strong {
  font: 700 15px/1.4 var(--jp);
}

.cr-edit-error-summary ul {
  margin: 9px 0 0;
  padding-left: 18px;
}

.cr-edit-error-summary button {
  border: 0;
  background: transparent;
  color: #ffb0a7;
  padding: 3px 0;
  font: 600 14px/1.4 var(--jp);
  text-decoration: underline;
  cursor: pointer;
}

.cr-edit-discard {
  position: absolute;
  z-index: 5;
  inset: auto 18px 18px;
  padding: 20px;
  border: 1px solid rgba(225, 236, 244, .4);
  background: #101a24;
  box-shadow: 0 18px 54px rgba(0, 0, 0, .58);
}

.cr-edit-discard strong {
  font: 700 17px/1.4 var(--jp);
}

.cr-edit-discard p {
  margin: 7px 0 16px;
  color: color-mix(in srgb, var(--muted) 72%, var(--text));
  font: 500 14px/1.55 var(--jp);
}

.cr-edit-discard div {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.cr-edit-discard button {
  min-height: 46px;
  border: 1px solid rgba(225, 236, 244, .3);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  font: 700 14px/1.2 var(--jp);
}

.cr-edit-discard [data-discard] {
  border-color: #ff8d80;
  color: #ffb0a7;
}

.cr-edit-toast {
  position: fixed;
  z-index: 10000;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(430px, calc(100vw - 36px));
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 18px;
  border: 1px solid rgba(225, 236, 244, .4);
  background: #e4edf3;
  color: #07111a;
  box-shadow: 0 20px 58px rgba(0, 0, 0, .44);
  font: 700 15px/1.4 var(--jp);
}

.cr-edit-toast span {
  flex: 1;
}

.cr-edit-toast button {
  min-height: 42px;
  border: 1px solid #07111a;
  background: transparent;
  color: #07111a;
  padding: 8px 12px;
  font: 800 14px/1 var(--jp);
  cursor: pointer;
}

/* The manager is already the detail layer: date, content, and actions stay scannable. */
.editor-current-item {
  grid-template-columns: 116px minmax(0, 1fr) 116px;
  gap: 14px;
}

.editor-current-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.editor-current-actions button {
  min-height: 34px;
  padding: 6px 7px;
  font-size: 11px;
}

.editor-current-state,
.editor-inplace-state {
  display: none;
}

/* Placeholder text is guidance, not timeline state. Keep it semantically neutral. */
.prediction-editor.official-mode .editor-quick-add input::placeholder,
.prediction-editor.official-mode .editor-row-form input::placeholder {
  color: color-mix(in srgb, var(--muted) 84%, var(--text) 16%);
  opacity: 1;
}

/* Management density: quiet type, one boundary, and a neutral focus treatment. */
.prediction-editor .editor-list-head h2 {
  font-size: clamp(32px, 3vw, 40px);
}

.prediction-editor .editor-list-head > div > p:last-child {
  font-size: 13px;
}

.prediction-editor .editor-quick-add-toggle > strong {
  font-size: 16px;
}

.prediction-editor .editor-quick-add-toggle > small {
  font-size: 12px;
}

.prediction-editor .editor-quick-add-toggle > span {
  font-size: 24px;
}

.prediction-editor .editor-current-item {
  min-height: 52px;
  padding: 6px 10px;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.prediction-editor:not(.has-inline-edit) .editor-current-entry:not(.is-editing):is(:hover, :focus-within) > .editor-current-item {
  background: rgba(226, 234, 239, .065);
  box-shadow: inset 2px 0 0 rgba(226, 234, 239, .72);
}

.prediction-editor .editor-current-date {
  font-size: 14px;
  line-height: 1.3;
}

.prediction-editor .editor-current-title {
  font-size: 15px;
  line-height: 1.4;
}

.prediction-editor .editor-row-form.editor-row-form-inplace {
  border: 0;
  background: transparent;
}

.prediction-editor .editor-row-form-inplace > .editor-current-item {
  border: 0;
  border-block: 1px solid rgba(190, 203, 212, .2);
  background: rgba(5, 10, 15, .72);
  box-shadow: none;
}

.prediction-editor .editor-row-form-inplace :is(
  .editor-row-date,
  .editor-row-title,
  .editor-row-note,
  .editor-row-source
) {
  min-height: 40px;
  border: 0;
  border-bottom: 1px solid rgba(190, 203, 212, .28);
  background: rgba(1, 6, 10, .38);
  box-shadow: none;
  outline: 0;
  padding: 7px 8px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}

.prediction-editor .editor-row-form-inplace :is(
  .editor-row-date,
  .editor-row-title,
  .editor-row-note,
  .editor-row-source
):focus-visible {
  border-bottom-color: rgba(226, 234, 239, .88);
  border-bottom-width: 2px;
  box-shadow: none;
  outline: 0;
}

.prediction-editor.has-inline-edit .editor-current-entry:not(.is-editing) {
  opacity: .28;
  filter: saturate(.2) brightness(.58);
}

.prediction-editor.has-inline-edit .editor-current-entry.is-editing {
  box-shadow: none;
}

@media (min-width: 761px) {
  .editor-row-form.has-official-details .editor-current-item {
    grid-template-columns:
      132px
      minmax(230px, 1.2fr)
      minmax(180px, 1fr)
      minmax(180px, .85fr)
      116px;
    gap: 10px;
    align-items: end;
  }

  .editor-row-form.has-official-details .editor-row-note-field,
  .editor-row-form.has-official-details .editor-row-source-field {
    grid-column: auto;
    grid-row: auto;
    align-self: end;
  }

  .editor-row-form.has-official-details .editor-row-note,
  .editor-row-form.has-official-details .editor-row-source {
    min-height: 40px;
  }

  .editor-row-form.has-official-details .editor-row-field small {
    display: none;
  }
}

@media (max-width: 760px) {
  .cr-edit-workbench {
    inset: 0;
    width: 100vw;
    height: 100svh;
    margin: 0;
    border: 0;
  }

  .cr-edit-head {
    grid-template-columns: minmax(0, 1fr) 48px;
    padding: calc(18px + env(safe-area-inset-top)) 18px 17px;
  }

  .cr-edit-head h2 {
    font-size: 25px;
  }

  .cr-edit-scroll {
    padding: 22px 18px 30px;
  }

  .cr-edit-date {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 17px;
  }

  .cr-edit-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  }

  .cr-edit-action-spacer {
    display: none;
  }

  .cr-edit-actions .cr-edit-delete {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .cr-edit-actions .cr-edit-save {
    min-width: 0;
  }

  .cr-edit-discard {
    inset: auto 12px calc(12px + env(safe-area-inset-bottom));
  }

  .editor-current-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px 12px;
    padding: 16px 14px;
  }

  .editor-current-date {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    font-size: 14px;
    text-align: left;
  }

  .editor-current-state {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    min-width: 0;
    padding: 6px 8px;
    font-size: 12px;
  }

  .editor-current-title {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    font-size: 16px;
    line-height: 1.5;
    text-align: left;
  }

  .editor-current-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .editor-current-actions button {
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .editor-row-form.has-official-details .editor-current-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .editor-row-form.has-official-details :is(
    .editor-inplace-date,
    .editor-inplace-title,
    .editor-row-note-field,
    .editor-row-source-field,
    .editor-row-actions
  ) {
    grid-column: 1;
    grid-row: auto;
  }

  .editor-quick-add-toggle {
    min-height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cr-edit-workbench::backdrop {
    backdrop-filter: none;
  }
}
