.modal > div,
.modal > form { position: relative; }

.modal > div {
  width: min(100%, 1120px);
  max-height: 94vh;
  overflow: auto;
  padding: 30px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 70px #102c1f45;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 8;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #c9d9cd;
  border-radius: 50%;
  background: #fff;
  color: #274634;
  font: 700 24px/1 Arial, sans-serif;
  text-decoration: none;
  box-shadow: 0 6px 16px #1937281f;
}

.close:hover,
.close:focus-visible { background: #e9f3eb; color: #173126; outline: 3px solid #5281652b; }

.gallery-filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 18px 0; padding: 14px; border: 1px solid #dfe8e1; border-radius: 15px; background: #f7faf7; }
.gallery-filters label { font: 700 12px Arial, sans-serif; color: #526258; }
.gallery-filters input, .gallery-filters select { display: block; width: 100%; height: 40px; margin-top: 6px; padding: 0 9px; border: 1px solid #dbe5dd; border-radius: 10px; background: #fff; color: #304238; }
.gallery-export-bar { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin: -7px 0 4px; }
.gallery-export-bar .hint { margin: 0 auto 0 0; }
.gallery-export-bar button { width: auto; }
.gallery-export-bar button:disabled { cursor: not-allowed; opacity: .55; }
#gallery-export-form { display: block; width: 100%; max-width: none; max-height: none; overflow: visible; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.gallery-card { position: relative; overflow: hidden; border: 1px solid #dce7de; border-radius: 16px; background: #fff; color: #274634; box-shadow: 0 8px 20px #1937280f; }
.gallery-card.selected { border-color: #28634d; box-shadow: 0 0 0 3px #28634d22, 0 8px 20px #1937280f; }
.gallery-card[hidden] { display: none !important; }
.gallery-preview { display: block; color: inherit; text-decoration: none; }
.gallery-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #edf3ee; }
.gallery-caption { display: grid; gap: 4px; padding: 12px; }
.gallery-card b, .gallery-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-select { position: absolute; z-index: 3; top: 9px; right: 9px; display: grid; width: 35px; height: 35px; place-items: center; border-radius: 50%; background: #fffffff2; box-shadow: 0 4px 14px #1937282b; cursor: pointer; }
.gallery-select input { width: 17px; height: 17px; accent-color: #28634d; }
.gallery-favorite { position: absolute; z-index: 4; top: 9px; left: 9px; display: grid; width: 35px; height: 35px; place-items: center; border: 0; border-radius: 50%; background: #fffffff2; color: #7f3048; font: 700 20px/1 Arial, sans-serif; box-shadow: 0 4px 14px #1937282b; cursor: pointer; }
.gallery-favorite:hover { background: #fbeef2; }
.gallery-favorite.active { background: #a94862; color: #fff; }
.gallery-favorite:disabled { cursor: not-allowed; opacity: .55; }
.gallery-favorites-filter.active { border-color: #a94862; background: #a94862; color: #fff; }
.gallery-document { display: grid; min-height: 170px; place-items: center; align-content: center; gap: 8px; background: #f4f7f4; color: #9c492d; text-decoration: none; }
.gallery-document span { display: grid; width: 58px; height: 68px; place-items: center; border: 2px solid #d78565; border-radius: 7px; background: #fff; font: 800 14px Arial, sans-serif; }
.gallery-document b { color: #526258; font: 600 12px Arial, sans-serif; }

.gallery-slideshow { position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column; padding: 18px; background: #10241af7; color: #fff; backdrop-filter: blur(10px); }
.gallery-slideshow header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.gallery-slideshow header > span { min-width: 0; overflow: hidden; font: 700 14px/1.4 "DM Sans", Arial, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.gallery-slideshow header > div { display: flex; gap: 5px; }
.gallery-slideshow button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid #ffffff24; border-radius: 12px; background: #ffffff12; color: #fff; font: 700 21px/1 Arial, sans-serif; cursor: pointer; }
.gallery-slideshow button:hover { background: #ffffff24; }
.gallery-slideshow button:disabled { cursor: not-allowed; opacity: .35; }
.gallery-slideshow main { position: relative; display: flex; min-height: 0; flex: 1; align-items: center; justify-content: center; overflow: hidden; border-radius: 22px; background: #0006; touch-action: pan-y; }
.gallery-slideshow img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery-slideshow [data-prev], .gallery-slideshow [data-next] { position: absolute; top: 50%; width: 48px; height: 48px; border-radius: 50%; transform: translateY(-50%); }
.gallery-slideshow [data-prev] { left: 14px; }
.gallery-slideshow [data-next] { right: 14px; }
.gallery-slideshow footer { padding-top: 10px; color: #ffffff9c; font: 500 12px/1.4 "DM Sans", Arial, sans-serif; text-align: center; }

.plan-list { display: grid; gap: 12px; margin-top: 16px; }
.plan-card { overflow: hidden; border: 1px solid #dfe8e1; border-radius: 16px; background: #fbfdfb; }
.plan-current { display: flex; align-items: center; gap: 10px; padding: 13px; }
.plan-current > div { min-width: 0; flex: 1; }
.plan-current b, .plan-current small, .plan-current em { display: block; }
.plan-current b { overflow: hidden; color: #2a4031; font: 700 14px Arial, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.plan-current small { margin-top: 3px; color: #75867b; font: 12px Arial, sans-serif; }
.plan-current em { width: max-content; margin-top: 5px; padding: 3px 7px; border-radius: 999px; background: #eaf3ec; color: #28634d; font: 700 10px Arial, sans-serif; font-style: normal; }
.plan-icon { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 10px; background: #fce9e2; color: #c05d36; }
.plan-history, .plan-new-version { margin: 0 12px 12px; border: 1px solid #e2ebe4; border-radius: 11px; background: #fff; }
.plan-history summary, .plan-new-version summary { padding: 10px 12px; color: #52665a; font: 700 12px Arial, sans-serif; cursor: pointer; }
.plan-history > div, .plan-new-version form { padding: 9px; border-top: 1px solid #e7ede8; }
.plan-version { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 9px; }
.plan-version:hover { background: #f5f8f5; }
.plan-version > span { display: grid; width: 31px; height: 31px; flex: 0 0 31px; place-items: center; border-radius: 8px; background: #edf3ee; color: #28634d; font: 700 11px Arial, sans-serif; }
.plan-version > div { min-width: 0; flex: 1; }
.plan-version b, .plan-version small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-version b { color: #344b3b; font: 600 12px Arial, sans-serif; }
.plan-version small { margin-top: 2px; color: #7c897f; font: 11px Arial, sans-serif; }
.plan-version > a:not(.download) { color: #28634d; font: 700 11px Arial, sans-serif; }

@media (max-width: 1000px) { .gallery-filters { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 850px) { .gallery-filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .plan-current { align-items: flex-start; flex-wrap: wrap; } .plan-current > div { width: calc(100% - 50px); flex: none; } .plan-current .button-outline { margin-left: 45px; } .plan-version { flex-wrap: wrap; } }
@media (max-width: 520px) { .gallery-grid, .gallery-filters { grid-template-columns: 1fr; } .gallery-export-bar { align-items: stretch; } .gallery-export-bar .hint { width: 100%; } .gallery-export-bar button { flex: 1; } .close { top: 10px; right: 10px; } .modal > div { max-height: 93vh; padding: 25px; border-radius: 24px 24px 0 0; } .gallery-slideshow { padding: 10px; } .gallery-slideshow header > span { max-width: 42vw; } .gallery-slideshow footer { font-size: 10px; } }

/* Release 1.10.0: AI caption feedback and bulk image assignments. */
.ai-caption-status { display:block; grid-column:2; margin-top:2px; font-size:11px; line-height:1.4; color:#527661; }
.ai-caption-status[data-state="ready"] { color:#2f6a48; }
.ai-caption-status[data-state="error"] { color:#9a573d; }
.gallery-bulk-assignment { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(150px,1fr) minmax(150px,1fr) auto; align-items:end; gap:10px; margin:10px 0 16px; padding:13px; border:1px solid #cfe0d2; border-radius:14px; background:#f4f9f5; }
.gallery-bulk-assignment > div { display:grid; gap:3px; }
.gallery-bulk-assignment b { color:#31553c; font:700 12px Arial,sans-serif; }
.gallery-bulk-assignment small { color:#687a6d; font-size:11px; line-height:1.35; }
.gallery-bulk-assignment label { display:grid; gap:4px; color:#48614f; font:700 11px Arial,sans-serif; }
.gallery-bulk-assignment select { height:36px; min-width:0; border:1px solid #ccdbcf; border-radius:9px; background:#fff; padding:0 8px; color:#294132; font:12px Arial,sans-serif; }
.gallery-bulk-assignment .primary { min-height:36px; white-space:nowrap; }
@media (max-width:720px) { .gallery-bulk-assignment { grid-template-columns:1fr 1fr; } .gallery-bulk-assignment > div { grid-column:1/-1; } .gallery-bulk-assignment .primary { grid-column:1/-1; } .ai-caption-status { grid-column:1/-1; } }

/* Release 1.10.2: bounded, per-image AI phase assignment for the current gallery selection. */
.gallery-ai-assignment { display:grid; grid-column:1/-1; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px 12px; padding:11px; border:1px solid #d7e7d9; border-radius:11px; background:#fffdfa; }
.gallery-ai-assignment > div { display:grid; gap:3px; }
.gallery-ai-assignment b { color:#31553c; font:700 12px Arial,sans-serif; }
.gallery-ai-assignment small { color:#687a6d; font-size:11px; line-height:1.35; }
.gallery-ai-assignment > button { width:auto; min-height:36px; white-space:nowrap; }
.gallery-ai-assignment-status { grid-column:1/-1; min-height:15px; color:#496e54 !important; font-weight:600; }
@media (max-width:720px) { .gallery-ai-assignment { grid-template-columns:1fr; } .gallery-ai-assignment > button { width:100%; } }

/* Release 1.10.3: phase-gap filter sits with the responsive gallery fields. */
.gallery-unassigned-phase-filter {
  display: flex !important;
  align-items: center;
  gap: .45rem;
  min-height: 2.5rem;
  padding: .45rem .7rem;
  border: 1px solid #d8e4da;
  border-radius: .75rem;
  background: #f7fbf7;
  color: #385642 !important;
  font-size: .78rem !important;
  cursor: pointer;
}
.gallery-unassigned-phase-filter input { width: auto !important; height: auto !important; margin: 0 !important; accent-color: #28634d; }

/* Release 1.11.1: inherited entry metadata remains visible but is clearly distinct from individual image assignments. */
.gallery-caption .gallery-assignment-gap { margin-top: 4px; color: #a85d2d; font-weight: 700; }
