/* إثراء المعجم: the four-step contribution wizard and its thank-you screen.
   Sizes follow the 1440px design;
   in this file the cards count their stroke on top of the padding, the form
   controls draw it inside. */

/* The banner shows the hero photo (960 x 422, covering the strip and centred) under an even veil. */
.page-header {
  --page-header-image: url('../img/add/header.jpg');
  --page-header-top: -86.42%;
  --page-header-height: 272.85%;
  --page-header-veil: rgba(9, 42, 30, 0.8);
}

/* Page colours that the shell tokens do not cover (the dialogs sit outside <main>). */
body {
  --field-border: #9da4ae;
  --field-text: #384250;
  --danger: #b42318;
}

.add {
  padding-bottom: 66px;
}

/* A long unbroken value (a pasted name, a link) wraps instead of widening the page. */
.add,
.add-dialog {
  overflow-wrap: break-word;
}

.preview-banner__lead,
.preview-banner__text,
.local-names__item > span,
.tags__item,
.tags__item > span,
.preview-head__tags li,
.draft__open > span {
  min-width: 0;
  max-width: 100%;
}

.add--done {
  padding-bottom: 56px;
}

.add__wizard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Links and small controls ---------- */
.add-link {
  /* Chrome sets 14px text 1px higher than the design does. */
  position: relative;
  top: 1px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green-600);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
}

.add-link:hover {
  color: var(--green-700);
  text-decoration: underline;
}

.add-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  min-height: 20px;
}

/* These two lines are long: they wrap on a narrow or zoomed screen. */
.add-top .add-link,
.submit-card__captcha .add-link {
  white-space: normal;
  text-align: start;
}

.add-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 16px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-surface-subtle);
}

.add-notice__text {
  flex: 1 1 200px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.add-notice__close {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.add-notice__close:hover {
  background: var(--green-100);
}

.add-gate {
  margin-bottom: -8px;
}

.add-status {
  margin-top: -8px;
  color: var(--danger);
  font-size: 14px;
  line-height: 20px;
}

/* The design's arrow is a down arrow turned to point left (forward in Arabic). */
.add-arrow {
  flex: none;
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: url('../img/ui/i-arrow-right-02.svg') center / 11.5px 17.5px no-repeat;
  mask: url('../img/ui/i-arrow-right-02.svg') center / 11.5px 17.5px no-repeat;
  transform: rotate(90deg);
}

.add-arrow--back {
  transform: rotate(-90deg);
}

/* Remove buttons: the design's thin grey cross, 13 x 20 with a larger hit area. */
.chip-x,
.uploader__remove {
  position: relative;
  flex: none;
  width: 13px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.chip-x::before,
.uploader__remove::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  -webkit-mask: url('../img/add/close.svg') center / var(--cross, 10px) no-repeat;
  mask: url('../img/add/close.svg') center / var(--cross, 10px) no-repeat;
}

.chip-x::after,
.uploader__remove::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.chip-x:hover,
.uploader__remove:hover {
  color: var(--text-default);
}

.add-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--green-200);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: add-spin 0.8s linear infinite;
}

.add-spinner--sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

@keyframes add-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Step progress ---------- */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
}

.stepper__meta {
  align-self: flex-end;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

ol.stepper__steps {
  display: flex;
  align-items: flex-start;
  margin: 0;
  padding: 6px 0 2px;
  list-style: none;
}

.stepper__step {
  flex: 0 1 200px;
  min-width: 0;
}

.stepper__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-secondary);
  font-family: var(--font);
  text-align: center;
  cursor: pointer;
}

.stepper__node {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--bg-white);
  /* The design draws the node's stroke outside its 36px box. */
  box-shadow: 0 0 0 1.5px var(--border);
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
}

.stepper__label {
  max-width: 100%;
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
}

.stepper__sub {
  max-width: 100%;
  font-size: 12px;
  line-height: 18px;
}

.stepper__step.is-current .stepper__node {
  background: var(--green-600);
  box-shadow: 0 0 0 4px var(--green-200);
  color: #fff;
}

