/* Liquid Glass V8 · daily instruction inbox */
.instruction-trigger {
  gap: .55rem;
  min-height: 3.15rem;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.instruction-trigger svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.instruction-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  visibility: hidden;
  opacity: 0;
  transition: opacity 180ms ease, visibility 180ms step-end;
}

.instruction-modal.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity 180ms ease, visibility 0ms step-start;
}

.instruction-modal__scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(17, 24, 39, .28);
  backdrop-filter: blur(.55rem) saturate(105%);
  -webkit-backdrop-filter: blur(.55rem) saturate(105%);
  cursor: default;
}

.instruction-sheet {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(48rem, 100%);
  max-height: min(48rem, calc(100dvh - 2.5rem));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 2rem;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .88), rgba(246, 249, 255, .72)),
    rgba(248, 250, 255, .78);
  box-shadow:
    0 2rem 5rem rgba(38, 63, 100, .22),
    inset 0 1px 0 rgba(255, 255, 255, .94),
    inset 0 -1px 0 rgba(111, 141, 184, .12);
  backdrop-filter: blur(2.1rem) saturate(132%);
  -webkit-backdrop-filter: blur(2.1rem) saturate(132%);
  transform: translateY(.8rem) scale(.985);
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1);
}

.instruction-modal.is-open .instruction-sheet {
  transform: translateY(0) scale(1);
}

.instruction-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.6rem 1.1rem;
  border-bottom: 1px solid rgba(106, 126, 155, .12);
}

.instruction-sheet__head h2 {
  margin: .12rem 0 .25rem;
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  letter-spacing: -.035em;
}

.instruction-sheet__head p:last-child {
  margin: 0;
  color: var(--soft);
  font-size: .9rem;
}

.instruction-sheet__close {
  display: grid;
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 1px solid rgba(105, 125, 153, .13);
  border-radius: 50%;
  background: rgba(255, 255, 255, .54);
  color: var(--text);
  cursor: pointer;
  font-size: 1.65rem;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .82);
}

.instruction-compose {
  min-height: 0;
  overflow: auto;
  padding: 1.25rem 1.6rem 1rem;
}

.rich-toolbar {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem;
  border: 1px solid rgba(101, 124, 157, .13);
  border-bottom: 0;
  border-radius: 1rem 1rem 0 0;
  background: rgba(248, 250, 255, .58);
}

.rich-toolbar > span {
  width: 1px;
  height: 1.4rem;
  margin: 0 .1rem;
  background: rgba(96, 116, 145, .16);
}

.rich-toolbar button {
  min-width: 2.35rem;
  min-height: 2.25rem;
  padding: 0 .65rem;
  border: 0;
  border-radius: .72rem;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
}

.rich-toolbar button:hover,
.rich-toolbar button:focus-visible {
  background: rgba(10, 132, 255, .09);
  color: #0875db;
  outline: none;
}

.instruction-editor {
  min-height: 9.5rem;
  padding: 1rem 1.05rem;
  overflow-wrap: anywhere;
  border: 1px solid rgba(101, 124, 157, .16);
  border-radius: 0 0 1rem 1rem;
  background: rgba(255, 255, 255, .58);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.72;
  outline: none;
  box-shadow: inset 0 1px .45rem rgba(59, 78, 106, .035);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.instruction-editor:empty::before {
  color: #9098a4;
  content: attr(data-placeholder);
  pointer-events: none;
}

.instruction-editor:focus,
.instruction-editor.is-dragging {
  border-color: rgba(10, 132, 255, .48);
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 0 0 .23rem rgba(10, 132, 255, .11);
}

.instruction-editor blockquote,
.instruction-history__content blockquote {
  margin: .55rem 0;
  padding-left: .8rem;
  border-left: .18rem solid rgba(10, 132, 255, .48);
  color: var(--soft);
}

.instruction-editor p,
.instruction-editor ul,
.instruction-editor ol,
.instruction-history__content p,
.instruction-history__content ul,
.instruction-history__content ol {
  margin: .25rem 0;
}

.instruction-attachments {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: .9rem;
  padding: .85rem 0;
}

.instruction-attachments > div {
  display: grid;
  gap: .15rem;
  margin-right: auto;
}

.instruction-attachments span {
  color: var(--soft);
  font-size: .78rem;
}

.instruction-file-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .55rem;
}

.instruction-file {
  position: relative;
  min-width: 0;
  margin: 0;
}

.instruction-file img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(103, 127, 160, .14);
  border-radius: .85rem;
  background: rgba(255, 255, 255, .52);
}

