/**
 * Contacts C2/C3: presentation of native embedded add/edit forms and read card.
 * Keep Roundcube's iframe, tabs, field controllers, validation and save intact.
 * Restricted to Elastic's large/normal framed layouts; no navigation override.
 */
html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details {
  box-sizing: border-box;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding: 24px;
  color: var(--cm-color-text);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contact-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contactphoto {
  float: none;
  flex: 0 0 72px;
  min-width: 72px;
  width: 72px;
  margin: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contactpic {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 20px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contactpic img {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: cover;
  background: var(--cm-color-surface-subtle);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contacthead {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .form-group {
  margin-bottom: 12px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .col-form-label {
  color: var(--cm-color-text-muted);
  font-size: 12px;
  line-height: 22px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details :is(input:not([type="hidden"]), select, textarea).form-control {
  min-width: 0;
  min-height: 36px;
  border: 1px solid #dedede;
  border-radius: 10px;
  box-shadow: none;
  background-color: var(--cm-color-surface);
  color: var(--cm-color-text);
  font-size: 13px;
  line-height: 1.5;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .form-control:focus {
  /* Elastic marks composite-field focus borders important. */
  border-color: var(--cm-color-focus) !important;
  outline: 2px solid var(--cm-color-focus);
  outline-offset: -2px;
  box-shadow: none;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .form-control::placeholder {
  color: var(--cm-color-text-muted);
  opacity: 1;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details select.custom-select {
  appearance: none;
  padding-right: 34px;
  background-image: url("../assets/icons/ui/lucide/regular/chevron-down.svg");
  background-size: 16px 16px;
  background-position: right 10px center;
  background-repeat: no-repeat;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details select.addfieldmenu {
  width: auto;
  min-width: 164px;
  max-width: 100%;
  min-height: 32px;
  border-color: transparent;
  background-color: var(--cm-color-surface-subtle);
  font-size: 12px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .nav-tabs {
  gap: 4px;
  margin-block: 24px 20px;
  padding-bottom: 0;
  border: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .nav-tabs .nav-link {
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  color: var(--cm-color-text-muted);
  font-size: 13px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .nav-tabs .nav-link.active {
  background: var(--cm-color-accent-soft);
  color: var(--cm-color-text);
  font-weight: 600;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .nav-tabs .nav-link:focus-visible {
  outline: 2px solid var(--cm-color-focus);
  outline-offset: 2px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactfieldgroup {
  margin-bottom: 24px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactfieldgroup legend {
  margin-bottom: 10px;
  color: var(--cm-color-text);
  font-size: 13px;
  font-weight: 600;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactselectsubtype {
  flex: 0 0 144px;
  max-width: 42%;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactcontrolleraddress .content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1 1 0;
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactcontrolleraddress .content .form-control {
  width: 100%;
  margin: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactcontrolleraddress .ff_street {
  grid-column: 1 / -1;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactcontrolleraddress .contactselectsubtype {
  align-self: flex-start;
  margin-right: 6px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactfieldbutton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--cm-color-text-muted);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactfieldbutton::before {
  content: "" !important;
  display: block;
  width: 16px;
  height: 16px;
  margin: 0 !important;
  background: currentColor;
  -webkit-mask: url("../assets/icons/ui/lucide/regular/trash-2.svg") center / contain no-repeat;
  mask: url("../assets/icons/ui/lucide/regular/trash-2.svg") center / contain no-repeat;
  font-family: inherit !important;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactfieldbutton:hover {
  background: var(--cm-color-danger-soft);
  color: var(--cm-color-danger);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) .btn-primary {
  min-height: 36px;
  padding-inline: 16px;
  border-color: var(--cm-color-accent-strong);
  border-radius: 10px;
  background: var(--cm-color-accent-strong);
  color: var(--cm-color-on-action);
  font-size: 13px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) .btn-primary:is(:hover, :focus, :active) {
  border-color: var(--cm-color-accent);
  background: var(--cm-color-accent);
  color: var(--cm-color-on-action);
  box-shadow: none;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) .btn-primary:focus-visible {
  outline: 2px solid var(--cm-color-focus);
  outline-offset: 2px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) .btn-primary.submit::before {
  content: "" !important;
  display: inline-block !important;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("../assets/icons/ui/lucide/regular/check.svg") center / contain no-repeat;
  mask: url("../assets/icons/ui/lucide/regular/check.svg") center / contain no-repeat;
}

/* C3: the actual native show document; no replacement card or navigation. */
html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show > .formcontent {
  box-sizing: border-box;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding: 24px;
  color: var(--cm-color-text);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contact-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contactphoto {
  flex: 0 0 72px;
  min-width: 72px;
  width: 72px;
  margin: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contactpic,
html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contactpic img {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  object-fit: cover;
  background: var(--cm-color-surface-subtle);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contacthead {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contacthead .source {
  margin: 0 0 6px;
  color: var(--cm-color-text-muted);
  font-size: 12px;
  line-height: 1.6;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contacthead .names {
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .nav-tabs {
  gap: 4px;
  margin-bottom: 24px;
  padding: 0;
  border: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .nav-tabs .nav-link {
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  color: var(--cm-color-text-muted);
  font-size: 13px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .nav-tabs .nav-link.active {
  background: var(--cm-color-accent-soft);
  color: var(--cm-color-text);
  font-weight: 600;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldgroup {
  margin-bottom: 24px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldgroup legend {
  margin-bottom: 10px;
  color: var(--cm-color-text);
  font-size: 13px;
  font-weight: 600;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldlabel {
  min-width: 110px;
  padding-left: 0;
  border: 0;
  background: transparent;
  color: var(--cm-color-text-muted);
  font-size: 12px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldcontent {
  min-width: 0;
  color: var(--cm-color-text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldcontent a {
  color: var(--cm-color-text);
  text-decoration: underline;
  text-decoration-color: var(--cm-color-border);
  text-underline-offset: 3px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldcontent a:hover {
  color: var(--cm-color-text);
  text-decoration-color: currentColor;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contactfieldcontent a:focus {
  background: var(--cm-color-accent-soft);
  color: var(--cm-color-text);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show > .formbuttons {
  box-sizing: border-box;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding: 0 24px 24px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .btn-primary {
  min-height: 36px;
  padding-inline: 16px;
  border-color: var(--cm-color-accent-strong);
  border-radius: 10px;
  background: var(--cm-color-accent-strong);
  color: var(--cm-color-on-action);
  font-size: 13px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .btn-primary:is(:hover, :focus, :active) {
  border-color: var(--cm-color-accent);
  background: var(--cm-color-accent);
  box-shadow: none;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show :is(.btn-primary, .nav-link, .contactfieldcontent a):focus-visible {
  outline: 2px solid var(--cm-color-focus);
  outline-offset: 2px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .btn-primary::before {
  content: "" !important;
  display: inline-block !important;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("../assets/icons/ui/lucide/regular/pencil.svg") center / contain no-repeat;
  mask: url("../assets/icons/ui/lucide/regular/pencil.svg") center / contain no-repeat;
}

/* C8: a cohesive contact header and quieter, consistently aligned form. */
html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contacthead .names {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 0 12px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .contact-header {
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 26px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show #contacthead {
  flex: 1 1 200px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show .cm-contact-header-edit {
  flex: 0 0 auto;
  margin: 0 0 0 auto;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook.action-show > .formbuttons.cm-contact-actions-moved:not(:has(> :not(#cm-contact-edit-home))) {
  display: none;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contacthead .form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 0 14px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contacthead .form-group > :is(.col-form-label, .col-sm-8, .col-sm-9, .col-sm-10) {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  padding: 0;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactselectsubtype {
  flex-basis: 124px;
  background-color: var(--cm-color-surface-subtle);
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) #contact-details .contactfieldgroup {
  margin-bottom: 22px;
}

html.iframe:is(.layout-large, .layout-normal):not(.dark-mode) body.task-addressbook:is(.action-add, .action-edit) .formbuttons {
  padding: 12px 24px;
  border-top: 1px solid var(--cm-color-divider);
  background: var(--cm-color-surface);
}