.stepper__step.is-current .stepper__label {
  color: var(--text-default);
  font-weight: 700;
}

.stepper__step.is-done .stepper__node {
  background: var(--green-600);
  box-shadow: 0 0 0 1.5px var(--green-600);
}

.stepper__step.is-done .stepper__label {
  color: var(--text-default);
}

.stepper__line {
  flex: 1 0 16px;
  height: 3px;
  margin-top: 17px;
  border-radius: 2px;
  background: var(--border);
}

.stepper__line.is-done {
  background: var(--green-600);
}

/* ---------- Form card and fields ---------- */
.add-form {
  display: contents;
}

.add-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
}

.add-card[hidden] {
  display: none;
}

.add-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.add-row > * {
  flex: 1 1 0;
  min-width: 0;
}

.fld {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.fld__label {
  /* Chrome sets 14px text 1px higher than the design does. */
  position: relative;
  top: 1px;
  display: flex;
  align-self: flex-start;
  gap: 4px;
  color: var(--text-default);
  font-size: 14px;
  line-height: 20px;
}

.fld__req {
  color: var(--danger);
}

.fld__control {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 16px 0 8px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-white);
  color: var(--field-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  text-align: right;
}

.fld__control::placeholder,
.local-names__input::placeholder,
.tags__input::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

.fld__control[readonly] {
  background-color: var(--bg-neutral);
}

textarea.fld__control {
  height: 96px;
  min-height: 96px;
  padding: 11px 16px 12px;
  /* The design's grip sits inside the corner; the native one is hidden. */
  background: var(--bg-white) url('../img/add/resize-handler.svg') left 2px bottom 2px / 12px 12px
    no-repeat;
  resize: vertical;
}

textarea.fld__control::-webkit-resizer {
  background: transparent;
}

input[type='search'].fld__control {
  -webkit-appearance: none;
  appearance: none;
}

select.fld__control {
  padding: 0 16px 0 40px;
  background-image: url('../img/add/chevron.svg');
  background-repeat: no-repeat;
  background-position: left 20.4px center;
  background-size: 11.25px 6.25px;
  color: var(--text-secondary);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.fld__control[aria-invalid='true'] {
  border-color: var(--danger);
}

.fld__error {
  color: var(--danger);
  font-size: 13px;
  line-height: 20px;
}

.fld__box {
  position: relative;
}

.fld__box .fld__control {
  padding-right: 44px;
}

.fld__mic {
  position: absolute;
  top: 10px;
  right: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.fld__mic::after,
.local-names__mic::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.fld__mic[aria-pressed='true'],
.local-names__mic[aria-pressed='true'] {
  outline: 2px solid var(--green-400);
  outline-offset: 2px;
}

.fld__removable {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fld__helper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-paragraph);
  font-size: 14px;
  line-height: 20px;
}

.fld__helper img {
  flex: none;
}

.repeat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.repeat > .fld,
.repeat > .add-row {
  align-self: stretch;
}

#translations {
  gap: 24px;
}

#translations .translation-row + .translation-row {
  margin-top: -8px;
}

/* ---------- Local names ---------- */
.local-names {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.local-names__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
}

.local-names__label {
  position: relative;
  top: 1px;
  color: var(--text-default);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.local-names__box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
}

.local-names__box:focus-within {
  border-color: var(--accent-focus);
}

.local-names__input {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text-default);
  font-family: var(--font);
  font-size: 15px;
  line-height: 22px;
}

.local-names__mic {
  position: relative;
  display: flex;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.local-names__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.local-names__list:empty {
  display: none;
}

.local-names__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-neutral);
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
}

/* ---------- Sections ---------- */
.add-sec {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding-top: 16px;
}

.add-sec--flush {
  padding-top: 0;
}

.add-sec > * {
  align-self: stretch;
}

.add-sec > .add-link {
  align-self: flex-start;
}

.add-sec__head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  line-height: 30px;
}

.add-sec__head .petal {
  inline-size: 14px;
  block-size: 14px;
}