.instruction-file figcaption {
  margin-top: .28rem;
  overflow: hidden;
  color: var(--soft);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instruction-file button {
  position: absolute;
  top: .28rem;
  right: .28rem;
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 50%;
  background: rgba(25, 31, 43, .72);
  color: #fff;
  cursor: pointer;
  font-size: 1.05rem;
}

.instruction-status {
  min-height: 1.25rem;
  margin: .65rem 0 0;
  color: var(--soft);
  font-size: .82rem;
}

.instruction-status[data-type="error"] {
  color: #d83a32;
}

.instruction-status[data-type="success"] {
  color: #24863a;
}

.instruction-history {
  padding: 0 1.6rem 1rem;
  border-top: 1px solid rgba(106, 126, 155, .1);
}

.instruction-history__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 0 .65rem;
}

.instruction-history__head h3 {
  margin: 0;
  font-size: .95rem;
}

.instruction-history__head > span {
  color: var(--soft);
  font-size: .72rem;
}

.instruction-history__list {
  display: grid;
  max-height: 10rem;
  gap: .55rem;
  overflow: auto;
}

.instruction-history__item {
  padding: .75rem .85rem;
  border: 1px solid rgba(104, 128, 160, .12);
  border-radius: 1rem;
  background: rgba(255, 255, 255, .45);
}

.instruction-history__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .35rem;
  color: var(--soft);
  font-size: .72rem;
}

.instruction-badge {
  padding: .2rem .48rem;
  border-radius: 999px;
  background: rgba(255, 149, 0, .1);
  color: #b56600;
}

.instruction-badge--applied {
  background: rgba(52, 199, 89, .1);
  color: #267c3c;
}

.instruction-history__content {
  color: var(--text);
  font-size: .86rem;
  line-height: 1.55;
}

.instruction-history__images {
  display: flex;
  gap: .35rem;
  margin-top: .55rem;
}

.instruction-history__images img {
  width: 3.3rem;
  height: 3.3rem;
  object-fit: cover;
  border-radius: .65rem;
}

.instruction-history__empty {
  margin: .2rem 0;
  color: var(--soft);
  font-size: .84rem;
}

.instruction-sheet__actions {
  display: flex;
  justify-content: flex-end;
  gap: .65rem;
  padding: .9rem 1.6rem 1.25rem;
  border-top: 1px solid rgba(106, 126, 155, .12);
}

.instruction-sheet__actions .action {
  min-width: 7.25rem;
}

body.instruction-open {
  overflow: hidden;
}

:root[data-theme="dark"] .instruction-modal__scrim {
  background: rgba(0, 0, 0, .52);
}

:root[data-theme="dark"] .instruction-sheet {
  border-color: rgba(210, 230, 255, .16);
  background:
    linear-gradient(145deg, rgba(32, 41, 56, .93), rgba(15, 20, 29, .9)),
    rgba(15, 20, 29, .9);
  box-shadow:
    0 2rem 5rem rgba(0, 0, 0, .5),
    inset 0 1px 0 rgba(255, 255, 255, .12);
}

:root[data-theme="dark"] .instruction-sheet__head,
:root[data-theme="dark"] .instruction-history,
:root[data-theme="dark"] .instruction-sheet__actions {
  border-color: rgba(210, 230, 255, .09);
}

:root[data-theme="dark"] .instruction-sheet__close,
:root[data-theme="dark"] .rich-toolbar,
:root[data-theme="dark"] .instruction-editor,
:root[data-theme="dark"] .instruction-history__item {
  border-color: rgba(210, 230, 255, .11);
  background: rgba(7, 11, 18, .42);
  color: var(--text);
}

:root[data-theme="dark"] .instruction-editor:focus,
:root[data-theme="dark"] .instruction-editor.is-dragging {
  border-color: rgba(74, 163, 255, .52);
  background: rgba(7, 11, 18, .7);
}

:root[data-theme="dark"] .rich-toolbar button {
  color: #bac5d5;
}

:root[data-theme="dark"] .instruction-status[data-type="success"] {
  color: #6edc83;
}

:root[data-theme="dark"] .instruction-status[data-type="error"] {
  color: #ff8179;
}

:root[data-theme="dark"] .instruction-badge {
  background: rgba(255, 159, 10, .13);
  color: #ffc46b;
}

:root[data-theme="dark"] .instruction-badge--applied {
  background: rgba(50, 215, 75, .12);
  color: #7ee38e;
}