.add-sec__head::after {
  content: '';
  flex: 1 0 0;
  height: 1px;
  background: var(--border);
}

.add-sec__lead {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

.add-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.add-next {
  margin-inline-start: auto;
}

/* ---------- Tags ---------- */
.tags {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.tags__label {
  position: relative;
  top: 1px;
  color: var(--text-default);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.tags__box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-self: stretch;
  gap: 8px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  cursor: text;
}

.tags__box:focus-within {
  padding: 7px 11px;
  border: 2px solid var(--accent-focus);
}

.tags__list {
  display: contents;
}

.tags__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  list-style: none;
}

.tags__item .chip-x {
  --cross: 7px;
  width: 10.7px;
  height: 16px;
  color: var(--green-600);
}

.tags__input {
  flex: 1 1 120px;
  min-width: 0;
  height: 24px;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text-default);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
}

.tags__hint {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 18px;
}

/* ---------- Attachments ---------- */
.photo-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-surface-subtle);
}

.photo-guide__title {
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
}

.photo-guide__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-guide__list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--green-700);
  font-size: 13px;
  line-height: 22px;
}

.photo-guide__list strong {
  font-weight: 600;
}

.uploader {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.uploader__drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  border-radius: var(--radius-sm);
  /* 1px stroke of 10px dashes and 5px gaps, as in the design. */
  background: var(--bg-neutral)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='.5' y='.5' rx='3.5' fill='none' stroke='%23d2d6db' stroke-dasharray='10 5' style='width:calc(100%25 - 1px);height:calc(100%25 - 1px)'/%3E%3C/svg%3E")
    0 0 / 100% 100% no-repeat;
  cursor: pointer;
}

.uploader__drop.is-dragging {
  background-color: var(--green-100);
}

.uploader__icon {
  display: block;
  margin: 1.25px 2.75px;
}

.uploader__text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.uploader__title {
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.uploader__formats {
  color: var(--text-paragraph);
  font-size: 12px;
  line-height: 18px;
}

.uploader__choose {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 2px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-neutral);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
}

.uploader__choose:hover {
  background: var(--bg-pressed);
}

.uploader__drop:focus-within .uploader__choose {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.uploader__files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.uploader__files:empty {
  display: none;
}

.uploader__file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-neutral);
}

.uploader__file > img {
  flex: none;
}