@media (max-width: 39rem) {
  .instruction-trigger {
    min-width: 0;
    padding-inline: .9rem;
  }

  .instruction-modal {
    align-items: end;
    padding: 0;
  }

  .instruction-sheet {
    width: 100%;
    max-height: calc(100dvh - .75rem);
    border-radius: 1.65rem 1.65rem 0 0;
    transform: translateY(1.25rem);
  }

  .instruction-sheet__head {
    padding: 1.15rem 1rem .85rem;
  }

  .instruction-sheet__head p:last-child {
    max-width: 17rem;
  }

  .instruction-compose {
    padding: 1rem;
  }

  .rich-toolbar {
    overflow-x: auto;
  }

  .rich-toolbar button {
    flex: 0 0 auto;
    min-height: 2.75rem;
  }

  .instruction-editor {
    min-height: 8.5rem;
  }

  .instruction-attachments {
    align-items: flex-start;
  }

  .instruction-attachments span {
    max-width: 12rem;
  }

  .instruction-file-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .instruction-history {
    padding: 0 1rem .8rem;
  }

  .instruction-history__head {
    align-items: flex-start;
    flex-direction: column;
    gap: .2rem;
  }

  .instruction-history__list {
    max-height: 7.5rem;
  }

  .instruction-sheet__actions {
    padding: .8rem 1rem calc(.9rem + env(safe-area-inset-bottom));
  }

  .instruction-sheet__actions .action {
    flex: 1;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .instruction-modal,
  .instruction-sheet {
    transition: none;
  }
}

/* V9 · compact batch picker + inline instruction images */
.history-select-wrap {
  position: relative;
}

select.history-list {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  margin: 0;
  padding: .72rem 3rem .72rem .9rem;
  overflow: hidden;
  border: 1px solid rgba(103, 128, 162, .18);
  border-radius: 1rem;
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .74), rgba(241, 246, 254, .54)),
    rgba(255, 255, 255, .52);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .86),
    0 .35rem 1.1rem rgba(45, 70, 105, .07);
}

select.history-list:focus-visible {
  border-color: rgba(10, 132, 255, .48);
  outline: none;
  box-shadow:
    0 0 0 .23rem rgba(10, 132, 255, .11),
    inset 0 1px 0 rgba(255, 255, 255, .86);
}

.history-select-wrap > svg {
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 1.15rem;
  height: 1.15rem;
  pointer-events: none;
  fill: none;
  stroke: var(--soft);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transform: translateY(-50%);
}

@media (min-width: 54rem) {
}

:root[data-theme="dark"] select.history-list {
  border-color: rgba(210, 230, 255, .13);
  background:
    linear-gradient(145deg, rgba(44, 55, 74, .72), rgba(20, 26, 37, .72)),
    rgba(17, 22, 31, .68);
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .1),
    inset 0 -1px 0 rgba(0, 0, 0, .28);
}

.rich-toolbar select {
  min-height: 2.25rem;
  padding: 0 1.65rem 0 .62rem;
  border: 0;
  border-radius: .72rem;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
}

.rich-toolbar select:focus-visible {
  background: rgba(10, 132, 255, .09);
  color: #0875db;
  outline: none;
}

.instruction-inline-image {
  position: relative;
  width: min(30rem, 82%);
  margin: .8rem 0;
}

.instruction-inline-image img {
  display: block;
  width: 100%;
  max-height: 22rem;
  object-fit: contain;
  object-position: left center;
  border: 1px solid rgba(103, 128, 160, .16);
  border-radius: .8rem;
  background: rgba(255, 255, 255, .36);
}

.instruction-inline-image figcaption {
  margin-top: .25rem;
  overflow: hidden;
  color: var(--soft);
  font-size: .7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instruction-inline-image button {
  position: absolute;
  top: .45rem;
  right: .45rem;
  display: grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 50%;
  background: rgba(20, 25, 34, .76);
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.instruction-history__content .instruction-inline-image {
  width: min(24rem, 88%);
  margin: .55rem 0;
}

:root[data-theme="dark"] .instruction-inline-image img {
  border-color: rgba(210, 230, 255, .11);
  background: rgba(7, 11, 18, .34);
}

@media (max-width: 39rem) {
  .rich-toolbar select,
  .rich-toolbar button {
    min-height: 2.75rem;
  }

  .instruction-inline-image,
  .instruction-history__content .instruction-inline-image {
    width: 100%;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: rgba(0, 0, 0, .22);
    --line-strong: rgba(0, 0, 0, .38);
  }

  .topbar,
  .panel,
  .review-panel,
  .card {
    border-color: rgba(0, 0, 0, .24);
  }
}