.uploader__name {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uploader__remove {
  width: 20px;
  color: var(--text-default);
}

.uploader__note {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

/* ---------- Sources ---------- */
.sources {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.source-row .fld {
  flex: 1 1 0;
}

.fld__box--remove .fld__control {
  padding-right: 16px;
  padding-left: 40px;
}

.fld__box--remove .chip-x {
  position: absolute;
  top: 10px;
  left: 14px;
}

/* ---------- Regions map ---------- */
.map-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.map-picker__locations {
  display: flex;
  flex: 1 1 260px;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.map-picker__label {
  position: relative;
  top: 1px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.map-picker__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map-picker__list:empty {
  display: none;
}

.map-picker__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-surface-subtle);
}

.map-picker__item > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-picker__item .chip-x {
  width: 12px;
  height: 18px;
}

.map-picker__name {
  position: relative;
  top: 1px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.map-picker__coords {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
  text-align: right;
}

.map-picker__empty {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

.ksa-map {
  position: relative;
  flex: none;
  width: 472px;
  max-width: 100%;
  aspect-ratio: 472 / 420;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--accent-surface-subtle) url('../img/add/map-grid.svg') 0 0 / 100% 100% no-repeat;
  direction: ltr;
}

.ksa-map__viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.ksa-map__viewport.is-zoomed {
  overflow: auto;
}

.ksa-map__sizer {
  position: relative;
  overflow: hidden;
}

.ksa-map__stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 472px;
  height: 420px;
  transform-origin: 0 0;
}

.ksa-map__regions {
  position: absolute;
  top: 18px;
  left: 17px;
  width: 438px;
  height: 360px;
}

.ksa-map__regions svg {
  display: block;
  overflow: visible;
}

.ksa-map__regions [role='button'] {
  cursor: pointer;
  outline: 0;
}

.ksa-map__regions [role='button']:hover .r-fill {
  fill: var(--green-100);
}

.ksa-map__regions [role='button']:focus-visible .r-fill {
  fill: var(--green-200);
}

/* Keyboard focus: an outline drawn above every region (see add.js). */
.ksa-map__focus {
  fill: none;
  stroke: #161616;
  stroke-width: 2px;
  stroke-linejoin: round;
  pointer-events: none;
}

.ksa-map[data-variant] .ksa-map__regions .is-selected .r-fill {
  fill: #88d8ad;
}

.ksa-map[data-variant='preview'] .ksa-map__regions .is-selected .r-fill {
  fill: #25935f;
}

.ksa-map__label {
  position: absolute;
  color: var(--text-default);
  font-size: 11px;
  font-weight: 600;
  line-height: 14px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.ksa-map__label--a,
.ksa-map__label--c {
  color: var(--text-secondary);
}

.ksa-map__label--b {
  color: #000;
}

.ksa-map__label.is-selected {
  color: var(--green-900);
}

.ksa-map[data-variant='preview'] .ksa-map__label {
  color: var(--green-900);
}

.ksa-map[data-variant='preview'] .ksa-map__label--b {
  color: var(--text-secondary);
}

/* As drawn: this label is white, so it only shows on a selected region. */
.ksa-map[data-variant='preview'] .ksa-map__label--c {
  color: #fff;
}

.ksa-map[data-variant='preview'] .ksa-map__label.is-selected {
  color: #fff;
}

.ksa-map.is-small .ksa-map__label {
  display: none;
}

.ksa-map__pin {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.ksa-map__zoom {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
}

.ksa-map__zoom button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-default);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
}

.ksa-map__zoom button:first-child {
  border-bottom: 1px solid var(--border);
}

.ksa-map__zoom button:hover {
  background: var(--bg-neutral);
}

/* ---------- Step 4: preview ---------- */
.add-review {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.add-review[hidden] {
  display: none;
}

.preview-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 16px 24px;
  border: 1px solid var(--green-300);
  border-radius: var(--radius-lg);
  background: var(--green-100);
}

.preview-banner__lead {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-banner__mark {
  inline-size: 28px;
  block-size: 28px;
}

.preview-banner__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-banner__title {
  position: relative;
  top: 1px;
  color: var(--green-900);
  font-size: 17px;
  font-weight: 700;
  line-height: 26px;
}

.preview-banner__note {
  color: var(--green-700);
  font-size: 13px;
  line-height: 20px;
}

.preview-banner__edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  color: var(--green-700);
  font-size: 14px;
  line-height: 20px;
}

.preview {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  /* 24px inside a 1.5px dashed stroke (8px dashes, 6px gaps), which CSS borders cannot draw. */
  padding: 26px;
  border-radius: var(--radius-lg);
  background: var(--accent-surface-subtle)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='.75' y='.75' rx='15.25' fill='none' stroke='%2388d8ad' stroke-width='1.5' stroke-dasharray='8 6' style='width:calc(100%25 - 1.5px);height:calc(100%25 - 1.5px)'/%3E%3C/svg%3E")
    0 0 / 100% 100% no-repeat;
}

.preview__content {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.preview__sidebar {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 24px;
  width: 400px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
}

.preview-card > * {
  max-width: 100%;
}

.preview-card__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 30px;
}

.preview-head {
  gap: 8px;
}

.preview-head__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.preview-head__tags li {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

.preview-head__lemma {
  font-size: 44px;
  font-weight: 700;
  line-height: 60px;
  overflow-wrap: anywhere;
}

.preview-head__scientific {
  align-self: stretch;
  color: var(--green-600);
  font-size: 22px;
  line-height: 30px;
  text-align: right;
}

.preview-head__description {
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 30px;
  white-space: pre-line;
}

.preview-names {
  gap: 4px;
}

.preview-names__list {
  align-self: stretch;
  margin: 0;
}

.preview-names__list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.preview-names__list dt {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  line-height: 22px;
}

.preview-names__list dd {
  min-width: 0;
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  overflow-wrap: anywhere;
}

.preview-quote {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: stretch;
  gap: 8px;
  margin: 0;
  padding: 20px 24px;
  border-inline-start: 4px solid var(--green-400);
  border-radius: var(--radius-md);
  background: var(--accent-surface-subtle);
}

.preview-quote__label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

.preview-quote__label .petal {
  inline-size: 14px;
  block-size: 14px;
}

.preview-quote__text {
  margin: 0;
  color: var(--green-900);
  font-size: 22px;
  font-weight: 500;
  line-height: 40px;
  white-space: pre-line;
}

.preview-quote__source {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
}

.preview-distribution__body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-self: stretch;
  gap: 24px;
}

.preview-distribution__body .ksa-map {
  /* Takes its 472px when there is room and shrinks before the pair wraps. */
  flex: 1000 1 240px;
  min-width: 0;
  max-width: min(100%, 472px);
}

.preview-distribution__panel {
  display: flex;
  flex: 1 1 150px;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  margin: 0;
}

.preview-distribution__panel > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-distribution__panel dt {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

.preview-distribution__panel dd {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 26px;
  white-space: pre-line;
}

.preview-more__list {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  gap: 12px;
  margin: 0;
}

.preview-more__list dt {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

.preview-more__list dd {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 26px;
  text-align: right;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.preview-gallery {
  align-items: stretch;
  gap: 12px;
  padding: 12px;
}

.preview-gallery--empty {
  padding: 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
  text-align: center;
}

.preview-gallery__main {
  display: block;
  width: 100%;
  height: 300px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.preview-gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.preview-gallery__thumbs button {
  display: block;
  width: 100%;
  height: 72px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bg-neutral);
  cursor: pointer;
}

.preview-gallery__thumbs button[aria-pressed='true'] {
  border: 2px solid var(--green-600);
}

.preview-gallery__thumbs img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-taxonomy {
  border-color: var(--accent-border);
  background: var(--accent-surface-subtle);
}

.ladder {
  align-self: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ladder__level {
  position: relative;
  padding: 0 30px 18px 0;
}

.ladder__level::before {
  content: '';
  position: absolute;
  top: 4px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: url('../img/add/ladder-dot.svg') center / 100% 100% no-repeat;
}

.ladder__level::after {
  content: '';
  position: absolute;
  top: 20px;
  right: 7px;
  bottom: 0;
  width: 2px;
  background: var(--green-200);
}

.ladder__level:last-child {
  padding-bottom: 0;
}

.ladder__level:last-child::before {
  right: 0;
  width: 16px;
  height: 16px;
  background-image: url('../img/add/ladder-dot-current.svg');
}

.ladder__level:last-child::after {
  display: none;
}

.ladder__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.ladder__label [lang='en'] {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
}

.ladder__value {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  text-align: right;
  overflow-wrap: anywhere;
}

.ladder__level--genus .ladder__value,
.ladder__level--species .ladder__value {
  font-weight: 400;
}

.ladder__level--species .ladder__value {
  color: var(--green-600);
}

.submit-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* 28px inside a 1.5px stroke; a CSS border would snap to 1px. */
  padding: 30px;
  border-radius: var(--radius-lg);
  background: var(--bg-white);
  box-shadow: inset 0 0 0 1.5px var(--green-600);
}

.submit-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
}

.submit-card__title {
  font-size: 22px;
  font-weight: 700;
  line-height: 32px;
}

.submit-card__meta {
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

.submit-card__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.submit-card__captcha {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.recaptcha {
  min-height: 78px;
}

.submit-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* ---------- Thank-you screen ---------- */
.add-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 64px 40px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  background: var(--accent-surface-subtle);
  text-align: center;
}

.add-done[hidden] {
  display: none;
}

.add-done__badge {
  display: block;
}

.add-done__title {
  font-size: 32px;
  font-weight: 700;
  line-height: 44px;
  outline: 0;
}

.add-done__text {
  max-width: min(560px, 100%);
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 28px;
}

.add-done__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 8px;
}

.add-done__home,
.add-done__home:hover {
  background: none;
  color: var(--text-default);
}

.add-done__home:hover {
  background: var(--bg-neutral);
}

/* ---------- Dialogs ---------- */
.add-dialog {
  /* Percentages, not viewport units: they follow the shell's zoom tool. */
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-white);
  color: var(--text-default);
  text-align: center;
}

.add-dialog::backdrop {
  background: rgba(16, 24, 40, 0.5);
}

.add-dialog--wide {
  width: min(640px, calc(100% - 32px));
  text-align: start;
}

.add-dialog__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.add-dialog__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 30px;
}

.add-dialog__head .add-dialog__title {
  flex: 1 1 0;
}

.add-dialog__count {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}

.add-dialog__count:empty {
  display: none;
}

.add-dialog__close {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.add-dialog__close:hover {
  background: var(--bg-neutral);
}

.add-dialog__lead {
  margin: 8px 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
}

.add-dialog__empty,
.missing__state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
}

.add-dialog__empty[hidden] {
  display: none;
}

.add-dialog__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-bottom: 12px;
}

.add-dialog__icon--error span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fee4e2;
  color: var(--danger);
  font-size: 24px;
  font-weight: 700;
}

.add-dialog__text {
  margin-top: 8px;
  font-size: 16px;
  line-height: 24px;
}

.add-dialog__lemma {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 28px;
}

.add-dialog__subtext {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 22px;
}

.add-dialog__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.add-dialog__danger,
.add-dialog__danger:hover {
  background: var(--danger);
}

#drafts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drafts__list,
.missing__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.draft {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.draft--active {
  border-color: var(--accent-border);
  background: var(--accent-surface-subtle);
}

.draft__open {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-default);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
  text-align: start;
  cursor: pointer;
}

.draft__open small {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

.draft--saved .draft__open small {
  color: var(--success-text);
}

.missing__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.missing__search {
  flex: 1 1 220px;
}

.missing__limit {
  flex: 0 0 120px;
}

.missing__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  color: var(--text-default);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
  text-align: start;
  cursor: pointer;
}

.missing__item:hover:not(:disabled),
.missing__item[aria-pressed='true'] {
  border-color: var(--accent-border);
  background: var(--accent-surface-subtle);
}

.missing__pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 20px;
}

.missing__pager[hidden] {
  display: none;
}

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .preview {
    flex-direction: column;
    align-items: stretch;
  }

  .preview__content {
    flex: none;
  }

  .preview__sidebar {
    width: auto;
  }
}

@media (max-width: 700px) {
  .add {
    padding-bottom: 48px;
  }

  .stepper {
    padding: 15px;
  }

  .stepper__step {
    flex: 1 1 0;
  }

  .stepper__label {
    font-size: 12px;
    line-height: 16px;
  }

  .stepper__sub {
    display: none;
  }

  .stepper__line {
    flex: 0 1 16px;
  }

  .add-card {
    padding: 15px;
  }

  .add-row,
  .source-row {
    flex-direction: column;
    align-items: stretch;
  }

  .add-row > *,
  .source-row .fld {
    flex: none;
  }

  .add-row__spacer {
    display: none;
  }

  .add-foot {
    flex-wrap: wrap;
  }

  .add-foot .btn,
  .submit-card__actions .btn {
    height: auto;
    min-height: 40px;
    padding-block: 8px;
    white-space: normal;
  }

  .preview {
    padding: 12px;
  }

  .preview-card,
  .submit-card {
    padding: 15px;
  }

  .preview-head__lemma {
    font-size: 32px;
    line-height: 44px;
  }

  .preview-quote {
    padding: 16px;
  }

  .preview-quote__text {
    font-size: 18px;
    line-height: 32px;
  }

  .add-done {
    padding: 31px 15px;
  }

  .add-done__title {
    font-size: 24px;
    line-height: 34px;
  }

  .add-dialog {
    padding: 20px;
  }
}
